docker pull broken in devel for docker >= 1.8 #2043
Comments
I'm seeing this too, with docker-1.8.2-5.gitcb216be.fc23.x86_64 , python-docker-py-1.3.1-1.fc23.noarch (on the docker host box) and ansible-1.9.3-3.fc23.noarch (on the machine running ansible). |
Note: the problem here isn't that the status message has changed, I don't think. Note in the error message, it actually logs the status it got: The code here is around https://github.com/AdamWill/ansible-modules-core/blob/devel/cloud/docker/docker.py#L1392 . It runs a Now I look at the output carefully it's pretty obvious what the problem is: the very last item in the stream is an empty dict! Look at the end:
that second-to-last dict is the one we actually want - the one with the status message that the code is looking for - but there's a completely empty dict after it. So we're getting that empty dict, and obviously hence our status value will be the empty string. So I guess the real problem here is in either docker-py or docker itself - whatever's causing that extra empty dict to show up in the stream. A dumb hack would be to take the last item, see if it's an empty dict, and take the second-to-last item if so, but that seems kinda awful. Having fun trying to track down what's causing this, though. |
fix #2043: strip empty dict from end of 'pull' stream
When pulling an image using Docker 1.8, it seems the output JSON stream has an empty dict at the very end. This causes ansible to fail when pulling an image, as it's expecting a status message in that dict which it uses to determine whether it had to download the image or not. As a bit of an ugly hack for that which remains backward compatible, try the last item in the stream, and if it's an empty dict, take the last-but-one item instead. The strip() is needed as the exact value appears to be '{}/r/n'; we could just match that, but it seems like the kind of thing where maybe it'd happen to just be '{}/n' or '{}' or something in some cases, so let's just use strip() in case.
For the record, I filed the underlying issue upstream with Docker: so if that ever gets resolved, this hack could be retired after a suitable grace period for people to update Docker... |
- see ansible/ansible-modules-core#2043 - images pulled with cli commands before launching containers - images defined as variables
- see ansible/ansible-modules-core#2043 - images pulled with cli commands before launching containers - images defined as variables
- see ansible/ansible-modules-core#2043 - images pulled with cli commands before launching containers - images defined as variables
Issue type
Bug report
Summary
The docker module fails when pulling new images when using docker >= 1.8.
Ansible version:
Environment/config:
OSX source install. Default config.
Steps to reproduce
Add a docker image that does not exist on the target host.
Ansible will mark the pull as failed, even though it completes successfully. Log below:
Note that the docker status is "Pull complete" and that the image exists in sudo docker show images after this. It appears that ansible does not correctly parse the status message.
This only happens for me after upgrading from docker 1.7 to 1.8.
Re-running ansible works correctly, as now the image is downloaded and the pull is not required - however having to run ansible repeatedly to download multiple images is highly frustrating.
The text was updated successfully, but these errors were encountered: