Rework log output if pull fails

Co-Authored-By: Sam Yaple <sam@yaple.net>
Change-Id: I066b2d419abb3ef2d4827ce686865c0dc68a5e97
Closes-bug: #1537763
This commit is contained in:
SamYaple 2016-01-28 02:43:55 +00:00
parent 2361fddcff
commit 4649279c9d

View File

@ -337,23 +337,35 @@ class DockerWorker(object):
] ]
for status in reversed(statuses): for status in reversed(statuses):
# NOTE(jeffrey4l): Get the last not empty status with status if 'error' in status:
# property if status['error'].endswith('not found'):
self.module.fail_json(
msg="The requested image does not exist: {}:{}".format(
image, tag),
failed=True
)
else:
self.module.fail_json(
msg="Unknown error message: {}".format(
status['error']),
failed=True
)
if status and status.get('status'): if status and status.get('status'):
# NOTE(SamYaple): This allows us to use v1 and v2 docker # NOTE(SamYaple): This allows us to use v1 and v2 docker
# registries. Eventually docker will stop supporting v1 # registries. Eventually docker will stop supporting v1
# registries and when that happens we can remove this. # registries and when that happens we can remove this.
if 'legacy registry' in status.get('status'): if 'legacy registry' in status['status']:
continue continue
elif "Downloaded newer image for" in status.get('status'): elif 'Downloaded newer image for' in status['status']:
self.changed = True self.changed = True
return return
elif "Image is up to date for" in status.get('status'): elif 'Image is up to date for' in status['status']:
return return
else: else:
self.module.fail_json( self.module.fail_json(
msg="Invalid status returned from pull", msg="Unknown status message: {}".format(
changed=True, status['status']),
failed=True failed=True
) )