From 742e30922b70952b8bc5b2394e29d0d020be4ea0 Mon Sep 17 00:00:00 2001 From: Tom Barron Date: Sat, 29 Dec 2018 21:35:53 -0600 Subject: [PATCH] Change ssh_utils parameter to correctly send keepalive packets The current implementation of ssh_utils never sends keepalive packets. In ssh_utils.SSHPool, the socket timeout parameter is set to None intending to keep ssh connections open. However, when the parameter is set to None, ssh_utils does not run the code to compare idle duration and keepalive interval. This patch reverts the socket timeout parameter to default (0.1 sec). The ssh_utils compares them every 0.1 seconds, and sends a keepalive packet if idle duration > keepalive interval (= self.conn_timeout). See cinder change: I8234083107207b9ebc0849947e8de92b5cf3e36e Change-Id: Ib13e5c6246412d667554cb0bd9c419b513af70c7 Related-Bug: #1673662 (cherry picked from commit 1814ad41134a2fa952ea6b664984da07d46d17c3) --- manila/utils.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/manila/utils.py b/manila/utils.py index 63f73de822..a4660d5965 100644 --- a/manila/utils.py +++ b/manila/utils.py @@ -150,16 +150,8 @@ class SSHPool(pools.Pool): look_for_keys=look_for_keys, timeout=self.conn_timeout, banner_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: