Argo CD auto-sync pruned a resource in CI
With prune: true, auto-sync deletes live resources that are no longer in Git. That is intended, but a wrong source path, a bad targetRevision, or an accidental manifest deletion can cause prune to remove resources you did not mean to drop.
What this error means
A workload disappears after a sync; the app history shows "Pruning" events for resources that vanished from the rendered manifests, often after a path or revision change.
Syncing (Retrieving ...)
Pruning Deployment/prod/api
Pruning Service/prod/api
Sync operation to a1b2c3d succeededCommon causes
The resource left the rendered manifest set
A wrong path, a broken kustomization, or a deleted file means the resource is no longer generated, so prune removes it as intended.
A targetRevision that points at the wrong tree
Pointing the app at a revision that lacks the resource makes Argo CD believe it should be pruned.
How to fix it
Confirm the render before allowing prune
- Run
argocd app diffto see exactly what will be pruned. - Verify the source path and targetRevision still include the resource.
- Only then sync; restore the resource by fixing the source if it was wrong.
argocd app diff my-app
argocd app sync my-app --dry-runGuard critical resources from prune
Annotate resources you never want pruned so an accidental removal from Git does not delete them.
metadata:
annotations:
argocd.argoproj.io/sync-options: Prune=falseHow to prevent it
- Run
argocd app diffin CI before an auto-prune sync. - Use
Prune=falseon resources that must never be auto-deleted. - Verify path and targetRevision so prune only drops truly removed resources.