fix: make the stage db-migrate Job a PreSync hook #7

Merged
goern merged 1 commit from fix/stage-db-migrate-presync-hook into main 2026-07-28 20:24:58 +00:00
Owner

Unblocks the feeldata-stage sync, which has been failing since #6 merged.

Symptom

Job.batch "db-migrate" is invalid: spec.template: field is immutable

ArgoCD retries forever. Because the sync operation fails as a whole, Deployment/api, Deployment/graphql and Deployment/web never get applied — stage is still running Codeberg images while dev and prod have moved.

Cause

A Job's spec.template is immutable. Without argocd.argoproj.io/hook, ArgoCD treats the Job as an ordinary resource and PATCHes the pod template on every change, which the API server rejects. The argocd.argoproj.io/hook-delete-policy: BeforeHookCreation annotation already present is inert — it only takes effect on resources that are actually hooks.

dev and prod both carry argocd.argoproj.io/hook: PreSync. Stage does not:

overlay hook: PreSync hook-delete-policy sync-wave
dev
prod
stage

This is pre-existing drift, not something #6 introduced. It went unnoticed for as long as feeldata-stage was hand-applied and off GitOps — the image repoint is simply the first pod-template change ever to reach it through ArgoCD.

Also needed

The stuck db-migrate Job in feeldata-stage must be deleted once for the sync to get past it; after that BeforeHookCreation handles replacement on every future sync. The Job is Complete and idempotent (it checks alembic state and exits early if already at head), so deleting it is safe.

Unblocks the `feeldata-stage` sync, which has been failing since #6 merged. ## Symptom ``` Job.batch "db-migrate" is invalid: spec.template: field is immutable ``` ArgoCD retries forever. Because the sync operation fails as a whole, `Deployment/api`, `Deployment/graphql` and `Deployment/web` never get applied — stage is still running Codeberg images while dev and prod have moved. ## Cause A Job's `spec.template` is immutable. Without `argocd.argoproj.io/hook`, ArgoCD treats the Job as an ordinary resource and PATCHes the pod template on every change, which the API server rejects. The `argocd.argoproj.io/hook-delete-policy: BeforeHookCreation` annotation already present is **inert** — it only takes effect on resources that are actually hooks. `dev` and `prod` both carry `argocd.argoproj.io/hook: PreSync`. Stage does not: | overlay | `hook: PreSync` | `hook-delete-policy` | `sync-wave` | |---|---|---|---| | dev | ✅ | ✅ | ✅ | | prod | ✅ | ✅ | — | | stage | ❌ | ✅ | ✅ | This is pre-existing drift, not something #6 introduced. It went unnoticed for as long as `feeldata-stage` was hand-applied and off GitOps — the image repoint is simply the first pod-template change ever to reach it through ArgoCD. ## Also needed The stuck `db-migrate` Job in `feeldata-stage` must be deleted once for the sync to get past it; after that `BeforeHookCreation` handles replacement on every future sync. The Job is `Complete` and idempotent (it checks alembic state and exits early if already at head), so deleting it is safe.
A Job's spec.template is immutable. Without argocd.argoproj.io/hook, ArgoCD
treats this Job as an ordinary resource and PATCHes the pod template on every
change, which the API server rejects:

  Job.batch "db-migrate" is invalid: spec.template: field is immutable

That fails the ENTIRE stage sync, not just the Job, so api/graphql/web were
left OutOfSync behind it. The hook-delete-policy annotation already present
only takes effect on resources that are actually hooks, so it was inert.

dev and prod have carried the hook annotation all along. Stage did not, and it
went unnoticed for as long as stage was hand-applied and off GitOps — the
image repoint in #6 is simply the first pod-template change to reach it.
goern merged commit e12962e19d into main 2026-07-28 20:24:58 +00:00
goern deleted branch fix/stage-db-migrate-presync-hook 2026-07-28 20:24:58 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
feeldata/manifests!7
No description provided.