Skip to content

fix(k8s): argo cd sync honours --prune and --force, rollout promote and abort reach the status subresource, and teardown's argo check fails closed #1433

Closed

Description

@dan-petty

Problem

Lines cited at 05e9388 (release/v0.2.29).

  • Sync drops its options.
    • Three callers POST {"sync": {"prune": ..., "force": ...}} to /api/v1/applications/{name}/sync: devops argo sync (commands/argo.py:256-262), the fleet sync (argo/fleet.py:57) and the GitOps trigger (argo/gitops.py:311).
    • Argo CD's ApplicationSyncRequest has no sync field. Prune is a top-level field and force is strategy.apply.force, so neither option reaches the sync.
  • Promote and abort change nothing.
    • promote_rollout and abort_rollout (argo/crd.py:215-240) send a {"status": ...} merge patch through patch_namespaced_custom_object (:128).
    • The Rollout CRD declares a status subresource, so the API server ignores .status on the main resource.
    • _mutate_rollout still returns True (argo/rollouts.py:70-75), and the metric gate then reports aborted (:167-169).
  • Teardown's safety check fails open.
    • _is_cluster_argo_managed (commands/k8s/stack_lifecycle.py:536-545) runs kubectl -n argocd get application cluster without -o and tests "cluster" in stdout.
    • It returns False on any non-zero exit. A timeout, an RBAC denial or an API error therefore lets teardown proceed (:1209).

Proposed remedy

  • Sync body. One request-body builder for the three sync callers: {"prune": prune, "strategy": {"apply": {"force": force}}}, plus appNamespace where it is sent today.
  • Rollouts. Promote and abort patch through patch_namespaced_custom_object_status. Promote also clears spec.paused when it is set, as kubectl argo rollouts promote does.
  • Teardown check. It reads the Application through ArgoCRDService (CustomObjectsApi).
    • 404 means the cluster is not managed by Argo CD.
    • Any other error refuses teardown and states the reason.

Acceptance criteria

  • For each of the three sync paths, the body recorded at the HTTP fake has a top-level prune and strategy.apply.force, and no sync key.
  • Promote and abort reach the status subresource in refactor(k8s): KubernetesService is the Kubernetes API seam, with a shared fake cluster and its contract suite #1315's fake cluster.
  • A refused patch makes _mutate_rollout report failure, and the gate reports abort_failed.
  • A 404 for the cluster Application allows teardown.
  • A 403, a timeout or a 500 stops teardown with an error.
  • Tests run offline with fakes only at process and HTTP edges; each new test runs under 1 s.
  • uv run devops ci passes.

Related: #1327 and #1335 (these clients move onto the egress factory), #1315, #1323, #755.

Found by the 2026-10-08 client-library audit.

Opened as a borrow (#1153, budget/borrowed): the agent filing quota is spent for this cycle, and this is a defect or security finding of the owner-requested 2026-10-08 client-library audit.

Activity

  1. added
    type/bug
    scope/k8s
    source/agent
    on Oct 8, 2026
  2. dan-petty-bot commented on Oct 8, 2026

    @dan-petty-bot
    Collaborator

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Priority: P2-Medium. The teardown fail-open could allow unintended cluster teardown on transient errors, and sync/rollout options silently no-op, but each requires a specific error path or user action to manifest.
    • Value: High. Three core Argo CD operations (sync with prune/force, rollout promote/abort, and teardown safety) are broken, directly undermining the reliability of the cluster management workflow.
    • Effort: Medium. Three distinct fixes across five-plus files with a clear proposed remedy for each, plus tests at process and HTTP edges, but no architectural change.
  3. added a commit that references this issue on Oct 25, 2026
    3596f38
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

    scope/k8ssource/agenttype/bug

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions