Skip to content

Fix FAB ignoring create_metadata_engine from local settings - #71674

Open
rjgoyln wants to merge 2 commits into
apache:mainfrom
rjgoyln:fix/fab-metadata-engine-hook
Open

Fix FAB ignoring create_metadata_engine from local settings#71674
rjgoyln wants to merge 2 commits into
apache:mainfrom
rjgoyln:fix/fab-metadata-engine-hook

Conversation

@rjgoyln

@rjgoyln rjgoyln commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Summary

airflow users create — the Helm chart's create-user job — fails on deployments that authenticate to the metadata database with short-lived credentials, while the migrate job and the API server of the same release succeed:

psycopg2.OperationalError: connection to server at "...rds.amazonaws.com" failed: fe_sendauth: no password supplied

Those deployments leave the password out of sql_alchemy_conn and override create_metadata_engine in airflow_local_settings.py to mint an RDS IAM token per physical connection. Only configure_orm() calls that hook, so the engine Flask-SQLAlchemy builds from the bare URI arrives with no credentials at all. The DB manager and the auth manager's Flask app carry the same gap; the API server escapes it only where deployments fall back to registering a global Engine listener.

Taking the default bind from the engine Airflow already built brings its connect args, pool settings and event handlers along with the hook. Only a bind that resolves to the metadata database is taken over, so secondary SQLALCHEMY_BINDS and a webserver_config.py aimed at a database of its own keep their own engines. The override goes through _make_engine, which Flask-SQLAlchemy documents as internal and free to change signature, and the provider pins only flask-sqlalchemy>=3.0.5.

Behavior change

FAB shares Airflow's metadata engine and pool rather than building one of its own, so the FAB REST API routes no longer create and dispose an engine per request. SQLALCHEMY_ENGINE_OPTIONS from webserver_config.py no longer applies to that bind.

closes: #71664


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5)

Generated-by: Claude Code (Opus 5) following the guidelines

Deployments that authenticate to the metadata database with short-lived
credentials override create_metadata_engine in airflow_local_settings.py so a
do_connect handler can mint a token per physical connection. Flask-SQLAlchemy
built a second engine straight from the connection URI, so those handlers never
ran and `airflow users create` — the Helm chart's create-user job — connected
without a password while the migrate job and the API server succeeded.

closes: apache#71664
@rjgoyln
rjgoyln force-pushed the fix/fab-metadata-engine-hook branch from 6788fd5 to ef5346e Compare August 16, 2026 15:36
@rjgoyln
rjgoyln marked this pull request as ready for review August 16, 2026 15:49
@rjgoyln
rjgoyln requested a review from vincbeck as a code owner August 16, 2026 15:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

createUserJob is not using create_metadata_engine from airflowLocalSettings

1 participant