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
This commit is contained in:
parent
aa1d3754b1
commit
7b109bb6bf
@ -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
|
||||
|
||||
|
@ -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 "
|
||||
|
Loading…
x
Reference in New Issue
Block a user