From: rajinir Date: Tue, 28 Apr 2015 16:28:51 +0000 (-0500) Subject: Eqlx: Fixes the retries on Network Connection Error X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=576c368f1c57ad4b9ae51268a48ac53c65e794aa;p=openstack-build%2Fcinder-build.git Eqlx: Fixes the retries on Network Connection Error Volume creations were failing due to ssh connection errors throwing ProcessExecutionError and retries were not happening. Made a fix to retry commands on both network errors and backend api exceptions. The parameter eqlx_cli_max_retries determines the number of retry attempts made. Closes Bug: #1441719 Change-Id: I54b76afc6c9c5d51dd9c38831ee0a1c731c7b161 --- diff --git a/cinder/tests/unit/test_eqlx.py b/cinder/tests/unit/test_eqlx.py index cb928c6d2..85082559e 100644 --- a/cinder/tests/unit/test_eqlx.py +++ b/cinder/tests/unit/test_eqlx.py @@ -345,6 +345,33 @@ class DellEQLSanISCSIDriverTestCase(test.TestCase): self.assertEqual(num_attempts + 1, self.driver._ssh_execute.call_count) + @mock.patch.object(greenthread, 'sleep') + def test_ensure_connection_retries(self, _gt_sleep): + num_attempts = 3 + self.driver.configuration.eqlx_cli_max_retries = num_attempts + self.mock_object(self.driver, '_ssh_execute', + mock.Mock(side_effect= + processutils.ProcessExecutionError + (stdout='% Error ... some error.\n'))) + # mocks for calls in _run_ssh + self.mock_object(utils, 'check_ssh_injection') + self.mock_object(ssh_utils, 'SSHPool') + + sshpool = ssh_utils.SSHPool("127.0.0.1", 22, 10, + "test", + password="test", + min_size=1, + max_size=1) + self.driver.sshpool = mock.Mock(return_value=sshpool) + ssh = mock.Mock(paramiko.SSHClient) + self.driver.sshpool.item().__enter__ = mock.Mock(return_value=ssh) + self.driver.sshpool.item().__exit__ = mock.Mock(return_value=False) + # now call the execute + self.assertRaises(exception.VolumeBackendAPIException, + self.driver._eql_execute, "fake command") + self.assertEqual(num_attempts + 1, + self.driver._ssh_execute.call_count) + @mock.patch.object(greenthread, 'sleep') def test_ensure_retries_on_channel_timeout(self, _gt_sleep): num_attempts = 3 diff --git a/cinder/volume/drivers/eqlx.py b/cinder/volume/drivers/eqlx.py index f04be1659..187d27df4 100644 --- a/cinder/volume/drivers/eqlx.py +++ b/cinder/volume/drivers/eqlx.py @@ -245,8 +245,6 @@ class DellEQLSanISCSIDriver(san.SanISCSIDriver): return self._ssh_execute( ssh, command, timeout=self.configuration.eqlx_cli_timeout) - except processutils.ProcessExecutionError: - raise except Exception as e: LOG.exception(e) greenthread.sleep(random.randint(20, 500) / 100.0)