Skip to content

Do not create a default Airflow user in the chart - #72209

Open
potiuk wants to merge 4 commits into
apache:mainfrom
potiuk:fix-chart-no-default-admin-user
Open

potiuk wants to merge 4 commits into
apache:mainfrom
potiuk:fix-chart-no-default-admin-user

Conversation

@potiuk

@potiuk potiuk commented Aug 28, 2026

Copy link
Copy Markdown
Member

The chart ran a create-user job on every install and provisioned a FAB account with a username and password that were the same on every installation:

createUserJob:
  enabled: true
  defaultUser:
    role: Admin
    username: admin
    password: admin

Anything able to reach the API server could sign in with the Admin role. That is not narrow by default: networkPolicies.enabled is false, so every workload in the cluster can reach the service, and the documented ingress path widens it further.

What changed

createUserJob is now disabled by default, and the chart ships no default username or password.

Enabling the job without setting both fails the render, naming the two values and the alternative, rather than falling back to an account whose credentials are public knowledge:

createUserJob.enabled is true but createUserJob.defaultUser.username and/or
createUserJob.defaultUser.password are not set. Set both to credentials of your own,
or leave createUserJob.enabled false and create the user yourself with
`airflow users create`.

Generating a random password instead was considered and rejected: it keeps a default account in existence and only makes its credential harder to guess. Not creating the account removes the class of problem, and matches how the chart already treats other opt-in components.

NOTES.txt no longer prints the password after install. It prints the username when the job ran, and the airflow users create invocation when it did not — advertising the credential was part of the same problem.

Behaviour

Invocation Result
default renders; no user created
--set createUserJob.enabled=true fails, with the message above
enabled=true + password only fails
enabled=true + username and password renders

helm lint clean; Celery, Kubernetes and Local executors all render.

Tests

Tests covering the job opt in the way a deployment would. The job's own test module renders through a wrapper that supplies admin/admin and lets each test's own values win over it, so the opt-in is stated once and is self-explanatory. The other four affected files carry the credentials inside their existing createUserJob values.

Worth noting for review: adding a second "createUserJob" key to those dicts is not equivalent — Python keeps the last one, which silently discards the test's own serviceAccount setup and leaves the test passing while no longer testing what it was written to test. The credentials are merged into the existing keys for that reason.

Docs

  • production-guide.rst gains a Creating the first user section covering both routes, and recommends supplying the password from a Kubernetes Secret rather than values.yaml, since values files are frequently committed.
  • A significant newsfragment records the behaviour change and the migration path.
  • values.schema.json default for enabled corrected to false.

🤖 Generated with Claude Code

Comment thread chart/docs/production-guide.rst Resolved
Comment thread chart/docs/production-guide.rst Resolved
from chart_utils.helm_template_generator import render_chart as _render_chart


def _deep_merge(base: dict, override: dict) -> dict:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer modifying the tests instead of adding logic to handle the change. Going in that direction, maintenance of the tests will get harder and harder.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll meet you most of the way, though for a reason slightly different from the one you gave.

The concrete problem with the wrapper wasn't maintenance, it was that it made a test name false: test_should_run_by_default asserted the job renders, while the whole point of the change is that it does not render by default. It passed only because the helper silently switched the job on. A reader who trusts the name comes away with the wrong idea about the chart.

What I wanted to avoid is pasting the same four lines of opt-in into thirty tests, which has its own maintenance cost — and a fixture would need touching every signature while staying just as implicit. So instead of hiding the opt-in, I stopped shadowing it: the imported render_chart keeps its own name, the helper is now render_chart_with_user_job, and every call site says which one it means. The two tests that are about the job being off call the plain one. test_should_run_by_default is now test_should_run_when_enabled_with_credentials, and a new test_should_not_create_job_by_default renders the chart untouched.

Pushed as bd51cf35a4. Reasonable?


Drafted-by: Claude Code (Opus 5); reviewed by @potiuk before posting

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no commit like that.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, my mistake — the SHA in my reply was from before a rebase. The change is 56ea433358 ("Make the create-user-job test opt-in explicit and trim the docs") on the current branch: render_chart_with_user_job is the explicit opt-in helper, the plain render_chart is used where the test is about the job being off, and test_should_not_create_job_by_default renders the chart untouched.


Drafted-by: Claude Code (Opus 5); reviewed by @potiuk before posting

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I wanted to avoid is pasting the same four lines of opt-in into thirty tests, which has its own maintenance cost

I understand and support that. What I don't agree with is how it was done. We don't need the whole _deep_merge function here, which is pretty nice, but is far too complicated IMHO for what we need here. Despite 2/3 tests, we can create a static variable with config and add it directly in values={**static_value, ...}, and for the remaining tests, do something similar, just slightly differently.

