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

Docker modules: improve documentation on docker vs. docker-py Python package requirements #42457

Merged
merged 2 commits into from
Jul 11, 2018

Conversation

felixfontein
Copy link
Contributor

SUMMARY

The original (semi-)official Python module for working with docker was called docker-py, which exists up to version 1.10.6. It has been renamed/superseeded to/by the docker module, which starts with version 2.0.0.

This (and the fact that this is not mentioned on either of the pypi pages; though such a note was apparently added, but later got lost again) leads to a lot of confusion, which can be seen for example in #42162 and #42258. A lot of people seem to believe since the requirements and error messages only mention python-py, that the modules do not work with the Python docker module (which is wrong, except if this is caused by a bug -- but that should not be fixed by adjusting the requirements). On the other hand, python-py is still required for Python 2.6, since Python 2.6 support was dropped before the first release of docker.

This PR tries to clean up the documentation by adding a disclaimer in the requirements section of every module mentioning both docker and docker-py (recommending docker if Python 2.6 is not required), and updates the error messages in the common code in module_utils/docker_common.py to also mention docker and not just docker-py.

Superseeds #42370 and #42394. Fixes #42258.
CC @samdoran, @kassiansun.

I would appreciate it if some of the docker module maintainers could take a look at this in more detail. Thanks.

ISSUE TYPE
  • Docs Pull Request
COMPONENT NAME

lib/ansible/module_utils/docker_common.py
docker_container
docker_image
docker_image_facts
docker_login
docker_network
docker_secret
docker_service
docker_swarm
docker_volume

ANSIBLE VERSION
2.6.1

@ansibot
Copy link
Contributor

ansibot commented Jul 7, 2018

@ansibot ansibot added affects_2.7 This issue/PR affects Ansible v2.7 cloud core_review In order to be merged, this PR must follow the core review workflow. docker docs This issue/PR relates to or includes documentation. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Jul 7, 2018
@felixfontein
Copy link
Contributor Author

(Once #40839 is merged, there's one error message in there which should also be updated to mention docker as well. CC @resmo)

@@ -36,6 +36,12 @@
requirements:
- "python >= 2.6"
- "docker-py >= 1.7.0"
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
module has been superseeded by L(docker,https://pypi.org/project/docker/)
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: superseeded -> superseded

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for noticing! I just fixed all of them.

@@ -77,6 +77,12 @@
requirements:
- "python >= 2.6"
- "docker-py >= 1.7.0"
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
module has been superseeded by L(docker,https://pypi.org/project/docker/)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

@@ -96,6 +96,12 @@
requirements:
- "python >= 2.6"
- "docker-py >= 1.7.0"
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
module has been superseeded by L(docker,https://pypi.org/project/docker/)
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

@@ -60,6 +60,10 @@

requirements:
- "docker-py >= 2.1.0"
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
module has been superseeded by L(docker,https://pypi.org/project/docker/)
Copy link
Contributor

Choose a reason for hiding this comment

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

Likewise.

@@ -143,6 +143,13 @@

requirements:
- "python >= 2.6"
- "docker-py >= 1.8.0"
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
module has been superseeded by L(docker,https://pypi.org/project/docker/)
Copy link
Contributor

Choose a reason for hiding this comment

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

Here as well.

@@ -136,6 +136,13 @@
- docker
requirements:
- python >= 2.7
- docker-py >= 1.7.0
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
module has been superseeded by L(docker,https://pypi.org/project/docker/)
Copy link
Contributor

Choose a reason for hiding this comment

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

Also here.

@@ -68,6 +68,12 @@
requirements:
- "python >= 2.6"
- "docker-py >= 1.10.0"
- "Please note that the L(docker-py,https://pypi.org/project/docker-py/) Python
module has been superseeded by L(docker,https://pypi.org/project/docker/)
Copy link
Contributor

Choose a reason for hiding this comment

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

And finally here too.

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. needs_triage Needs a first human triage before being processed. labels Jul 7, 2018
@@ -136,6 +136,13 @@
- docker
requirements:
- python >= 2.7
- docker-py >= 1.7.0
Copy link
Contributor

Choose a reason for hiding this comment

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

I think docker_swarm is for docker's built-in swarm mode, docker-py should have a higher version number?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, good question; the code also uses the log_driver parameter of create_swarm_spec, which has (according to the change log) only introduced in 2.6.0; I'll bump it up to that for now. @tbouvet: do you know more details?

@@ -68,6 +68,12 @@
requirements:
- "python >= 2.6"
- "docker-py >= 1.10.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Per change log, this should be 1.5.0, but align this with MIN_DOCKER_VERSION = 1.7.0, it should not be listed explictly here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually this is document, keep this and align to 1.7.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It uses the labels parameter for the create_volume call, so according to https://docker-py.readthedocs.io/en/stable/change-log.html it requires 1.10.0.

@@ -143,6 +143,13 @@

requirements:
- "python >= 2.6"
- "docker-py >= 1.8.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Does docker_service needs an explicitly dependency on docker-py version, or just implicitly inherits docker-compose's requirement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It should implicitly inherit docker-compose's requirements. My idea was to list it nonetheless (so it's listed for all docker_* modules), but I can remove it if you prefer.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, leaving a deprecation comment about docker-py and docker everywhere is boring, but useful for newbies.

@@ -96,7 +96,7 @@
description:
- Path to a file containing environment variables I(FOO=BAR).
- If variable also present in C(env), then C(env) value will override.
- Requires docker >= 2.3.0.
- Requires docker-py >= 1.4.0.
Copy link
Contributor

Choose a reason for hiding this comment

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

Align with MIN_DOCKER_VERSION

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I removed it, since the general requirements for the module already specify docker-py >= 1.7.0.

@kassiansun
Copy link
Contributor

There're too many commits, could you please rebase them? It will make the commit history cleaner after getting merged.

@felixfontein felixfontein force-pushed the docker-improve-requirement-docs branch from 744ed7d to ceb2d6f Compare July 7, 2018 15:45
@felixfontein
Copy link
Contributor Author

I've squashed them. This would have happen during merge anyway, but this way the commit message is nicer ;-)

@Akasurde
Copy link
Member

Akasurde commented Jul 7, 2018

@felixfontein Does this resolves - #38833 ?

@felixfontein
Copy link
Contributor Author

@Akasurde I don't think so. This PR is (so far) only about the dependency on the docker / docker-py Python modules, and not on the Docker daemon/server/API version required.

@kassiansun
Copy link
Contributor

shipit

@jctanner jctanner added this to the 2.7.0 milestone Jul 8, 2018
@felixfontein felixfontein force-pushed the docker-improve-requirement-docs branch from ceb2d6f to d316a76 Compare July 9, 2018 05:51
@felixfontein
Copy link
Contributor Author

Now that #40839 has been merged, I rebased against devel and adjusted the new messages there according to the rest of this PR.

@samdoran samdoran merged commit 765a513 into ansible:devel Jul 11, 2018
@felixfontein felixfontein deleted the docker-improve-requirement-docs branch July 12, 2018 05:48
@felixfontein
Copy link
Contributor Author

Everyone, thanks for your reviews, and thanks for handling this! :)

@felixfontein
Copy link
Contributor Author

I will create a backport PR for stable-2.6 as soon as #42533 is merged.

felixfontein added a commit to felixfontein/ansible that referenced this pull request Jul 17, 2018
…package requirements (ansible#42457)

* Make sure all docker-py/docker requirements are listed, and clarify about docker vs. docker-py.

* Adjusting changes made in ansible#40839.
mattclay pushed a commit that referenced this pull request Jul 18, 2018
…package requirements (#42457)

* Make sure all docker-py/docker requirements are listed, and clarify about docker vs. docker-py.

* Adjusting changes made in #40839.
@ansible ansible locked and limited conversation to collaborators Jul 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.7 This issue/PR affects Ansible v2.7 cloud docker docs This issue/PR relates to or includes documentation. module This issue/PR relates to a module. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. support:community This issue/PR relates to code supported by the Ansible community. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docker_volume says it depends on docker-py, which breaks docker_container
8 participants