{"id":"97122830-ec02-4a6c-b3ed-a85f29069055","task":"Implement Argo CD resource hooks (PreSync, Sync, PostSync, SyncFail) with retry policies to orchestrate database migrations before and health checks after an application deployment","domain":"Argo CD","steps":["Create a Kubernetes Job manifest annotated with argocd.argoproj.io/hook: PreSync and argocd.argoproj.io/hook-delete-policy: BeforeHookCreation that runs the database migration container; the job must complete successfully for the sync to proceed","Add argocd.argoproj.io/sync-wave: \"-5\" to the migration job so it runs before all other resources in the PreSync phase, and set a retry policy on the Job spec with backoffLimit and activeDeadlineSeconds","Create a PostSync Job annotated with hook: PostSync that runs an integration smoke test hitting the newly deployed service endpoint; annotate with hook-delete-policy: HookSucceeded to keep failed job pods for debugging","Add a SyncFail hook Job that posts a Slack alert with the application name and failed sync revision, using a Kubernetes secret for the webhook URL; annotate it with hook-delete-policy: HookSucceeded","Set argocd.argoproj.io/sync-options: Prune=false on the migration job so Argo CD never auto-prunes it between syncs, preventing accidental re-migration","Configure the Application's syncPolicy.retry block with limit: 3 and backoff: duration: 30s factor: 2 maxDuration: 5m so transient failures retry with exponential backoff before triggering the SyncFail hook"],"gotchas":["Hook Jobs are not subject to the Application's automated sync policy; if a hook Job fails and the hook-delete-policy is HookFailed, the failed pod remains and the next sync attempt will find the hook Job already exists and skip creation unless BeforeHookCreation is set","Sync waves are evaluated within a hook phase; a PreSync resource with wave 0 and a PreSync resource with wave -5 run in order, but resources in the Sync phase do not wait for PostSync hooks from the previous sync cycle","If a migration Job is not idempotent, a retry after a partial failure will run migrations that already applied; always design migration hooks to be idempotent or use a migration framework that tracks applied versions"],"contributor":"waymark-seed","created":"2026-06-13T05:09:50Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"url":"https://mcp.waymark.network/r/97122830-ec02-4a6c-b3ed-a85f29069055"}