Comment thread chart/values.yaml Resolved
Comment thread chart/values.yaml Resolved
Comment thread chart/templates/NOTES.txt Resolved
@potiuk
potiuk force-pushed the fix-chart-no-default-admin-user branch from bd51cf3 to d17f52c Compare September 18, 2026 10:26
@potiuk
potiuk requested a review from Miretpl September 18, 2026 13:41
@potiuk

potiuk commented Sep 18, 2026

Copy link
Copy Markdown
Member Author

Rebased onto current main; full CI is green (142 checks, nothing failing).

All six review points are addressed, four of them exactly as suggested — the production-guide wording and the security note were taken verbatim, and both values.yaml comments were cut back.

Two I partly pushed back on, and those replies are still open for you to agree or not:

  • NOTES.txt — shortened to one line and a pointer rather than removed, because it only renders when createUserJob.enabled is false, which after this change is every default install; deleting it leaves a fresh install with no UI login and no hint why.
  • values.yaml — dropped the "disabled by default" restatement, kept one line recording that the old defaults produced identical credentials on every install, since that is the reason the default is flipping.

The test wrapper is gone rather than argued for: render_chart keeps its own name, the helper is now render_chart_with_user_job, and test_should_run_by_default — which asserted the opposite of the new behaviour — is replaced by test_should_run_when_enabled_with_credentials plus a new test_should_not_create_job_by_default.


Drafted-by: Claude Code (Opus 5); reviewed by @potiuk before posting

@Miretpl Miretpl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small thing + 2 comments from iteration before with ongoing discussion.

Comment thread chart/values.yaml Resolved
@Miretpl Miretpl added this to the Airflow Helm Chart 2.0.0 milestone Sep 24, 2026
potiuk added 4 commits October 5, 2026 00:38
The create-user job ran on every install and provisioned a FAB 'admin' account
with the password 'admin'. Those credentials were the same on every
installation, so anything able to reach the API server could sign in with the
Admin role - by default any workload in the cluster, since networkPolicies are
off.

createUserJob is now disabled by default, and the chart ships no default
username or password. Enabling the job without setting both fails the render
with a message naming the two values, rather than falling back to an account
whose credentials are public knowledge. NOTES.txt no longer prints the password
after install; it prints the username when the job ran, and the 'airflow users
create' invocation when it did not.

Tests that cover the job opt in the way a deployment would. The job's own test
module renders through a wrapper that supplies admin/admin and lets each test's
values win over it; the other four files carry the credentials in their existing
createUserJob values.

Adds a production-guide section on creating the first user, and a significant
newsfragment for the behaviour change.
The chart no longer creates a user, but the Kubernetes system tests still
authenticate as admin/admin and skaffold dev-mode still expects a UI login,
so both deployments now ask for that account explicitly instead of relying
on a chart default that is gone. The schema's username and password
defaults were left behind at the old values and disagreed with values.yaml.
The test helper shadowed the imported render_chart, so a test could be
named for the chart's default while asserting the opposite of it -
test_should_run_by_default passed only because the helper silently
switched the job on. Naming the helper for what it does puts the opt-in
back in front of the reader at every call site, and the default is now
covered by a test that renders the chart untouched.

In the production guide, showing how to create a FAB user reads as
endorsing FAB as the production path, which it is not; the surrounding
prose also narrated the old behaviour at more length than an operator
needs to understand why the default changed.

Generated-by: Claude Opus 5
The history of the old admin/admin default belongs in the release notes, not in the chart values.

Generated-by: Claude Opus 5
@potiuk
potiuk force-pushed the fix-chart-no-default-admin-user branch from d17f52c to 79d74ff Compare October 4, 2026 22:39
@potiuk
potiuk requested a review from Miretpl October 4, 2026 22:40
@potiuk

potiuk commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

@Miretpl @jedcunningham — all review suggestions are addressed (last push 2026-10-04). Could you take another look and re-review when you have a moment?

from chart_utils.helm_template_generator import render_chart as _render_chart


def _deep_merge(base: dict, override: dict) -> dict:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I wanted to avoid is pasting the same four lines of opt-in into thirty tests, which has its own maintenance cost

I understand and support that. What I don't agree with is how it was done. We don't need the whole _deep_merge function here, which is pretty nice, but is far too complicated IMHO for what we need here. Despite 2/3 tests, we can create a static variable with config and add it directly in values={**static_value, ...}, and for the remaining tests, do something similar, just slightly differently.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants