Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds automated user creation in production image #13728

Merged
merged 3 commits into from
Jan 19, 2021

Conversation

potiuk
Copy link
Member

@potiuk potiuk commented Jan 17, 2021

This PR implements automated user creation for production image
controlled by environment variables.

This is a solution for anyone who would like to make a quick test
with the production image and would like to:

  • init/upgrade the db automatically
  • create a user

This is particularly useful for internal sqlite db initialization
but can also be used to initialize the user in docker-compose
or similar cases where there is no equivalent of init containers
that are usually used to perform the initilization.

Closes #8606


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.

@potiuk
Copy link
Member Author

potiuk commented Jan 17, 2021

When adding this one, it was already too much of a logic where function were mixed with code in the entrypoint so I used the opportunity to follow Google's guidelines and extract the logic into functions and call the functions - instead of inlining the logic. Looks much neater and it is easy to understand what happens step-by-step. Corresponding to that I also updated the documentation to describe what happens in the prod image entrypoint so that users are not surprised by what happens by default and still can (if they really want) try out the image and start webserver or generally initialise the DB inside of airflow by just passing the right variables. Good for quick sanity checks.

@github-actions
Copy link

The Workflow run is cancelling this PR. It has some failed jobs matching ^Pylint$,^Static checks,^Build docs$,^Spell check docs$,^Backport packages$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.

@potiuk potiuk force-pushed the add-automated-user-creation branch from 1977824 to d5e63da Compare January 18, 2021 01:13
@potiuk
Copy link
Member Author

potiuk commented Jan 18, 2021

Temprary failures - it's good to go.

@potiuk potiuk force-pushed the add-automated-user-creation branch from d5e63da to ed8b783 Compare January 18, 2021 08:11
@potiuk potiuk force-pushed the add-automated-user-creation branch from ed8b783 to c3cf1ef Compare January 18, 2021 09:27
@potiuk potiuk force-pushed the add-automated-user-creation branch from d2c0f3f to 1bd4b5d Compare January 18, 2021 11:53
This PR implements automated user creation for production image
controlled by environment variables.

This is a solution for anyone who would like to make a quick test
with the production image and would like to:

* init/upgrade the db automatically
* create a user

This is particularly useful for internal sqlite db initialization
but can also be used to initialize the user in docker-compose
or similar cases where there is no equivalent of init containers
that are usually used to perform the initilization.

Closes apache#8606
@potiuk potiuk force-pushed the add-automated-user-creation branch from 1bd4b5d to 93712ba Compare January 19, 2021 02:59
@potiuk
Copy link
Member Author

potiuk commented Jan 19, 2021

All points addressed @kaxil !

Copy link
Member

@feluelle feluelle left a comment

Choose a reason for hiding this comment

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

LGTM 👍 (commented only a minor suggestion)

scripts/in_container/prod/entrypoint_prod.sh Outdated Show resolved Hide resolved
@github-actions github-actions bot added the full tests needed We need to run full set of tests for this PR to merge label Jan 19, 2021
@github-actions
Copy link

The PR most likely needs to run full matrix of tests because it modifies parts of the core of Airflow. However, committers might decide to merge it quickly and take the risk. If they don't merge it quickly - please rebase it to the latest master at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@potiuk potiuk merged commit bc026cf into apache:master Jan 19, 2021
@potiuk potiuk deleted the add-automated-user-creation branch January 19, 2021 14:45
kaxil pushed a commit that referenced this pull request Jan 21, 2021
* Adds automated user creation in the production image

This PR implements automated user creation for the production image
controlled by environment variables.

This is a solution for anyone who would like to make a quick test
of the production image and would like to:

* init/upgrade the DB automatically
* create a user

This is particularly useful for internal SQLite db initialization
but can also be used to initialize the user in docker-compose
or similar cases where there is no equivalent of init containers
that are usually used to perform the initialization.

Closes #860

(cherry picked from commit bc026cf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:dev-tools full tests needed We need to run full set of tests for this PR to merge kind:documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deal with initial username/passwords in the production docker image
4 participants