Skip to content
Latchkey

Argo CD "PreSync hook failed" in CI

A PreSync hook runs before the main sync, typically a migration or setup Job. If the hook resource fails, Argo CD stops the sync and marks the operation SyncFailed, because the main resources should not apply after a failed prerequisite.

What this error means

The sync operation ends with "SyncFailed" and a hook message such as "PreSync hook Job/db-migrate failed" or a nonzero Job completion, before the main resources are applied.

argocd
FATA[0042] Operation has completed with phase: Failed
Message: one or more synchronization tasks completed unsuccessfully,
reason: PreSync hook Job argocd/db-migrate failed

Common causes

The hook Job exited non-zero

The migration or setup command inside the PreSync Job failed, so its pod completed with an error and the hook is marked failed.

The hook could not schedule or pull its image

A missing image, RBAC gap, or resource limit keeps the hook pod from running to completion, which reads as a hook failure.

How to fix it

Read the hook Job logs

  1. Find the hook Job named in the SyncFailed message.
  2. Read its pod logs to see why the command failed.
  3. Fix the command or its inputs, then re-sync.
Terminal
kubectl -n argocd logs job/db-migrate
kubectl -n argocd describe job db-migrate

Control hook lifecycle and deletion policy

Set a hook delete policy so failed hook resources are cleaned up and re-created on the next attempt.

hook-job.yaml
metadata:
  annotations:
    argocd.argoproj.io/hook: PreSync
    argocd.argoproj.io/hook-delete-policy: HookFailed

How to prevent it

  • Make hook Jobs idempotent so a retry does not compound a partial run.
  • Set a hook-delete-policy so failed hooks do not block the next sync.
  • Test migration hooks against a staging cluster before prod.

Frequently asked questions

What causes ""PreSync hook failed""?
The migration or setup command inside the PreSync Job failed, so its pod completed with an error and the hook is marked failed.
How do I fix "PreSync hook failed"?
Read the hook Job logs

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card