Skip to content

fix(tests): 21 k8s tests fail where kubectl is not on PATH #5132

Closed

Description

@dan-petty

Problem Description

The roadmap implement job stops because the runner image holds no kubectl and about 20 unit tests need a real kubectl binary. The implement runner Job for #1878 (2026-11-12 14:22-15:32Z, image sha256:c8d2f7c80de33578454240252dfc94730ff674dc124598574e12bc57f551d79c) ran uv run devops ci test. The run failed on the base commit too, with FileNotFoundError: 'kubectl'. The job then stopped with failure class plan_defect.

The runner image leaves kubectl out on purpose (NOT_IN_RUNNER in src/devops_cli/roadmap/runner_tools.py; #3562 defers it). The defect is in the tests: docs/TESTING.md says that a test of src/ starts no system program, that the lookup of a program on PATH is part of its fake, and that a test must not skip based on host state. ADR 0007 (amendment of 2026-10-24) removes the allowance for kubectl offline renderers. The hermetic floor in tests/conftest.py still lets every test start kubectl kustomize and kubectl patch --local, so a test that needs the real binary passes in the devcontainer and on the GitHub runner and fails only where kubectl is missing.

The 21 tests and their causes:

  • tests/k8s/test_image_pins.py (9 tests): the autouse fixture _kustomize_runs_for_real sends kubectl kustomize to the real binary. The image-pins workflow already runs devops k8s image-pins with the real tools.
  • tests/k8s/test_k8s_argocd_gate.py (10 tests): the fixture fakes kubectl kustomize, but not the lookup. _check_tree in src/devops_cli/k8s/argocd_gate.py calls shutil.which("kubectl") and raises ArgoCDGateError when it finds nothing.
  • tests/commands/k8s/test_k8s.py::test_deploy_stack_leaves_the_service_digest_image_updater_set_on_application_devops: the test runs a real kubectl patch --local on the patch that deploy-stack sends.
  • tests/commands/k8s/test_k8s_rag_ingest_manifests.py::test_qdrant_secret_scoped_to_ingest_workflow_template_only: the test renders the committed k8s/devops with a real kubectl kustomize. That is a check of committed files, which docs/TESTING.md puts in the k8s row of devops ci.

Reproduction Steps

  1. Make a directory that holds a symbolic link to each program of /usr/local/bin except kubectl, and put it in PATH in place of /usr/local/bin. Do not change the host.
  2. Run env PATH=<that PATH> uv run pytest -n 6 -q tests/k8s/test_image_pins.py tests/k8s/test_k8s_argocd_gate.py tests/commands/k8s/test_k8s.py tests/commands/k8s/test_k8s_rag_ingest_manifests.py.

Expected vs Actual Behavior

Expected: the tests pass with or without kubectl on PATH, as on the stock GitHub runner and in the runner image.

Actual: 21 tests fail. The output is 21 failed, 2309 passed over the files that name kubectl. The full suite with kubectl hidden gives 24 failed, 23949 passed: the 21 tests above, and the 3 tests of the review_window scenario and test_review_facts, which fail with kubectl on PATH too (#4865).

Environment Diagnostics

Devcontainer with kubectl at /usr/local/bin/kubectl, hidden from PATH for the run. Runner image of the implement job, which holds no kubectl.

Logs, Traces, or Terminal Output

FAILED tests/k8s/test_image_pins.py::test_an_image_on_the_latest_tag_is_not_a_pin - FileNotFoundError: [Errno 2] No such file or directory: 'kubectl'
FAILED tests/k8s/test_k8s_argocd_gate.py::test_a_clean_tree_passes_and_names_each_application_it_built - devops_cli.exceptions.k8s.ArgoCDGateError: kubectl is required to build Argo CD applications. Run 'devops install-tools --tool kubectl'.
FAILED tests/commands/k8s/test_k8s.py::test_deploy_stack_leaves_the_service_digest_image_updater_set_on_application_devops - FileNotFoundError: [Errno 2] No such file or directory: 'kubectl'
FAILED tests/commands/k8s/test_k8s_rag_ingest_manifests.py::test_qdrant_secret_scoped_to_ingest_workflow_template_only - FileNotFoundError: [Errno 2] No such file or directory: 'kubectl'

Proposed fix

  • test_image_pins.py: answer kubectl kustomize from the files of the test tree and the canned chart render.
  • test_k8s_argocd_gate.py: make the fake of kubectl include its lookup on PATH.
  • The deploy-stack test: check that the patch is a JSON merge patch (RFC 7386) that names kustomize.patches alone, with no real kubectl.
  • The Qdrant Secret test: move it to the k8s row of devops ci (tests/gate/k8s_checks/).
  • Guard: remove the kubectl offline-renderer allowance from the floor, as ADR 0007 decided, so a test that starts a real kubectl fails on every host. A floor test proves the refusal.

Related: #1878 (the stopped job), #3562 (kubectl in the runner image, a separate security decision).

Source: #1878

Activity

  1. added
    source/agent
    on Nov 12, 2026
  2. added
    type/bug
    scope/tests
    status/new
    value/high
    effort/medium
    on Nov 12, 2026
  3. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor
    • Priority: P1-High. The failure stops the roadmap implement job and blocks the CI pipeline.
    • Related: feat(roadmap): Add kubectl and kube-linter to runner tool catalog #3562, which asks for a different change. Both address kubectl being absent from the runner image, but #3562 adds the tool to the environment while the candidate fixes the tests to not require it.
  4. added
    priority/p1-high
    owner/agent
    on Nov 12, 2026
  5. removed
    status/new
    owner/agent
    on Nov 12, 2026
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/mediumpriority/p1-highscope/testssource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions