diff options
author | Ganesh Nalawade <ganesh634@gmail.com> | 2018-08-02 12:08:37 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-02 12:08:37 +0530 |
commit | 3f3101dfe5f96d5acd5522ca9265502e9b93adfd (patch) | |
tree | df5c3007a6277dd47bd4cd718780604142804825 /bin | |
parent | b771913c0dffd3614304b5d59ccdab35f225ca57 (diff) | |
download | ansible-3f3101dfe5f96d5acd5522ca9265502e9b93adfd.tar.gz |
Raise exception if command timeout is triggered (#43078)
* Raise exception if command timeout is triggered
Fixes #43076
If persistent connection timeout is triggered, riase
exception which will be send over socket to module code
instead of silently shutting down the socket.
* Fix CI failure
* Fix review comment
* Fix CI failure
* Fix review comment
* Fix review comment
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/ansible-connection | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/bin/ansible-connection b/bin/ansible-connection index 322ccc5a91..a9b381c63a 100755 --- a/bin/ansible-connection +++ b/bin/ansible-connection @@ -16,6 +16,7 @@ import os import signal import socket import sys +import time import traceback import errno import json @@ -141,22 +142,28 @@ class ConnectionProcess(object): self.exception = traceback.format_exc() finally: - # when done, close the connection properly and cleanup - # the socket file so it can be recreated + # allow time for any exception msg send over socket to receive at other end before shutting down + time.sleep(0.1) + + # when done, close the connection properly and cleanup the socket file so it can be recreated self.shutdown() def connect_timeout(self, signum, frame): - display.display('persistent connection idle timeout triggered, timeout value is %s secs' - % self.connection.get_option('persistent_connect_timeout'), log_only=True) - self.shutdown() + msg = 'persistent connection idle timeout triggered, timeout value is %s secs.\nSee the timeout setting options in the Network Debug and ' \ + 'Troubleshooting Guide.' % self.connection.get_option('persistent_connect_timeout') + display.display(msg, log_only=True) + raise Exception(msg) def command_timeout(self, signum, frame): - display.display('command timeout triggered, timeout value is %s secs' % self.connection.get_option('persistent_command_timeout'), log_only=True) - self.shutdown() + msg = 'command timeout triggered, timeout value is %s secs.\nSee the timeout setting options in the Network Debug and Troubleshooting Guide.'\ + % self.connection.get_option('persistent_command_timeout') + display.display(msg, log_only=True) + raise Exception(msg) def handler(self, signum, frame): - display.display('signal handler called with signal %s' % signum, log_only=True) - self.shutdown() + msg = 'signal handler called with signal %s.' % signum + display.display(msg, log_only=True) + raise Exception(msg) def shutdown(self): """ Shuts down the local domain socket |