Merge "linuxscsi: Stop waiting for multipath devices during extend_volume" into stable/queens

This commit is contained in:
Zuul 2020-02-18 15:06:59 +00:00 committed by Gerrit Code Review
commit 6e4e8901fe
6 changed files with 37 additions and 25 deletions

View File

@ -176,7 +176,8 @@ class FibreChannelConnector(base.BaseLinuxConnector):
volume_paths = self.get_volume_paths(connection_properties)
if volume_paths:
return self._linuxscsi.extend_volume(volume_paths)
return self._linuxscsi.extend_volume(
volume_paths, use_multipath=self.use_multipath)
else:
LOG.warning("Couldn't find any volume paths on the host to "
"extend volume for %(props)s",

View File

@ -471,7 +471,8 @@ class ISCSIConnector(base.BaseLinuxConnector, base_iscsi.BaseISCSIConnector):
volume_paths = self.get_volume_paths(connection_properties)
LOG.info("Found paths for volume %s", volume_paths)
if volume_paths:
return self._linuxscsi.extend_volume(volume_paths)
return self._linuxscsi.extend_volume(
volume_paths, use_multipath=self.use_multipath)
else:
LOG.warning("Couldn't find any volume paths on the host to "
"extend volume for %(props)s",

View File

@ -34,7 +34,7 @@ class NVMeConnector(base.BaseLinuxConnector):
"""Connector class to attach/detach NVMe over fabric volumes."""
def __init__(self, root_helper, driver=None,
def __init__(self, root_helper, driver=None, use_multipath=False,
device_scan_attempts=initiator.DEVICE_SCAN_ATTEMPTS_DEFAULT,
*args, **kwargs):
super(NVMeConnector, self).__init__(
@ -42,6 +42,7 @@ class NVMeConnector(base.BaseLinuxConnector):
driver=driver,
device_scan_attempts=device_scan_attempts,
*args, **kwargs)
self.use_multipath = use_multipath
@staticmethod
def get_connector_properties(root_helper, *args, **kwargs):
@ -182,7 +183,8 @@ class NVMeConnector(base.BaseLinuxConnector):
"""
volume_paths = self.get_volume_paths(connection_properties)
if volume_paths:
return self._linuxscsi.extend_volume(volume_paths)
return self._linuxscsi.extend_volume(
volume_paths, use_multipath=self.use_multipath)
else:
LOG.warning("Couldn't find any volume paths on the host to "
"extend volume for %(props)s",

View File

@ -531,7 +531,7 @@ class LinuxSCSI(executor.Executor):
root_helper=self._root_helper)
return out
def extend_volume(self, volume_paths):
def extend_volume(self, volume_paths, use_multipath=False):
"""Signal the SCSI subsystem to test for volume resize.
This function tries to signal the local system's kernel
@ -561,24 +561,26 @@ class LinuxSCSI(executor.Executor):
LOG.debug("volume size after scsi device rescan %s", new_size)
scsi_wwn = self.get_scsi_wwn(volume_paths[0])
mpath_device = self.find_multipath_device_path(scsi_wwn)
if mpath_device:
# Force a reconfigure so that resize works
self.multipath_reconfigure()
if use_multipath:
mpath_device = self.find_multipath_device_path(scsi_wwn)
if mpath_device:
# Force a reconfigure so that resize works
self.multipath_reconfigure()
size = self.get_device_size(mpath_device)
LOG.info("mpath(%(device)s) current size %(size)s",
{'device': mpath_device, 'size': size})
result = self.multipath_resize_map(scsi_wwn)
if 'fail' in result:
LOG.error("Multipathd failed to update the size mapping of "
"multipath device %(scsi_wwn)s volume %(volume)s",
{'scsi_wwn': scsi_wwn, 'volume': volume_paths})
return None
size = self.get_device_size(mpath_device)
LOG.info("mpath(%(device)s) current size %(size)s",
{'device': mpath_device, 'size': size})
result = self.multipath_resize_map(scsi_wwn)
if 'fail' in result:
LOG.error("Multipathd failed to update the size mapping "
"of multipath device %(scsi_wwn)s volume "
"%(volume)s",
{'scsi_wwn': scsi_wwn, 'volume': volume_paths})
return None
new_size = self.get_device_size(mpath_device)
LOG.info("mpath(%(device)s) new size %(size)s",
{'device': mpath_device, 'size': new_size})
new_size = self.get_device_size(mpath_device)
LOG.info("mpath(%(device)s) new size %(size)s",
{'device': mpath_device, 'size': new_size})
return new_size

View File

@ -36,7 +36,8 @@ class NVMeConnectorTestCase(test_connector.ConnectorTestCase):
def setUp(self):
super(NVMeConnectorTestCase, self).setUp()
self.connector = nvme.NVMeConnector(None,
execute=self.fake_execute)
execute=self.fake_execute,
use_multipath=False)
def _nvme_list_cmd(self, *args, **kwargs):
return FAKE_NVME_LIST_OUTPUT, None
@ -153,9 +154,11 @@ class NVMeConnectorTestCase(test_connector.ConnectorTestCase):
self.connector.extend_volume,
connection_properties)
@mock.patch.object(linuxscsi.LinuxSCSI, 'find_multipath_device_path')
@mock.patch.object(linuxscsi.LinuxSCSI, 'extend_volume')
@mock.patch.object(nvme.NVMeConnector, 'get_volume_paths')
def test_extend_volume(self, mock_volume_paths, mock_scsi_extend):
def test_extend_volume(self, mock_volume_paths, mock_scsi_extend,
mock_scsi_find_mpath):
fake_new_size = 1024
mock_volume_paths.return_value = ['/dev/vdx']
mock_scsi_extend.return_value = fake_new_size
@ -166,3 +169,4 @@ class NVMeConnectorTestCase(test_connector.ConnectorTestCase):
'transport_type': 'rdma'}
new_size = self.connector.extend_volume(connection_properties)
self.assertEqual(fake_new_size, new_size)
mock_scsi_find_mpath.assert_not_called()

View File

@ -761,7 +761,8 @@ loop0 0"""
mock_find_mpath_path.return_value = ('/dev/mapper/dm-uuid-mpath-%s' %
wwn)
ret_size = self.linuxscsi.extend_volume(['/dev/fake1', '/dev/fake2'])
ret_size = self.linuxscsi.extend_volume(['/dev/fake1', '/dev/fake2'],
use_multipath=True)
self.assertEqual(2048, ret_size)
# because we don't mock out the echo_scsi_command
@ -795,7 +796,8 @@ loop0 0"""
mock_mpath_resize_map.return_value = 'fail'
ret_size = self.linuxscsi.extend_volume(['/dev/fake1', '/dev/fake2'])
ret_size = self.linuxscsi.extend_volume(['/dev/fake1', '/dev/fake2'],
use_multipath=True)
self.assertIsNone(ret_size)
# because we don't mock out the echo_scsi_command