Skip to content

fix(infra): report not found for missing pod in FakeCluster #6994

Done

Description

@dan-petty

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 db on node-2 and runs kubectl get pod db-1 -o json.
  • THEN The fake returns exit code 0 and the pod spec has nodeName node-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 runs uv run pytest tests/commands/test_infra_apply.py -k test_an_agent_stops_before_the_control_plane_node.
  • THEN The test passes, report['reason'] contains is the control-plane node, and it does not contain is 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_cnpg and _read_app answers. 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.
  • How should the test control HOSTNAME to exercise the container case?: Use pytest monkeypatch to 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

  1. dan-petty commented on Nov 24, 2026

    @dan-petty
    OwnerAuthor
  2. added
    type/bug
    scope/infra
    source/agent
    status/new
    effort/low
    value/high
    priority/p0-critical
    owner/agent
    on Nov 24, 2026
  3. devops-cli-service commented on Nov 24, 2026

    @devops-cli-service
    Contributor

    Next step: the alternatives check records a verdict. See the section Proposed design of the body.

  4. added
    status/in-progress
    status/in-review
    and removed
    status/new
    status/in-progress
    on Nov 24, 2026
  5. removed
    status/in-review
    owner/agent
    on Nov 24, 2026
  6. devops-cli-service commented on Nov 24, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-24 15:27 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p0-criticalscope/infrasource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions