Merge "Change ssh_utils parameter to correctly send keepalive packets" into stable/ocata

This commit is contained in:
Zuul 2019-01-16 13:50:32 +00:00 committed by Gerrit Code Review
commit 14bf24b231

View File

@ -108,16 +108,8 @@ class SSHPool(pools.Pool):
key_filename=self.path_to_private_key,
look_for_keys=look_for_keys,
timeout=self.conn_timeout)
# Paramiko by default sets the socket timeout to 0.1 seconds,
# ignoring what we set through the sshclient. This doesn't help for
# keeping long lived connections. Hence we have to bypass it, by
# overriding it after the transport is initialized. We are setting
# the sockettimeout to None and setting a keepalive packet so that,
# the server will keep the connection open. All that does is send
# a keepalive packet every ssh_conn_timeout seconds.
if self.conn_timeout:
transport = ssh.get_transport()
transport.sock.settimeout(None)
transport.set_keepalive(self.conn_timeout)
return ssh
except Exception as e: