Skip to content

Conversation

@potiuk
Copy link
Member

@potiuk potiuk commented Jan 7, 2022

PIP produces a warning when root user is used to run pip install.
This is done for a good reason - because installing PIP this way
clashes with a number of distro-managed python packages.

The warning cannot be disabled even if our use case is legitimate
as has been extensively discussed in
pypa/pip#10556.

The advice given by the warning is a bit misleading - it suggests
to use virtualenv, but since this is considered a bad practice
for container building and because we need to create virtualenvs
dynamically inside the image, using virtualenv is a bad solution
for us. It's been attempted in #19189 and failed.

Instead we create an airflow user and use PIP_USER="true" which
installs all dependencies in build segment to ~/.local folder
from where we can copy it to the main image.

That get rids of the warning and at the same time allows us to
keep the best practices of building the images.


^ 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 potiuk requested review from ashb and mik-laj as code owners January 7, 2022 11:39
@boring-cyborg boring-cyborg bot added the area:production-image Production image improvements and fixes label Jan 7, 2022
@potiuk potiuk requested a review from uranusjr January 7, 2022 11:39
@potiuk
Copy link
Member Author

potiuk commented Jan 7, 2022

This is another smaller change separated out from the #20238

@potiuk
Copy link
Member Author

potiuk commented Jan 7, 2022

cc: @ashb @uranusjr -> even easier to review that way. I will continue adding other changes separated from #20238

@potiuk potiuk force-pushed the build-image-uses-airflow-useer branch from d999df3 to 5a3a105 Compare January 7, 2022 11:52
@potiuk potiuk requested a review from kaxil January 7, 2022 12:29
@potiuk
Copy link
Member Author

potiuk commented Jan 7, 2022

Looks green :)

@potiuk potiuk changed the title Uses airflow user for build segment of docker image Use airflow user for build segment of docker image Jan 7, 2022
PIP produces a warning when root user is used to run pip install.
This is done for a good reason - because installing PIP this way
clashes with a number of distro-managed python packages.

The warning cannot be disabled even if our use case is legitimate
as has been extensively discussed in
pypa/pip#10556.

However, the advice given by the warning is a bit misleading - it
suggests to use virtualenv, but since this is considered a bad practice
for container building and because we need to create virtualenvs
dynamically inside the image, using virtualenv is a bad solution for us.
It's been attempted in apache#19189 and failed.

Instead we create an airflow user and use PIP_USER="true" which
installs all dependencies in build segment to ~/.local folder
from where we can copy it to the main image.

That get rids of the warning and at the same time allows us to
keep the best practices of building the images.
@potiuk potiuk force-pushed the build-image-uses-airflow-useer branch from 5a3a105 to 67279c6 Compare January 8, 2022 16:34
@potiuk
Copy link
Member Author

potiuk commented Jan 8, 2022

REbased to latest main. Would love re-review.

@github-actions
Copy link

github-actions bot commented Jan 8, 2022

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 main at your convenience, or amend the last commit of the PR, and push it with --force-with-lease.

@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 8, 2022
@potiuk potiuk merged commit 3feb057 into apache:main Jan 8, 2022
@potiuk potiuk deleted the build-image-uses-airflow-useer branch January 8, 2022 19:41
@potiuk potiuk added this to the Airflow 2.2.4 milestone Jan 20, 2022
@potiuk potiuk added the changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) label Jan 22, 2022
potiuk added a commit that referenced this pull request Jan 22, 2022
PIP produces a warning when root user is used to run pip install.
This is done for a good reason - because installing PIP this way
clashes with a number of distro-managed python packages.

The warning cannot be disabled even if our use case is legitimate
as has been extensively discussed in
pypa/pip#10556.

However, the advice given by the warning is a bit misleading - it
suggests to use virtualenv, but since this is considered a bad practice
for container building and because we need to create virtualenvs
dynamically inside the image, using virtualenv is a bad solution for us.
It's been attempted in #19189 and failed.

Instead we create an airflow user and use PIP_USER="true" which
installs all dependencies in build segment to ~/.local folder
from where we can copy it to the main image.

That get rids of the warning and at the same time allows us to
keep the best practices of building the images.

(cherry picked from commit 3feb057)
jedcunningham pushed a commit that referenced this pull request Jan 27, 2022
PIP produces a warning when root user is used to run pip install.
This is done for a good reason - because installing PIP this way
clashes with a number of distro-managed python packages.

The warning cannot be disabled even if our use case is legitimate
as has been extensively discussed in
pypa/pip#10556.

However, the advice given by the warning is a bit misleading - it
suggests to use virtualenv, but since this is considered a bad practice
for container building and because we need to create virtualenvs
dynamically inside the image, using virtualenv is a bad solution for us.
It's been attempted in #19189 and failed.

Instead we create an airflow user and use PIP_USER="true" which
installs all dependencies in build segment to ~/.local folder
from where we can copy it to the main image.

That get rids of the warning and at the same time allows us to
keep the best practices of building the images.

(cherry picked from commit 3feb057)
@potiuk potiuk restored the build-image-uses-airflow-useer branch April 26, 2022 20:50
@potiuk potiuk deleted the build-image-uses-airflow-useer branch July 29, 2022 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:production-image Production image improvements and fixes changelog:skip Changes that should be skipped from the changelog (CI, tests, etc..) full tests needed We need to run full set of tests for this PR to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants