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

Replace DockerOperator's 'volumes' arg for 'mounts' #15843

Merged
merged 4 commits into from
May 17, 2021

Conversation

uranusjr
Copy link
Member

Fix #9047, close #15815. I *think this can also resolve #12537 (less sure about that).

All existing volumes usages are also migrated to use mounts instead.

This also includes a fix to DockerSwamOperator’s inability to mount things into the container; the new argument is also passed to Swam, so users can mount by setting mounts on DockerSwamOprerator as well.

Should I add entries to the Docker provider’s changelog now, or is it done when the provider is released?


^ 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.

@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$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.

@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$,^Provider packages,^Checks: Helm tests$,^Test OpenAPI*.

Copy link
Contributor

@akki akki left a comment

Choose a reason for hiding this comment

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

Thanks for the patch & great work.
I have left some comments regarding some concerns that I see.

One more thing that I am concerned about is that will users now explicitly need to do pip install docker to use this feature (as they will now need to import docker.types.Mount into their DAGs) or is that taken care of by your changes to docs/conf.py?

airflow/providers/docker/operators/docker.py Outdated Show resolved Hide resolved
airflow/providers/docker/operators/docker.py Show resolved Hide resolved
@@ -77,6 +77,7 @@ def _client_service_logs_effect():
image='ubuntu:latest',
command='env',
user='unittest',
mounts=[],
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUC this test would pass even if there were no changes made to DockerSwarmOperator in this PR (since we're checking the default value of DockerOperator right now).
I think it is worth passing some value to the operator & checking it gets passed here as expected.

Copy link
Member Author

Choose a reason for hiding this comment

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

I’ve modified the test case to ensure the variable is passed.

@akki
Copy link
Contributor

akki commented May 16, 2021

Ohh yeah and BTW, since it's not too late, you might also be able to fix a typo in "Swarm" in your commit message 😉

@potiuk
Copy link
Member

potiuk commented May 16, 2021

Good points @akki. @uranusjr , I added fixup with the type changes. Would you also mind to add provider.yaml + Changelog description?

@potiuk
Copy link
Member

potiuk commented May 16, 2021

Much nicer rendering:

Screenshot from 2021-05-16 13-47-47

uranusjr added 2 commits May 17, 2021 20:22
All existing 'volumes' usages are also migrated to use 'mounts' instead.

This also includes a fix to DockerSwarmOperator's inability to mount
things into the container; the new argument is also passed to Swam, so
users can mount by setting 'mounts' on DockerSwarmOprerator as well.
@uranusjr uranusjr force-pushed the docker-volumes-to-mount branch from a7258bd to f01c89f Compare May 17, 2021 12:32
@uranusjr uranusjr force-pushed the docker-volumes-to-mount branch from f01c89f to 785c141 Compare May 17, 2021 12:33
@github-actions github-actions bot added the okay to merge It's ok to merge this PR as it does not require more tests label May 17, 2021
@github-actions
Copy link

The PR is likely OK to be merged with just subset of tests for default Python and Database versions without running the full matrix of tests, because it does not modify the core of Airflow. If the committers decide that the full tests matrix is needed, they will add the label 'full tests needed'. Then you should rebase to the latest master or amend the last commit of the PR, and push it with --force-with-lease.

@potiuk potiuk merged commit 12995cf into apache:master May 17, 2021
@uranusjr uranusjr deleted the docker-volumes-to-mount branch May 17, 2021 15:31
potiuk added a commit to potiuk/airflow that referenced this pull request Jul 14, 2021
The DockerOperator by default mounts temporary folder to inside
the container in order to allow to store files bigger than
default size of disk for the container, however this did not work
when remote Docker engine or Docker-In-Docker solution was used.

This worked before the apache#15843 change, because the /tmp has
been ignored, however when we change to "Mounts", the "/tmp"
mount fails when using remote docker engine.

This PR adds parameter that allows to disable this temporary
directory mounting (and adds a note that it can be replaced
with mounting existing volumes). Also it prints a warning
if the directory cannot be mounted and attempts to re-run
such failed attempt without mounting the temporary
directory which brings back backwards-compatible behaviour
for remote engines and docker-in-docker.

Fixes: apache#16803
Fixes: apache#16806
potiuk added a commit that referenced this pull request Jul 15, 2021
…16932)

* Adds option to disable mounting temporary folder in DockerOperator

The DockerOperator by default mounts temporary folder to inside
the container in order to allow to store files bigger than
default size of disk for the container, however this did not work
when remote Docker engine or Docker-In-Docker solution was used.

This worked before the #15843 change, because the /tmp has
been ignored, however when we change to "Mounts", the "/tmp"
mount fails when using remote docker engine.

This PR adds parameter that allows to disable this temporary
directory mounting (and adds a note that it can be replaced
with mounting existing volumes). Also it prints a warning
if the directory cannot be mounted and attempts to re-run
such failed attempt without mounting the temporary
directory which brings back backwards-compatible behaviour
for remote engines and docker-in-docker.

Fixes: #16803
Fixes: #16806
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers kind:documentation okay to merge It's ok to merge this PR as it does not require more tests
Projects
None yet
4 participants