Skip to content

Argo CD server-side apply: a field removed from git persists live

Problem

A field was deleted from the manifest in git (here: spec.ingress on the Kanidm CR, Phase 6 of the ingress-nginx migration) but it stays on the live object. The Argo CD app reports Synced/Healthy, the repo diff is empty, and the workload that consumes the field (here the Kanidm operator, which kept creating its Ingress) keeps acting on it. A forced sync does not remove it either.

Root Cause

With ServerSideApply=true, Argo CD prunes a field only if its own field manager owns it. The live CR still carried an old Update entry for manager argocd-controller in metadata.managedFields, written before the app switched to server-side apply (client-side Update, no Apply). Fields owned through that entry are not pruned by an SSA apply that no longer lists them. Argo CD's ClientSideApplyMigration only migrates the kubectl-client-side-apply manager, so it never touches the argocd-controller Update entry. Server-side apply keeps no last-applied annotation, so Argo CD also sees no diff for a removed field.

How to Diagnose

kubectl --context=<ctx> -n <ns> get <kind> <name> --show-managed-fields -o json \
  | jq '.metadata.managedFields[] | {manager, operation, time, fields: (.fieldsV1 | keys)}'
# find which manager owns the stale path, e.g. f:spec -> f:ingress
kubectl --context=<ctx> -n <ns> get <kind> <name> --show-managed-fields -o json \
  | jq '.metadata.managedFields[] | select(.fieldsV1."f:spec"."f:ingress") | {manager, operation}'

A leftover Update entry from argocd-controller (or any manager other than the current Argo CD SSA manager) that owns the removed path is the signature.

Fix / Workaround

  • One-time patch of the live field, done by the owner (Argo CD then stays Synced because git no longer has it): kubectl --context=<ctx> -n <ns> patch <kind> <name> --type=json -p '[{"op":"remove","path":"/spec/<field>"}]'. Used for Kanidm spec.ingress; the operator then deleted its Ingress.
  • Alternatively remove the stale managedFields entry so the next SSA apply owns and prunes the field.
  • Optional, untested: the argocd.argoproj.io/client-side-apply-migration-manager annotation on the resource, naming the manager to migrate (default is kubectl-client-side-apply).
  • Objects generated by an operator from the removed field (Ingress kanidm/kanidm, vault/vault) are not owned by Argo CD and are never pruned by it. Either the operator deletes them after the field is gone, or they need a one-off manual cleanup (done for vault/vault, an orphan).

Before relying on removal of a field via git alone, check for stale managers on CRs that were converted to server-side apply.