diff options
author | Ganesh Nalawade <ganesh634@gmail.com> | 2017-08-01 23:15:45 +0530 |
---|---|---|
committer | Chris Alfonso <christopher.alfonso@gmail.com> | 2017-08-01 11:45:45 -0600 |
commit | 70ce39484089e79dd27ab89dcbdd7ce79ffddfa5 (patch) | |
tree | 93332d6e76868c05de389c76277e6002e27c8721 /bin/ansible-connection | |
parent | 4dd8f281d6a70429b04b37943029c9a2f1e827db (diff) | |
download | ansible-70ce39484089e79dd27ab89dcbdd7ce79ffddfa5.tar.gz |
Persistent connection timer changes (#27272)
* Add command_timeout timer that defines the amount
of time to wait for a command or RPC call before
timing out.
* Remove connect_retries and connect_interval configuration
varaible and replace it with connect_retry_timeout to control
the timeout value of connection to local scoket.
* Make required changes to netowrk action plugins and relevant
network files in module_utils.
* Required documentation changes.
Diffstat (limited to 'bin/ansible-connection')
-rwxr-xr-x | bin/ansible-connection | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/bin/ansible-connection b/bin/ansible-connection index 073de82af5..84fdc06fb0 100755 --- a/bin/ansible-connection +++ b/bin/ansible-connection @@ -178,11 +178,11 @@ class Server(): display.display('shutdown local socket, connection was active for %s secs' % delta, log_only=True) def connect_timeout(self, signum, frame): - display.display('connect timeout triggered, timeout value is %s secs' % C.PERSISTENT_CONNECT_TIMEOUT, log_only=True) + display.display('persistent connection idle timeout triggered, timeout value is %s secs' % C.PERSISTENT_CONNECT_TIMEOUT, log_only=True) self.shutdown() def command_timeout(self, signum, frame): - display.display('commnad timeout triggered, timeout value is %s secs' % self.play_context.timeout, log_only=True) + display.display('command timeout triggered, timeout value is %s secs' % self.play_context.timeout, log_only=True) self.shutdown() def handler(self, signum, frame): @@ -214,6 +214,7 @@ class Server(): def do_EXEC(self, data): cmd = data.split(b'EXEC: ')[1] + display.display('Command executed: %s' % cmd, log_only=True) return self.connection.exec_command(cmd) def do_PUT(self, data): @@ -352,17 +353,17 @@ def main(): sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) - attempts = C.PERSISTENT_CONNECT_RETRIES - while bool(attempts): + connect_retry_timeout = C.PERSISTENT_CONNECT_RETRY_TIMEOUT + while bool(connect_retry_timeout): try: sock.connect(socket_path) break except socket.error: - time.sleep(C.PERSISTENT_CONNECT_INTERVAL) - attempts -= 1 + time.sleep(1) + connect_retry_timeout -= 1 else: - display.display('number of connection attempts exceeded, unable to connect to control socket', pc.remote_addr, pc.remote_user, log_only=True) - display.display('persistent_connect_interval=%s, persistent_connect_retries=%s' % (C.PERSISTENT_CONNECT_INTERVAL, C.PERSISTENT_CONNECT_RETRIES), pc.remote_addr, pc.remote_user, log_only=True) + display.display('connect retry timeout expired, unable to connect to control socket', pc.remote_addr, pc.remote_user, log_only=True) + display.display('persistent_connect_retry_timeout is %s secs' % (C.PERSISTENT_CONNECT_RETRY_TIMEOUT), pc.remote_addr, pc.remote_user, log_only=True) sys.stderr.write('failed to connect to control socket') sys.exit(255) |