From 70ce39484089e79dd27ab89dcbdd7ce79ffddfa5 Mon Sep 17 00:00:00 2001 From: Ganesh Nalawade Date: Tue, 1 Aug 2017 23:15:45 +0530 Subject: 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. --- bin/ansible-connection | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'bin') 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) -- cgit v1.2.1