aboutsummaryrefslogtreecommitdiff
path: root/ansible/library
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-01-04 12:30:43 +0000
committerGerrit Code Review <review@openstack.org>2016-01-04 12:30:44 +0000
commite355132bfc3e6a019711303b1d2d78c17c7caa84 (patch)
treefccd942960f35e54fbce4a49e00d1fceb432dc55 /ansible/library
parent63f079485160c6c462adcd4ca449bd0522d7cc3b (diff)
parent7fe22629aba3aad2577a8b396b638128218a1d53 (diff)
downloadkolla-e355132bfc3e6a019711303b1d2d78c17c7caa84.tar.gz
kolla-e355132bfc3e6a019711303b1d2d78c17c7caa84.zip
Merge "Fix the docker may return a empty dict when pull images"
Diffstat (limited to 'ansible/library')
-rw-r--r--ansible/library/kolla_docker.py38
1 files changed, 21 insertions, 17 deletions
diff --git a/ansible/library/kolla_docker.py b/ansible/library/kolla_docker.py
index 1b24f0ccb..224fda3ca 100644
--- a/ansible/library/kolla_docker.py
+++ b/ansible/library/kolla_docker.py
@@ -211,28 +211,32 @@ class DockerWorker(object):
image, tag = self.parse_image()
- status = [
+ statuses = [
json.loads(line.strip()) for line in self.dc.pull(
repository=image, tag=tag, stream=True
)
]
- # NOTE(SamYaple): This allows us to use v1 and v2 docker registries.
- # Eventually docker will stop supporting v1 registries and when
- # that happens we can remove this.
- search = -2 if 'legacy registry' in status[-1].get('status') else -1
-
- if "Downloaded newer image for" in status[search].get('status'):
- self.changed = True
- elif "Image is up to date for" in status[search].get('status'):
- # No new layer was pulled, no change
- pass
- else:
- self.module.fail_json(
- msg="Invalid status returned from pull",
- changed=True,
- failed=True
- )
+ for status in reversed(statuses):
+ # NOTE(jeffrey4l): Get the last not empty status with status
+ # property
+ if status and status.get('status'):
+ # NOTE(SamYaple): This allows us to use v1 and v2 docker
+ # registries. Eventually docker will stop supporting v1
+ # registries and when that happens we can remove this.
+ if 'legacy registry' in status.get('status'):
+ continue
+ elif "Downloaded newer image for" in status.get('status'):
+ self.changed = True
+ return
+ elif "Image is up to date for" in status.get('status'):
+ return
+ else:
+ self.module.fail_json(
+ msg="Invalid status returned from pull",
+ changed=True,
+ failed=True
+ )
def remove_container(self):
if self.check_container():