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.py: allow docker versions beginning with 'v' #76

Merged
merged 2 commits into from
Jan 27, 2021

Conversation

voondo
Copy link
Contributor

@voondo voondo commented Jan 27, 2021

I don't know why, but here, the docker version output begins with a 'v':

$ docker version --format "{{.Server.Version}}"
v20.10.1

which trigger this error:

Traceback (most recent call last):
  File "/home/romain/pro/aubonticket/.venv/lib/python3.8/site-packages/ansible/executor/task_executor.py", line 158, in run
    res = self._execute()
  File "/home/romain/pro/aubonticket/.venv/lib/python3.8/site-packages/ansible/executor/task_executor.py", line 613, in _execute
    self._connection = self._get_connection(cvars, templar)
  File "/home/romain/pro/aubonticket/.venv/lib/python3.8/site-packages/ansible/executor/task_executor.py", line 908, in _get_connection
    connection, plugin_load_context = self._shared_loader_obj.connection_loader.get_with_context(
  File "/home/romain/pro/aubonticket/.venv/lib/python3.8/site-packages/ansible/plugins/loader.py", line 826, in get_with_context
    obj.__init__(instance, *args, **kwargs)
  File "/home/romain/pro/aubonticket/.venv/lib/python3.8/site-packages/ansible_collections/community/general/plugins/connection/docker.py", line 93, in __init__
    if docker_version != u'dev' and LooseVersion(docker_version) < LooseVersion(u'1.3'):
  File "/usr/host/lib/python3.8/distutils/version.py", line 52, in __lt__
    c = self._cmp(other)
  File "/usr/host/lib/python3.8/distutils/version.py", line 337, in _cmp
    if self.version < other.version:
TypeError: '<' not supported between instances of 'str' and 'int'
fatal: [server]: FAILED! => {
    "msg": "Unexpected failure during module execution.",
    "stdout": ""
}
SUMMARY

I modified the _sanitize_version method to handle this case.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

plugins/connection/docker.py

Copy link
Collaborator

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

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

That's an interesting finding! For me, that command gives the version without a leading v (20.10.0 and 20.10.2). I don't have 20.10.1 installed somewhere, maybe it just happens there?

In any case, could you please add a changelog fragment?

@voondo
Copy link
Contributor Author

voondo commented Jan 27, 2021

I added the changelog fragment as requested.

About this mysterious 'v', maybe is it caused by the fact that the dockerd packaged by my linux distribution is built from moby and is not the official prebuilt Docker CE ? I don't know

@felixfontein
Copy link
Collaborator

Out of curiosity, which distribution is it that you have this problem with? I've checked with both Arch Linux (I think the package is also built from moby: https://github.com/archlinux/svntogit-community/blob/packages/docker/trunk/PKGBUILD) and Debian (using the official docker-ce packages from https://download.docker.com/linux/debian).

Co-authored-by: Felix Fontein <felix@fontein.de>
@voondo
Copy link
Contributor Author

voondo commented Jan 27, 2021

It's exherbo where Docker itself is a set composed of theses packages:

Honestly, I'm not an docker expert so I can't tell more...

@felixfontein felixfontein merged commit 43cbe30 into ansible-collections:main Jan 27, 2021
@felixfontein
Copy link
Collaborator

@voondo thanks for this fix! I'll probably do a bugfix release of the collection this evening so this gets out ASAP.

I've never really looked at how Moby is built, so I can't tell either :) I just dwell through the sources sometimes to try to figure out how something works in the CLI to find out how to achieve the same result with the API resp. Docker SDK for Python... :)

felixfontein added a commit to felixfontein/community.general that referenced this pull request Jan 27, 2021
felixfontein added a commit to ansible-collections/community.general that referenced this pull request Jan 27, 2021
@felixfontein felixfontein mentioned this pull request Jan 28, 2021
@voondo voondo deleted the patch-1 branch January 28, 2021 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants