Merge "Fix multipath resize map with friendly names"

This commit is contained in:
Zuul 2023-08-17 00:56:26 +00:00 committed by Gerrit Code Review
commit 0a5d4c1506
3 changed files with 33 additions and 16 deletions

View File

@ -565,8 +565,8 @@ class LinuxSCSI(executor.Executor):
root_helper=self._root_helper)
return out
def _multipath_resize_map(self, mpath_id):
cmd = ('multipathd', 'resize', 'map', mpath_id)
def _multipath_resize_map(self, dm_path):
cmd = ('multipathd', 'resize', 'map', dm_path)
(out, _err) = self._execute(*cmd,
run_as_root=True,
root_helper=self._root_helper)
@ -577,11 +577,13 @@ class LinuxSCSI(executor.Executor):
return out
def multipath_resize_map(self, mpath_id):
def multipath_resize_map(self, dm_path):
"""Issue a multipath resize map on device.
This forces the multipath daemon to update it's
size information a particular multipath device.
:param dm_path: Real path of the DM device (eg: /dev/dm-5)
"""
# "multipathd reconfigure" is async since 0.6.1. While the
@ -590,7 +592,7 @@ class LinuxSCSI(executor.Executor):
tstart = time.time()
while True:
try:
self._multipath_resize_map(mpath_id)
self._multipath_resize_map(dm_path)
break
except putils.ProcessExecutionError as err:
with excutils.save_and_reraise_exception(reraise=True) as ctx:
@ -646,7 +648,7 @@ class LinuxSCSI(executor.Executor):
LOG.info("mpath(%(device)s) current size %(size)s",
{'device': mpath_device, 'size': size})
self.multipath_resize_map(scsi_wwn)
self.multipath_resize_map(os.path.realpath(mpath_device))
new_size = utils.get_device_size(self, mpath_device)
LOG.info("mpath(%(device)s) new size %(size)s",

View File

@ -765,9 +765,9 @@ loop0 0"""
self.assertEqual(expected_commands, self.cmds)
def test_multipath_resize_map(self):
wwn = '1234567890123456'
self.linuxscsi.multipath_resize_map(wwn)
expected_commands = ['multipathd resize map %s' % wwn]
dm_path = '/dev/dm-5'
self.linuxscsi.multipath_resize_map(dm_path)
expected_commands = ['multipathd resize map %s' % dm_path]
self.assertEqual(expected_commands, self.cmds)
@mock.patch.object(linuxscsi.LinuxSCSI, 'find_multipath_device_path')
@ -804,7 +804,9 @@ loop0 0"""
@mock.patch.object(linuxscsi.LinuxSCSI, 'get_scsi_wwn')
@mock.patch('os_brick.utils.get_device_size')
@mock.patch.object(linuxscsi.LinuxSCSI, 'get_device_info')
def test_extend_volume_with_mpath(self, mock_device_info,
@mock.patch('os.path.realpath')
def test_extend_volume_with_mpath(self, mock_realpath,
mock_device_info,
mock_device_size,
mock_scsi_wwn,
mock_find_mpath_path):
@ -817,8 +819,10 @@ loop0 0"""
mock_device_size.side_effect = [1024, 2048, 1024, 2048, 1024, 2048]
wwn = '1234567890123456'
mock_scsi_wwn.return_value = wwn
mock_find_mpath_path.return_value = ('/dev/mapper/dm-uuid-mpath-%s' %
wwn)
mpath_path = ('/dev/mapper/dm-uuid-mpath-%s' % wwn)
mock_find_mpath_path.return_value = mpath_path
dm_path = '/dev/dm-5'
mock_realpath.return_value = dm_path
ret_size = self.linuxscsi.extend_volume(['/dev/fake1', '/dev/fake2'],
use_multipath=True)
@ -828,8 +832,9 @@ loop0 0"""
expected_cmds = ['tee -a /sys/bus/scsi/drivers/sd/0:0:0:1/rescan',
'tee -a /sys/bus/scsi/drivers/sd/1:0:0:1/rescan',
'multipathd reconfigure',
'multipathd resize map %s' % wwn]
'multipathd resize map %s' % dm_path]
self.assertEqual(expected_cmds, self.cmds)
mock_realpath.assert_called_once_with(mpath_path)
@mock.patch.object(linuxscsi.LinuxSCSI, '_multipath_resize_map')
@mock.patch.object(linuxscsi.LinuxSCSI, 'find_multipath_device_path')
@ -874,7 +879,9 @@ loop0 0"""
@mock.patch.object(linuxscsi.LinuxSCSI, 'get_scsi_wwn')
@mock.patch('os_brick.utils.get_device_size')
@mock.patch.object(linuxscsi.LinuxSCSI, 'get_device_info')
def test_extend_volume_with_mpath_pending(self, mock_device_info,
@mock.patch('os.path.realpath')
def test_extend_volume_with_mpath_pending(self, mock_realpath,
mock_device_info,
mock_device_size,
mock_scsi_wwn,
mock_find_mpath_path,
@ -889,8 +896,10 @@ loop0 0"""
mock_device_size.side_effect = [1024, 2048, 1024, 2048, 1024, 2048]
wwn = '1234567890123456'
mock_scsi_wwn.return_value = wwn
mock_find_mpath_path.return_value = ('/dev/mapper/dm-uuid-mpath-%s' %
wwn)
mpath_path = ('/dev/mapper/dm-uuid-mpath-%s' % wwn)
mock_find_mpath_path.return_value = mpath_path
dm_path = '/dev/dm-5'
mock_realpath.return_value = dm_path
mock_mpath_resize_map.side_effect = (
putils.ProcessExecutionError(stdout="timeout"),
"success")
@ -904,7 +913,8 @@ loop0 0"""
'tee -a /sys/bus/scsi/drivers/sd/1:0:0:1/rescan',
'multipathd reconfigure']
self.assertEqual(expected_cmds, self.cmds)
mock_mpath_resize_map.assert_has_calls([mock.call(wwn)] * 2)
mock_mpath_resize_map.assert_has_calls([mock.call(dm_path)] * 2)
mock_realpath.assert_called_once_with(mpath_path)
@mock.patch('time.sleep')
@mock.patch('time.time')

View File

@ -0,0 +1,5 @@
---
fixes:
- |
`Bug #1609753 <https://bugs.launchpad.net/os-brick/+bug/1609753>`_: Fixed
resizing multipath device when user friendly names are ON.