/gitops-argo-skills:argocd-sync-failure-and-drift-investigationfrom gitops-argo-skills
Troubleshoots Argo CD sync failures and drift: OutOfSync/Progressing/Degraded states, failing hook Jobs, and distinguishing manual edits from genuine Git/cluster divergence.
Ships in gitops-argo-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
An Application reporting OutOfSync, stuck Progressing, or a failed
sync operation tells you that something is wrong but rarely tells you
why at a glance — the real cause is buried in a specific resource's
diff, a specific hook Job's pod logs, or the distinction between "Git and
the cluster genuinely disagree" versus "someone changed a live resource
by hand and Argo CD hasn't reconciled it yet." This skill assumes the
Application spec itself (sync policy, sync waves, hooks, custom health
checks) is already configured per
argocd-application-configuration
and goes deep on the investigative workflow for when that configuration
isn't behaving as expected in a running cluster: reading resource-level
diffs, tracing a failing hook to its root cause, and telling manual
cluster drift apart from real Git/cluster divergence before deciding
whether to sync, patch Git, or leave a resource alone.
Application shows OutOfSync and it's not obvious which
resource(s) differ or why.Application is stuck Progressing past the point it should
normally settle, or a sync operation is stuck Running/Terminating.PreSync, Sync, or PostSync hook Job failed, timed out, or is
blocking the rest of the sync from proceeding.kubectl edit/kubectl patch/kubectl scale directly
against a resource Argo CD manages, and you need to know whether that
change will be reverted, silently kept, or is masking a real
discrepancy with Git.Application reports Synced/Healthy but a user insists the
cluster is doing something different from what's in Git (or vice
versa).OutOfSync diff represents a resource that should
be synced from Git, or a field that should instead be added to
ignoreDifferences because the live value is legitimately
controller-managed.argocd CLI access
(argocd login <ARGOCD_SERVER>) and read (at minimum) RBAC on the
target Application/AppProject.kubectl access to the destination cluster for direct inspection —
the argocd CLI's view is derived from the same live state but is
sometimes stale relative to a fresh kubectl get.Application's Git source repo accessible for comparison
(git log, git blame on the manifest path) so you can tell whether a
live-cluster value was ever declared in Git at all.Application spec fields this skill diagnoses
against — see
argocd-application-configuration
for syncPolicy, ignoreDifferences, sync waves, and hooks if any of
those concepts are unfamiliar; this skill does not re-explain them.kubectl logs/kubectl describe pod access in the
destination namespace to read the failing hook Job's actual pod
output, not just Argo CD's summary status.Start from the Application's own status, not just the UI's
red/yellow dot. Pull the full status block for the actual sync/health
condition and the specific resource(s) implicated:
argocd app get payments-api-prod -o json | jq '.status.sync, .status.health, .status.operationState'
kubectl get application payments-api-prod -n argocd -o jsonpath='{.status.conditions}'
status.sync.status (Synced/OutOfSync), status.health.status
(Healthy/Progressing/Degraded/Missing/Unknown), and
status.operationState.phase (Succeeded/Failed/Error/Running)
are three independent signals — a Synced + Degraded
Application and an OutOfSync + Healthy one are different
problems requiring different fixes, so don't collapse them into one
"is it broken" question.
Get the resource-level diff, not the app-level summary. argocd app diff shows exactly which fields differ, per resource, between
the Git-rendered manifest and the live object:
argocd app diff payments-api-prod
Read the diff output as < live cluster / > Git desired (or the
reverse depending on CLI version — confirm with --help if unsure).
A diff limited to one or two fields on one resource (e.g. replicas,
an injected annotation) is a very different problem from a diff
spanning many resources (usually a bad merge, a botched Kustomize
overlay, or the wrong targetRevision).
Narrow to the specific resource when the app has many. argocd app resources lists every managed resource with its own sync/health
status so you're not diffing the whole app to find one bad
Deployment:
argocd app resources payments-api-prod
argocd app diff payments-api-prod --resource apps:Deployment:payments-prod/payments-api
Distinguish manual drift from genuine Git/cluster divergence —
this is the crux of most confusing OutOfSync reports:
git show <targetRevision>:<path> (or argocd app manifests payments-api-prod for the fully-rendered desired state). If the
field isn't in the Git-rendered manifest, its live value came from
somewhere else — a mutating webhook, an HPA, a defaulting
controller, or a manual edit — not from Git diverging.kubectl get <resource> -o yaml for
metadata.managedFields (kubectl get deploy payments-api -n payments-prod --show-managed-fields -o yaml) to see which field
manager last wrote that field and when — argocd-controller means
Argo CD itself made the last write (so the diff is likely transient
or a race), while kubectl-edit/kubectl-patch/a human's kubeconfig
user means someone changed it out-of-band.argocd app history payments-api-prod against the
timing of the suspected manual change — if the last successful sync
predates when the manual edit was made, the live cluster and the
sync history simply haven't caught up yet; that's expected, not a
bug.selfHeal is enabled and the field still shows as different
after a completed sync, the manual edit is being fought and
re-applied continuously — that's the sync-loop pitfall, and the fix
is ignoreDifferences, not disabling selfHeal (see
argocd-application-configuration
Common pitfalls).Investigate a stuck/failing sync hook by going straight to the
hook's own Job/Pod, not the Application's summary. Argo CD's
operationState reports which hook is blocking, but the actual error
is in the pod:
argocd app get payments-api-prod -o json | jq '.status.operationState.syncResult.resources[] | select(.hookType != null)'
kubectl get jobs -n payments-prod -l argocd.argoproj.io/hook-type
kubectl logs job/payments-api-migrate -n payments-prod
kubectl describe pod -l job-name=payments-api-migrate -n payments-prod
Common root causes at this point: the hook container's command
exited non-zero (application-level bug in the migration/script — read
the actual log line), the pod never scheduled (resource
requests/limits or a missing image pull secret — check kubectl describe pod events), or the hook Job hit its own activeDeadlineSeconds
/ Argo CD's operation timeout before finishing.
If a hook is stuck because a previous failed run's Job object still
exists, confirm the hook-delete-policy and clean up manually if
needed rather than waiting indefinitely:
kubectl get jobs -n payments-prod -l argocd.argoproj.io/hook-type=PreSync
kubectl delete job payments-api-migrate -n payments-prod # only if hook-delete-policy is missing/insufficient
argocd app sync payments-api-prod
Prefer fixing hook-delete-policy: HookSucceeded,HookFailed in Git
(see
argocd-application-configuration)
over repeatedly deleting stuck Jobs by hand — the manual delete is a
one-time unblock, not a fix for the recurring cause.
When a Degraded/stuck Progressing resource is a custom CRD,
confirm whether Argo CD has real health-check logic for that kind
before trusting its verdict:
kubectl get application payments-api-prod -n argocd -o jsonpath='{.status.resources[?(@.kind=="DatabaseClaim")]}'
kubectl get databaseclaim payments-api-db -n payments-prod -o yaml
If kubectl shows the resource genuinely healthy but Argo CD reports
Progressing/Unknown indefinitely, this is a missing custom health
check, not a real problem with the resource — see
argocd-application-configuration
step 5 for adding one, rather than treating the app as actually
broken.
Before forcing a resolution, run a dry-run to see exactly what a real sync would change:
argocd app sync payments-api-prod --dry-run
argocd app sync payments-api-prod --resource apps:Deployment:payments-prod/payments-api --dry-run
Only escalate to argocd app sync --force (replace semantics) or
argocd app terminate-op (abort a stuck operation) once the dry-run
diff and the hook logs make the root cause unambiguous — both are
stronger, riskier actions than a normal sync (see Common pitfalls).
status.sync, status.health, and
status.operationState as three separate signals before deciding what
"broken" means for a given Application — conflating them leads to
fixing the wrong thing.argocd app diff --resource ...) as soon
as an app manages more than a handful of resources — an app-wide diff
on a large Application buries the one relevant field in noise.managedFields/field-manager inspection as the standard way to
tell "Argo CD wrote this last" from "a human/other controller wrote
this last" — don't guess based on how the diff looks.ignoreDifferences (if the
field is legitimately externally managed) or a written runbook telling
humans to change it in Git, not kubectl, going forward — treat
repeated manual drift on the same field as a process gap, not a
one-off to silently re-sync away each time.argocd app sync --dry-run and --resource-scoped syncs over a
full --force sync when the cause is still unclear — narrow the blast
radius while you're still diagnosing, not after.Symptom: argocd app diff shows no meaningful difference, yet the
Application still reports OutOfSync.
Fix: The diff is likely in a field Argo CD compares but doesn't
render clearly in the default diff view (e.g. an annotation ordering
difference, or a field under a status subresource being compared when
it shouldn't be). Run argocd app diff --hard-refresh to bypass any
cached comparison and force a fresh live-state fetch before concluding
the diff tool itself is wrong.
Symptom: A resource keeps flipping between Synced and OutOfSync
every reconciliation loop, and each argocd app diff shows the same
field toggling.
Fix: This is a live sync loop, not intermittent drift — a mutating
admission webhook, HPA, or defaulting controller is rewriting the field
immediately after every sync (selfHeal reverts it, the controller sets
it again). Confirm via managedFields timestamps, then add the field
to spec.ignoreDifferences (see
argocd-application-configuration)
instead of repeatedly re-syncing.
Symptom: A PreSync hook Job is stuck Running far past when it
should have finished, and the sync operation itself is stuck
Running/never times out.
Fix: Check kubectl describe pod for the hook — a common cause is
the pod never actually scheduled (insufficient node resources, a
missing/misconfigured image pull secret) so there's no process to time
out yet. Argo CD's operation-level timeout doesn't fire on a pod that
never started; fix the scheduling blocker directly, or set
activeDeadlineSeconds on the hook Job spec so it self-terminates
instead of hanging indefinitely.
Symptom: Someone kubectl scaled a Deployment's replicas up during
an incident, and thirty seconds later it silently reverted back to the
Git-declared value — the on-call engineer assumes Argo CD is
"fighting" them and disables sync entirely as a workaround.
Fix: This is selfHeal working as designed, not a bug — the
replica count is declared in Git and Argo CD is correctly reverting
the out-of-band change. During an active incident where a temporary
manual scale is intentional, either pause automated sync for that
specific Application (argocd app set <app> --sync-policy none) or
add a temporary Prune=false/ignoreDifferences entry, and revert the
workaround once the incident resolves — don't leave sync disabled
indefinitely as the "fix."
Symptom: argocd app sync --force was used to unblock a stuck sync,
and it deleted and recreated a resource with an immutable field
(ClusterIP, a PVC's storage class), causing unexpected downstream
breakage.
Fix: --force uses replace (delete+create), not patch, semantics —
reserve it for genuine "the API server rejects a normal patch" cases
confirmed via the actual error in operationState.message, run
argocd app diff first to see what would be replaced, and prefer
--resource-scoped --force over an app-wide one so only the resource
that genuinely needs replacing is affected.
Symptom: A stuck sync operation is aborted with argocd app terminate-op, but some resources from the partial sync were already
applied and others weren't, leaving the cluster in a half-migrated
state.
Fix: terminate-op stops the operation, not the already-applied
changes — after terminating, immediately run argocd app diff to see
exactly which resources are now inconsistent, and re-sync deliberately
(ideally --dry-run first) rather than assuming termination reverted
anything.
Scenario: payments-api-prod has shown OutOfSync for two days.
The team assumed it was "just a flaky sync" and kept clicking "Sync" in
the UI, which briefly clears the status before it returns within
minutes.
Pull the three independent status signals:
argocd app get payments-api-prod -o json | jq '.status.sync.status, .status.health.status, .status.operationState.phase'
Result: "OutOfSync", "Healthy", "Succeeded" — the app is
functionally fine (healthy), it's specifically the Git/cluster
comparison that's mismatched, and the last sync operation itself
completed without error. This rules out a hook failure entirely.
Get the resource-level diff:
argocd app diff payments-api-prod
Output shows a single difference on the payments-api Deployment:
spec.replicas: live=12, git=3.
Check whether replicas is even meaningfully declared in Git as 3,
or whether an HPA manages it:
kubectl get hpa payments-api -n payments-prod -o yaml
Confirms an HPA (payments-api-hpa) targets this Deployment and had
scaled it to 12 replicas under load — replicas in Git is just the
HPA's minimum floor, not the live intended value, so this was never
real drift; it's the well-known HPA-vs-GitOps interaction.
Fix at the source rather than re-syncing daily: add replicas to
ignoreDifferences in the Application spec (per
argocd-application-configuration):
spec:
ignoreDifferences:
- group: apps
kind: Deployment
name: payments-api
jsonPointers:
- /spec/replicas
After applying, argocd app get payments-api-prod reports Synced
permanently (barring an actual Git change), and the team stops
manually re-syncing an app that was never actually out of sync in any
meaningful way.
ignoreDifferences are configured; this skill diagnoses that configuration's runtime behavior.Applications at once rather than a single app.Degraded state with metrics/logs/traces during a live incident.kubectl change made during an active incident without it becoming a confusing drift investigation afterward.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
11 skills in this plugin
/argocd-application-configurationConfigures Argo CD `Application` custom resources — sync policies (automated vs. manual, prune, self-heal), sync waves and hooks for ordered/multi-phase rollouts, and health checks for custom resource types. Use when the user asks to "write an Argo CD Application manifest," "enable auto-sync / self-heal / prune," "order resources with sync waves," "add a PreSync/PostSync hook," "fix an Application stuck OutOfSync or Progressing," or "define a custom health check for a CRD Argo CD doesn't understand natively."
/argocd-applicationset-patternsDesigns Argo CD `ApplicationSet` resources that template many `Application` objects from a single source using generators — List, Cluster, Git directory/file, and Matrix (combined generators). Use when the user asks to "generate an Application per cluster/environment/ directory," "avoid copy-pasting Argo CD Applications," "roll out a service to a fleet of clusters," "combine a cluster generator with a Git generator," or "debug an ApplicationSet producing unexpected or missing Applications."
npx claudepluginhub selvarajmurugesan90/ops-engineering-skills --plugin gitops-argo-skillsOther plugins' skills for the same job