Repository navigation
Description
Problem
The test double FakeCluster._read_pod_single in tests/support/infra.py returns a synthetic pod on node-1 for every unknown pod name.
When Service Image Tests executes inside a container, Docker sets the HOSTNAME environment variable.
In src/devops_cli/infra/nodes.py, current_pod_node reads HOSTNAME when NODE_NAME is not set and queries kubectl get pod $HOSTNAME.
FakeCluster answers that this pod is on node-1.
When test_an_agent_stops_before_the_control_plane_node executes, apply finds that the host node matches the pod node.
It stops with node-1.example.com (node-1) is its pod node before it evaluates the control-plane node check.
The test fails on AssertionError: assert 'node-1.example.com (node-1) is the control-plane node' in report['reason'].
This defect causes Service Image Tests (shard 1 of 6) to fail on all Renovate pull requests that change container inputs (#6986, #6987, #6989, #6991).
Change
Return exit code 1 with pods "<name>" not found in FakeCluster._read_pod_single when the requested pod is not known.
Add an assertion in test_an_agent_stops_before_the_control_plane_node to ensure the test passes when HOSTNAME is set.
Proposed design
Problem statement
FakeCluster._read_pod_single returns a synthetic pod on node-1 for every unknown pod name. In a container, HOSTNAME makes current_pod_node query a pod that FakeCluster then places on node-1. test_an_agent_stops_before_the_control_plane_node stops at the pod-node check and fails. The fix returns kubectl's not-found error for unknown pods and makes the test assert the control-plane reason with HOSTNAME set.
Acceptance criteria
Requirement: Unknown pod returns not found
FakeCluster._read_pod_single SHALL return exit code 1 with stderr pods "<name>" not found when the requested pod is not a known CNPG primary pod.
Scenario: Unknown pod name
- WHEN A test installs FakeCluster and runs
kubectl get pod missing-pod -o json. - THEN The fake returns exit code 1, stdout is empty, and stderr contains
pods "missing-pod" not found.
Requirement: Known CNPG primary pod still resolves
FakeCluster._read_pod_single SHALL still return the primary pod of a known CNPG cluster.
Scenario: Known CNPG primary pod
- WHEN A test adds a FakeCNPGCluster named
dbonnode-2and runskubectl get pod db-1 -o json. - THEN The fake returns exit code 0 and the pod spec has
nodeNamenode-2.
Requirement: Control-plane test with HOSTNAME
test_an_agent_stops_before_the_control_plane_node MUST pass when HOSTNAME names a pod that FakeCluster does not know.
Scenario: HOSTNAME set to an unknown pod
- WHEN The test sets HOSTNAME to
service-image-tests, clears NODE_NAME, and runsuv run pytest tests/commands/test_infra_apply.py -k test_an_agent_stops_before_the_control_plane_node. - THEN The test passes,
report['reason']containsis the control-plane node, and it does not containis its pod node.
Existing Tool Considered
No alternatives check has run. No open, maintained tool or library covers this change: it corrects the repository's own FakeCluster test double. The change edits existing code (about 10 lines) and adds one test assertion. The build cost is under 2,000 tokens and under 15 minutes of elapsed time.
Key questions
- What should FakeCluster._read_pod_single return for an unknown pod?: Return exit code 1 with stderr
pods "<name>" not found, as kubectl does and as the existing CNPG and Argo CD not-found answers do. (best practice) [sources: tests/support/infra.py, src/devops_cli/infra/nodes.py, tests/commands/test_infra_apply.py]- Chosen: Return kubectl not-found error. It matches kubectl and the existing
_read_cnpgand_read_appanswers. It removes the synthetic node-1 pod. - Rejected: Keep a synthetic pod on node-1. It hides a missing pod. It makes HOSTNAME resolve to node-1 and causes the early stop.
- Rejected: Return an empty pod with no nodeName. It does not match kubectl. Callers cannot tell a missing pod from an unassigned pod.
- Chosen: Return kubectl not-found error. It matches kubectl and the existing
- How should the test control HOSTNAME to exercise the container case?: Use pytest
monkeypatchto set HOSTNAME to a pod name absent from FakeCluster and to remove NODE_NAME. Then assert the report reason is the control-plane reason. (best practice) [sources: tests/commands/test_infra_apply.py, tests/support/infra.py]- Chosen: Set HOSTNAME with monkeypatch. It is deterministic and reproduces the container case.
- Rejected: Rely on the CI container HOSTNAME. It is environment-dependent and may be absent locally.
- Rejected: Unset HOSTNAME. It does not exercise the container path.
- Does the change need a new dependency or tool?: No. The change uses the existing FakeCluster and the pytest monkeypatch fixture. [sources: tests/support/infra.py, tests/commands/test_infra_apply.py]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 24, 2026
CI shard 1 of 6 fails on all Renovate PRs that change container inputs.Both fix a test fixture that causes CI failures, but #3990 fixes cluster_jobs isolation while this fixes FakeCluster pod lookup.devops-cli-service commentedon Nov 24, 2026
Next step: the alternatives check records a verdict. See the section Proposed design of the body.
devops-cli-service commentedon Nov 24, 2026
Released in v0.209.2: https://github.com/dan-petty/devops-cli/releases/tag/v0.209.2
devops-cli-service commentedon Nov 24, 2026
Live since 2026-11-24 15:27 UTC