jykae opened a new pull request, #68074:
URL: https://github.com/apache/airflow/pull/68074

   Extends the existing `migrate-database-job` so a single `helm upgrade` 
reconciles the Airflow metadata DB in both directions — forward migrate, no-op, 
or `airflow db downgrade` executed inside the still-running api-server pod 
(whose source-version image still ships the reverse alembic scripts).
   
   **What the chart does now**
   
   1. The job runs `pre-install,pre-upgrade` (was `post-install,post-upgrade`), 
so the DB is reconciled *before* the new image rolls out.
   2. The default `args` embed a bash entrypoint (`chart/files/db_migrate.sh`) 
that:
      - Reads the alembic revision currently in the DB.
      - Reads `AIRFLOW_TARGET_VERSION` (the chart's `.airflowVersion`).
      - Decides one of: `noop`, `forward` (`exec airflow db migrate`), or 
`downgrade` (exec into the running api-server pod and run `airflow db downgrade 
--to-version X.Y.Z --yes` there).
   3. New namespace-scoped RBAC (`Role` + `RoleBinding`) grants the job's 
existing ServiceAccount `pods get/list` and `pods/exec create/get`, only when 
both `rbac.create` and `migrateDatabaseJob.enabled` are true.
   4. User-supplied `migrateDatabaseJob.command` / `migrateDatabaseJob.args` 
still win — only the default is changed.
   
   **Why exec into the api-server pod**
   
   Reverse alembic scripts only exist in the source-version image. The new 
migrations image cannot run a downgrade against the schema of an older Airflow. 
Exec-ing into the still-running source-version api-server pod sidesteps the 
need to ship a second image or to coordinate a rolling pod swap.
   
   **Tests**
   
   50 helm tests in 
`chart/tests/helm_tests/airflow_aux/test_migrate_database_job.py` and 
`chart/tests/helm_tests/airflow_aux/test_migrate_database_job_rbac.py` all pass.
   
   closes: #68072
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Opus 4.7
   
   Generated-by: Claude Opus 4.7 following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to