diff --git a/cinder/tests/test_pure.py b/cinder/tests/test_pure.py index d0139a04789..fb6ba618e8d 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 0e5abf68774..190a514f731 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 "