Fix paths for NVMe devices (non-nguid)
Fixed regression introduced by
https://review.opendev.org/c/openstack/os-brick/+/800014, where
connect_volume method returned a list with a single path instead of
just the path.
Closes-Bug: #1945323
Change-Id: I5e5b13dd73ab8d30439de76dd73eb41b763e7f05
(cherry picked from commit dd90bb6356
)
This commit is contained in:
parent
4c9317e2b2
commit
36f12c05a7
|
@ -194,7 +194,7 @@ class NVMeOFConnector(base.BaseLinuxConnector):
|
|||
path = set(all_nvme_devices) - set(current_nvme_devices)
|
||||
if not path:
|
||||
raise exception.VolumePathsNotFound()
|
||||
return list(path)
|
||||
return list(path)[0]
|
||||
|
||||
@utils.retry(exception.VolumeDeviceNotFound)
|
||||
def _get_device_path_by_nguid(self, nguid):
|
||||
|
@ -205,14 +205,14 @@ class NVMeOFConnector(base.BaseLinuxConnector):
|
|||
LOG.debug("Try to retrieve symlink to %(device_path)s.",
|
||||
{"device_path": device_path})
|
||||
try:
|
||||
paths, _err = self._execute('readlink',
|
||||
'-e',
|
||||
device_path,
|
||||
run_as_root=True,
|
||||
root_helper=self._root_helper)
|
||||
if not paths:
|
||||
path, _err = self._execute('readlink',
|
||||
'-e',
|
||||
device_path,
|
||||
run_as_root=True,
|
||||
root_helper=self._root_helper)
|
||||
if not path:
|
||||
raise exception.VolumePathsNotFound()
|
||||
return paths.split()[0]
|
||||
return path.rstrip()
|
||||
except putils.ProcessExecutionError as e:
|
||||
LOG.exception(e)
|
||||
raise exception.VolumeDeviceNotFound(device=device_path)
|
||||
|
|
|
@ -214,6 +214,23 @@ class NVMeOFConnectorTestCase(test_connector.ConnectorTestCase):
|
|||
root_helper=None,
|
||||
run_as_root=True)
|
||||
|
||||
@mock.patch.object(nvmeof.NVMeOFConnector, '_get_nvme_devices')
|
||||
def test__get_device_path(self, mock_nvme_devices):
|
||||
mock_nvme_devices.return_value = ['/dev/nvme0n1',
|
||||
'/dev/nvme1n1',
|
||||
'/dev/nvme0n2']
|
||||
current_devices = ['/dev/nvme0n1', '/dev/nvme0n2']
|
||||
self.assertEqual(self.connector._get_device_path(current_devices),
|
||||
'/dev/nvme1n1')
|
||||
|
||||
@mock.patch.object(nvmeof.NVMeOFConnector, '_get_nvme_devices')
|
||||
def test__get_device_path_no_new_device(self, mock_nvme_devices):
|
||||
current_devices = ['/dev/nvme0n1', '/dev/nvme0n2']
|
||||
mock_nvme_devices.return_value = current_devices
|
||||
self.assertRaises(exception.VolumePathsNotFound,
|
||||
self.connector._get_device_path,
|
||||
current_devices)
|
||||
|
||||
@mock.patch.object(nvmeof.NVMeOFConnector, '_execute', autospec=True)
|
||||
def test__get_device_path_by_nguid(self, mock_execute):
|
||||
mock_execute.return_value = '/dev/nvme0n1\n', None
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
NVMe-oF connector `bug #1945323
|
||||
<https://bugs.launchpad.net/os-brick/+bug/1945323>`_ [bugs.launchpad.net]: Fixed a regression
|
||||
where connect_volume returned a list with a single path instead of just the path
|
Loading…
Reference in New Issue