From: Patrick East Date: Tue, 3 Feb 2015 20:09:58 +0000 (-0800) Subject: Make PureISCSIDriver iSCSI port discovery more flexible X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=7b109bb6bf831dab08fe7a2db2800f2ae34b2bfd;p=openstack-build%2Fcinder-build.git Make PureISCSIDriver iSCSI port discovery more flexible While searching for reachable iSCSI ports on the target flash array it might fail the discovery command. If this happens on driver setup it will throw an exception from attempting to use fields on an uninitialized class variable. This fixes the log message and adds a retry to the method to make this more flexible with network timeouts. Closes-Bug: 1417730 Change-Id: I99ffb8de4dd5a421442df1bf745808505775480a --- diff --git a/cinder/tests/test_pure.py b/cinder/tests/test_pure.py index d0139a047..fb6ba618e 100644 --- a/cinder/tests/test_pure.py +++ b/cinder/tests/test_pure.py @@ -13,6 +13,8 @@ # License for the specific language governing permissions and limitations # under the License. +import sys + import mock from oslo_concurrency import processutils from oslo_utils import units @@ -21,7 +23,12 @@ from cinder import exception from cinder import test -import sys +def fake_retry(exceptions, interval=1, retries=3, backoff_rate=2): + def _decorator(f): + return f + return _decorator + +mock.patch('cinder.utils.retry', fake_retry).start() sys.modules['purestorage'] = mock.Mock() from cinder.volume.drivers import pure diff --git a/cinder/volume/drivers/pure.py b/cinder/volume/drivers/pure.py index 0e5abf687..190a514f7 100644 --- a/cinder/volume/drivers/pure.py +++ b/cinder/volume/drivers/pure.py @@ -264,6 +264,7 @@ class PureISCSIDriver(san.SanISCSIDriver): self._iscsi_port = self._choose_target_iscsi_port() return self._iscsi_port + @utils.retry(exception.PureDriverException, retries=3) def _choose_target_iscsi_port(self): """Find a reachable iSCSI-enabled port on target array.""" ports = self._array.list_ports() @@ -276,8 +277,8 @@ class PureISCSIDriver(san.SanISCSIDriver): except processutils.ProcessExecutionError as err: LOG.debug(("iSCSI discovery of port %(port_name)s at " "%(port_portal)s failed with error: %(err_msg)s"), - {"port_name": self._iscsi_port["name"], - "port_portal": self._iscsi_port["portal"], + {"port_name": port["name"], + "port_portal": port["portal"], "err_msg": err.stderr}) else: LOG.info(_LI("Using port %(name)s on the array at %(portal)s "