feat(flagsmith): Allow custom annotations on migrate jobs - #542
Merged
germangarces merged 2 commits intoJun 4, 2026
Conversation
The migrate-db and migrate-analytics-data Jobs currently expose
`jobAnnotations`, but those are wired into the pod template
(`spec.template.metadata.annotations`), not the Job's own
`metadata.annotations`.
The only existing source of Job-level annotations is
`common.annotations`, which is applied to every resource the chart
renders. That makes it unusable for per-resource concerns like Helm
hooks (`helm.sh/hook`, `helm.sh/hook-weight`,
`helm.sh/hook-delete-policy`), ArgoCD sync waves, or Kyverno policy
exceptions, all of which must live on the resource's own metadata.
Add a new `jobs.migrateDb.annotations` (and matching
`jobs.migrateAnalyticsData.annotations`) value that is merged into
the Job's `metadata.annotations` on top of `common.annotations`,
with Job-specific keys taking precedence. Defaults to {}, so existing
renders are unchanged.
|
good stuff. need this |
germangarces
requested changes
Jun 4, 2026
germangarces
left a comment
Member
There was a problem hiding this comment.
Thanks for the contribution. Is solid overall. Two small nits to avoid possible headaches in the future.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Thanks for submitting a PR! Please check the boxes below:
Changes
Add a new
annotationsvalue tojobs.migrateDbandjobs.migrateAnalyticsDatathat is rendered onto the Job resource's ownmetadata.annotations.Why
jobs.migrateDb.jobAnnotationslooks like it should do this, but it is wired into the pod template (spec.template.metadata.annotations), so it never reaches the Job's metadata. Today, the only way to set Job-level annotations iscommon.annotations, which is applied to every resource the chart renders (Deployments, Services, Secrets, Ingresses, …).That makes it impossible — without
extraObjectsor post-render kustomize — to apply per-resource concerns to just the migrate Job, including:helm.sh/hook: pre-upgrade,helm.sh/hook-weight,helm.sh/hook-delete-policy). Helm only recognises these on a resource's top-levelmetadata.annotations(see https://helm.sh/docs/topics/charts_hooks/#writing-a-hook). Promoting the migrate-db Job into apre-upgradehook is the standard way to gate a rollout on DB migrations and abort the upgrade cleanly on failure — particularly valuable when running >1 API replica so the new pods don't start serving against an unmigrated schema.argocd.argoproj.io/sync-wave).Design
jobs.migrateDb.annotations(default{}), merged withcommon.annotationsinto the Job'smetadata.annotations. Job-specific keys win on conflict, matching "more specific wins" convention.jobs.migrateAnalyticsData.annotationsfor symmetry.jobs.migrateDb.jobAnnotations(pod-template annotations) is left untouched to preserve backward compatibility — despite its misleading name.{}means rendered output is identical to today for existing users.Files changed
charts/flagsmith/templates/jobs-migrate-db.yamlcharts/flagsmith/templates/jobs-migrate-analytics-data.yamlcharts/flagsmith/values.yaml(new value + docstring with apre-upgradehook example)How did you test this code?
helm templateagainst three values configurations:Default (
annotationsunset) — output is byte-identical tomain; nometadata.annotationsblock emitted. Backward compatibility verified.Hook annotations set:
Renders:
and:
Conflict with
common.annotations— given:the migrate-db Job correctly merges both sources and the Job-specific
company.io/owner: migrations-teamwins over the common value, while the analytics Job (no override) still inheritsplatform.Verified with
helm lint charts/flagsmith(passes, same warnings asmain).