docker_node_info: improve error handling (#63418)

* Improve error handling for get_service_inspect().

* Add changelog fragment.
This commit is contained in:
Felix Fontein 2019-10-13 14:16:02 +02:00 committed by GitHub
parent 7f643690c7
commit d753168e9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View file

@ -0,0 +1,3 @@
bugfixes:
- "docker_node_info - improve error handling when service inspection fails, for example because node name being ambiguous
(https://github.com/ansible/ansible/issues/63353, PR https://github.com/ansible/ansible/pull/63418)."

View file

@ -164,10 +164,9 @@ class AnsibleDockerSwarmClient(AnsibleDockerClient):
if exc.status_code == 503:
self.fail("Cannot inspect node: To inspect node execute module on Swarm Manager")
if exc.status_code == 404:
if skip_missing is False:
self.fail("Error while reading from Swarm manager: %s" % to_native(exc))
else:
if skip_missing:
return None
self.fail("Error while reading from Swarm manager: %s" % to_native(exc))
except Exception as exc:
self.fail("Error inspecting swarm node: %s" % exc)