mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix a potential bug in docker pull
This commit is contained in:
parent
0ad023a0ac
commit
1bb98542d3
1 changed files with 6 additions and 4 deletions
|
@ -1159,9 +1159,11 @@ class DockerManager(object):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.module.fail_json(msg="failed to login to the remote registry, check your username/password.", error=repr(e))
|
self.module.fail_json(msg="failed to login to the remote registry, check your username/password.", error=repr(e))
|
||||||
try:
|
try:
|
||||||
last = None
|
changes = list(self.client.pull(image, tag=tag, stream=True, **extra_params))
|
||||||
for line in self.client.pull(image, tag=tag, stream=True, **extra_params):
|
try:
|
||||||
last = line
|
last = changes[-1]
|
||||||
|
except IndexError:
|
||||||
|
last = '{}'
|
||||||
status = json.loads(last).get('status', '')
|
status = json.loads(last).get('status', '')
|
||||||
if status.startswith('Status: Image is up to date for'):
|
if status.startswith('Status: Image is up to date for'):
|
||||||
# Image is already up to date. Don't increment the counter.
|
# Image is already up to date. Don't increment the counter.
|
||||||
|
@ -1171,7 +1173,7 @@ class DockerManager(object):
|
||||||
self.increment_counter('pulled')
|
self.increment_counter('pulled')
|
||||||
else:
|
else:
|
||||||
# Unrecognized status string.
|
# Unrecognized status string.
|
||||||
self.module.fail_json(msg="Unrecognized status from pull.", status=status)
|
self.module.fail_json(msg="Unrecognized status from pull.", status=status, changes=changes)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.module.fail_json(msg="Failed to pull the specified image: %s" % resource, error=repr(e))
|
self.module.fail_json(msg="Failed to pull the specified image: %s" % resource, error=repr(e))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue