Repository navigation
fix(airflow): the API issues service tokens while people keep Keycloak (#1047) - #1048
Merged
Merged
Conversation
The API server ran the Airflow 3 default SimpleAuthManager while every user the platform provisions (admin, nova-api) is a FAB user, so POST /auth/token answered 401 for all of them. Nova signs in as nova-api with the airflow-nova-api Secret, got 401 on every call and showed "the scheduler did not answer" and "Could not read runs" (platform#1047). Run the FAB manager on the api-server only, through a small subclass: the stock FabAuthManager refuses to exchange a password for a token while AUTH_TYPE is AUTH_OAUTH (the Keycloak login people use), and the service users have no other way in. The subclass asks the FAB user store directly. Keycloak users have no local password, so OIDC stays the only way for people. The module is a ConfigMap mounted by the api-server alone (it is the only component that serves the API), on PYTHONPATH; step-airflow applies it before the chart so a fresh install never starts without it.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.
4 tasks
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.
Fixes #1047.
What
The API server ran Airflow 3's default
SimpleAuthManager, while every user the platform provisions is a FAB user.POST /auth/tokentherefore answered401 {"detail":"Invalid credentials"}fornova-api(Secretairflow-nova-api), foradmin(Secretairflow-admin), and for everyone else. Nova renders that as “The scheduler did not answer” and “Could not read runs”; the scheduler itself was healthy.This puts the FAB manager back on the api-server and adds
manifests/airflow-auth-manager.yaml, a ConfigMap carrying one small subclass:FabAuthManager.create_tokenonly checks a password when FAB'sAUTH_TYPEisAUTH_DB/AUTH_LDAP. This platform runsAUTH_TYPE=AUTH_OAUTHso people sign in through Keycloak, so the stock class refuses every password exchange — including the service accounts that have no browser.StardeltFabAuthManager.create_tokenasks the FAB user store directly, with the same input validation. A Keycloak user has no local password, so people still sign in only through OIDC.step-airflowapplies the ConfigMap beforehelm upgrade, so a fresh install cannot start without it.Evidence (live cluster, before → after)
kubectl -n stardelt logs deploy/nova --since=4m | grep -c "sign-in was refused"→0.Checks
python3 -m unittest discover -s scripts/tests→ Ran 273 tests, OK (skipped=1); the newtest_airflow_auth_manager.pycovers the wiring: the manager name, the mount andPYTHONPATH, the module compiles from the ConfigMap, the Makefile applies it before Helm, and the-vNname in manifest and values agree.make lint→lint: OK(includescheck-airflow-users).helm template airflow apache-airflow/airflow --version 1.22.0 -f helm-values/airflow.yamlrendersAIRFLOW__CORE__AUTH_MANAGERand the mount on the api-server only.make step-airflow; release 38, api-server rolled cleanly.Note for a later values edit
The ConfigMap name is versioned (
airflow-auth-manager-v1). A content edit needs the suffix bumped — then the volume name changes and the pod rolls; an in-place ConfigMap edit would not.