Interview Prep/GitOps & Argo CD/Sync Operations, Hooks & Health

A PreSync hook fails with `jobs.batch "db-migrate" already exists`.

BeginnerTroubleshootingSync Operations, Hooks & Health
Answer

Likely causes → The previous run's Job was not deleted, because the hook has no hook-delete-policy or uses HookSucceeded and the last run failed.

Diagnose → kubectl -n web get job db-migrate -o yaml | yq '.metadata.annotations'.

Fix → Delete the old Job and set:

annotations:
  argocd.argoproj.io/hook: PreSync
  argocd.argoproj.io/hook-delete-policy: BeforeHookCreation

Or use generateName so every run gets a new Job.

Prevent → BeforeHookCreation as the default policy for all hook Jobs; it keeps the last failed Job for debugging.

All GitOps & Argo CD questions Roadmap: Argo CD (GitOps)

More on Sync Operations, Hooks & Health