mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-07-30 12:15:45 +00:00
Fix error handling. (#546)
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
bugfixes:
|
||||||
|
- "docker_api connection plugin - fix error handling when 409 Conflict is returned by the Docker daemon in case of a stopped container (https://github.com/ansible-collections/community.docker/pull/546)."
|
||||||
|
- "docker_container_exec - fix error handling when 409 Conflict is returned by the Docker daemon in case of a stopped container (https://github.com/ansible-collections/community.docker/pull/546)."
|
||||||
@@ -113,7 +113,7 @@ class Connection(ConnectionBase):
|
|||||||
else:
|
else:
|
||||||
raise AnsibleConnectionFailure('Could not find container "{1}" ({0})'.format(e, self.get_option('remote_addr')))
|
raise AnsibleConnectionFailure('Could not find container "{1}" ({0})'.format(e, self.get_option('remote_addr')))
|
||||||
except APIError as e:
|
except APIError as e:
|
||||||
if e.response and e.response.status_code == 409:
|
if e.response is not None and e.response.status_code == 409:
|
||||||
raise AnsibleConnectionFailure('The container "{1}" has been paused ({0})'.format(e, self.get_option('remote_addr')))
|
raise AnsibleConnectionFailure('The container "{1}" has been paused ({0})'.format(e, self.get_option('remote_addr')))
|
||||||
self.client.fail(
|
self.client.fail(
|
||||||
'An unexpected Docker error occurred for container "{1}": {0}'.format(e, self.get_option('remote_addr'))
|
'An unexpected Docker error occurred for container "{1}": {0}'.format(e, self.get_option('remote_addr'))
|
||||||
|
|||||||
@@ -295,7 +295,7 @@ def main():
|
|||||||
except NotFound:
|
except NotFound:
|
||||||
client.fail('Could not find container "{0}"'.format(container))
|
client.fail('Could not find container "{0}"'.format(container))
|
||||||
except APIError as e:
|
except APIError as e:
|
||||||
if e.response and e.response.status_code == 409:
|
if e.response is not None and e.response.status_code == 409:
|
||||||
client.fail('The container "{0}" has been paused ({1})'.format(container, to_native(e)))
|
client.fail('The container "{0}" has been paused ({1})'.format(container, to_native(e)))
|
||||||
client.fail('An unexpected Docker error occurred: {0}'.format(to_native(e)), exception=traceback.format_exc())
|
client.fail('An unexpected Docker error occurred: {0}'.format(to_native(e)), exception=traceback.format_exc())
|
||||||
except DockerException as e:
|
except DockerException as e:
|
||||||
|
|||||||
Reference in New Issue
Block a user