diff options
author | Simon Westphahl <westphahl@gmail.com> | 2019-03-28 04:44:49 +0100 |
---|---|---|
committer | Toshio Kuratomi <a.badger@gmail.com> | 2019-04-01 14:38:52 -0700 |
commit | 7d6c925e38a814cd8c1e5cfd685151411b1222ac (patch) | |
tree | 107d28c8421da5ddf7b2538d9ce2b2a928f36113 | |
parent | 707c75ab0b63a0949ef7471143db6e1fed05840c (diff) | |
download | ansible-7d6c925e38a814cd8c1e5cfd685151411b1222ac.tar.gz |
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 <westphahl@gmail.com>
* Changelog for winrm error handling improvement
-rw-r--r-- | changelogs/fragments/winrm-all-timeout-exceptions.yaml | 4 | ||||
-rw-r--r-- | lib/ansible/plugins/connection/winrm.py | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/changelogs/fragments/winrm-all-timeout-exceptions.yaml b/changelogs/fragments/winrm-all-timeout-exceptions.yaml new file mode 100644 index 0000000000..589635e5bc --- /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 20d00ba8a1..fb88605788 100644 --- a/lib/ansible/plugins/connection/winrm.py +++ b/lib/ansible/plugins/connection/winrm.py @@ -491,7 +491,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: |