-
Notifications
You must be signed in to change notification settings - Fork 16.4k
Description
Apache Airflow version
2.4.2
What happened
Running helm upgrade with helm hooks disabled in a namespace that already has the chart installed will fail because it's trying to patch a Job resource, which is immutable:
cannot patch "<release_name>-run-airflow-migrations" with kind Job: Job.batch "<release_name>-run-airflow-migrations" is invalid: spec.template: Invalid value: core.PodTemplateSpec {<...entire json spec of Job resource...>}: field is immutable
This happens when helm hooks are disabled on the db migrations job:
migrateDatabaseJob:
useHelmHooks: false
For more detail on why a user would want to do this, see #11979
Copying this from my comment on that issue:
Kube does offer a parameter called .spec.ttlSecondsAfterFinished that, when specified, will delete the Job after the specified number of seconds after completion (see https://kubernetes.io/docs/concepts/workloads/controllers/ttlafterfinished/). This is a pretty good solution, though installs done in a period of time shorter than this value might still run into the same problem.
The solution I propose here is to set a helm pre-install hook on the database deployment as well as the db migrations, and set the hook weight on the database lower than that of the migrations, so the database will be created first, then the migrations will run, then the webserver and etc. pods will come up. Then I think we could safely remove the wait-for-db-migrations initContainer on the deployments.
Are you willing to submit PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct