Skip to content

Helm chart tries to patch immutable Job resources on helm upgrade #27561

@calebwoofenden

Description

@calebwoofenden

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions