From 3f9770d2c0fd76070214ca85e0dd81b9f1924011 Mon Sep 17 00:00:00 2001 From: Kurt Martin Date: Mon, 15 Dec 2014 15:14:42 -0800 Subject: [PATCH] Fix 3PAR driver hang on SSH calls In removing the 3PAR driver local file locks, part of the fix included making a new SSH connection for each call in the hp3parclient as oppose to leaving a connection open. Older hp3parclients(3.1.1 and later) will result in the SSH calls hanging at driver initilization time. This patch will now check against the correct minimum hp3parclient version and remove the need for checking of the SSH args version since the minimum hp3parclient is now greater than 3.1.1 Closes-Bug: #1402115 Change-Id: Ic162a1a469e85fa36501d4de245fe16738d3aefa --- cinder/tests/fake_hp_3par_client.py | 2 +- cinder/tests/test_hp3par.py | 19 ++------ .../volume/drivers/san/hp/hp_3par_common.py | 43 +++++++------------ 3 files changed, 21 insertions(+), 43 deletions(-) diff --git a/cinder/tests/fake_hp_3par_client.py b/cinder/tests/fake_hp_3par_client.py index 85905448c..b6f19d557 100644 --- a/cinder/tests/fake_hp_3par_client.py +++ b/cinder/tests/fake_hp_3par_client.py @@ -22,7 +22,7 @@ import mock from cinder.tests import fake_hp_client_exceptions as hpexceptions hp3par = mock.Mock() -hp3par.version = "3.1.0" +hp3par.version = "3.1.2" hp3par.exceptions = hpexceptions sys.modules['hp3parclient'] = hp3par diff --git a/cinder/tests/test_hp3par.py b/cinder/tests/test_hp3par.py index d95df7c6a..93719067f 100644 --- a/cinder/tests/test_hp3par.py +++ b/cinder/tests/test_hp3par.py @@ -365,7 +365,9 @@ class HP3PARBaseDriver(object): HP3PAR_SAN_IP, HP3PAR_USER_NAME, HP3PAR_USER_PASS, + missing_key_policy='AutoAddPolicy', privatekey=HP3PAR_SAN_SSH_PRIVATE, + known_hosts_file=mock.ANY, port=HP3PAR_SAN_SSH_PORT, conn_timeout=HP3PAR_SAN_SSH_CON_TIMEOUT)] @@ -421,20 +423,7 @@ class HP3PARBaseDriver(object): self.assertRaises(exception.InvalidInput, self.setup_driver) - @mock.patch('hp3parclient.version', "3.1.0") - def test_ssh_options_310(self): - - self.ctxt = context.get_admin_context() - mock_client = self.setup_mock_client(driver=hpfcdriver.HP3PARFCDriver) - expected = [ - mock.call.getCPG(HP3PAR_CPG), - mock.call.getCPG(HP3PAR_CPG2)] - mock_client.assert_has_calls( - self.standard_login + - expected + - self.standard_logout) - - @mock.patch('hp3parclient.version', "3.1.1") + @mock.patch('hp3parclient.version', "3.1.2") def test_ssh_options(self): expected_hosts_key_file = "test_hosts_key_file" @@ -466,7 +455,7 @@ class HP3PARBaseDriver(object): expected + self.standard_logout) - @mock.patch('hp3parclient.version', "3.1.1") + @mock.patch('hp3parclient.version', "3.1.2") def test_ssh_options_strict(self): expected_hosts_key_file = "test_hosts_key_file" diff --git a/cinder/volume/drivers/san/hp/hp_3par_common.py b/cinder/volume/drivers/san/hp/hp_3par_common.py index 3782894d3..0a697799b 100644 --- a/cinder/volume/drivers/san/hp/hp_3par_common.py +++ b/cinder/volume/drivers/san/hp/hp_3par_common.py @@ -69,8 +69,7 @@ from taskflow.patterns import linear_flow LOG = logging.getLogger(__name__) -MIN_CLIENT_VERSION = '3.1.0' -MIN_CLIENT_SSH_ARGS_VERSION = '3.1.1' +MIN_CLIENT_VERSION = '3.1.2' hp3par_opts = [ cfg.StrOpt('hp3par_api_url', @@ -160,10 +159,11 @@ class HP3PARCommon(object): 2.0.27 - Fixing manage source-id error bug #1357075 2.0.28 - Removing locks bug #1381190 2.0.29 - Report a limitless cpg's stats better bug #1398651 + 2.0.30 - Update the minimum hp3parclient version bug #1402115 """ - VERSION = "2.0.29" + VERSION = "2.0.30" stats = {} @@ -238,30 +238,19 @@ class HP3PARCommon(object): LOG.error(msg) raise exception.InvalidInput(reason=msg) - client_version = hp3parclient.version - - if client_version < MIN_CLIENT_SSH_ARGS_VERSION: - self.client.setSSHOptions( - self.config.san_ip, - self.config.san_login, - self.config.san_password, - port=self.config.san_ssh_port, - conn_timeout=self.config.ssh_conn_timeout, - privatekey=self.config.san_private_key) - else: - known_hosts_file = CONF.ssh_hosts_key_file - policy = "AutoAddPolicy" - if CONF.strict_ssh_host_key_policy: - policy = "RejectPolicy" - self.client.setSSHOptions( - self.config.san_ip, - self.config.san_login, - self.config.san_password, - port=self.config.san_ssh_port, - conn_timeout=self.config.ssh_conn_timeout, - privatekey=self.config.san_private_key, - missing_key_policy=policy, - known_hosts_file=known_hosts_file) + known_hosts_file = CONF.ssh_hosts_key_file + policy = "AutoAddPolicy" + if CONF.strict_ssh_host_key_policy: + policy = "RejectPolicy" + self.client.setSSHOptions( + self.config.san_ip, + self.config.san_login, + self.config.san_password, + port=self.config.san_ssh_port, + conn_timeout=self.config.ssh_conn_timeout, + privatekey=self.config.san_private_key, + missing_key_policy=policy, + known_hosts_file=known_hosts_file) def client_logout(self): LOG.info(_LI("Disconnect from 3PAR REST and SSH %s") % self.uuid) -- 2.45.2