From a44dfed57012340572d3b002c1e2c4f89d84bd2e Mon Sep 17 00:00:00 2001 From: Simon Westphahl Date: Thu, 28 Mar 2019 04:44:49 +0100 Subject: [PATCH] Catch all request timeouts for winrm connection (#54104) * Catch all request timeouts for winrm connection The current implementation only catches 'ConnectTimeout' exceptions. Instead we should catch 'Timout' which also catches ReadTimeout exceptions. Improves on: #51744 Co-Authored-By: westphahl * Changelog for winrm error handling improvement --- changelogs/fragments/winrm-all-timeout-exceptions.yaml | 4 ++++ lib/ansible/plugins/connection/winrm.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/winrm-all-timeout-exceptions.yaml diff --git a/changelogs/fragments/winrm-all-timeout-exceptions.yaml b/changelogs/fragments/winrm-all-timeout-exceptions.yaml new file mode 100644 index 00000000000..589635e5bce --- /dev/null +++ b/changelogs/fragments/winrm-all-timeout-exceptions.yaml @@ -0,0 +1,4 @@ +--- +minor_changes: + - Catch all connection timeout related exceptions and raise + AnsibleConnectionError instead diff --git a/lib/ansible/plugins/connection/winrm.py b/lib/ansible/plugins/connection/winrm.py index 7c020b142e6..4564ef76edb 100644 --- a/lib/ansible/plugins/connection/winrm.py +++ b/lib/ansible/plugins/connection/winrm.py @@ -489,7 +489,7 @@ class Connection(ConnectionBase): % (to_native(response.std_out), to_native(stderr))) return response - except requests.exceptions.ConnectionError as exc: + except requests.exceptions.Timeout as exc: raise AnsibleConnectionFailure('winrm connection error: %s' % to_native(exc)) finally: if command_id: