RBD: Fix disconnect_volume for encrypted volumes
After change Ie373ab050dcc0a35c749d9a53b6cf5ca060bcb58 closing bugs
connector was broken for encrypted volumes:
<== disconnect_volume:
exception (0ms) AttributeError("'RBDVolumeIOWrapper' object has
no attribute 'startswith'") trace_logging_wrapper
/usr/lib/python3.9/site-packages/os_brick/utils.py:162
This hapens because "_device_path_from_symlink" doesn't take into
account of the file handle, and we were missing a unit test for this
case.
Closes-Bug: #1981455
Change-Id: Ib001e2b4d1347754c2b46730bc10d86e8cdab7ad
(cherry picked from commit dde8f102b7
)
This commit is contained in:
parent
0bd5dc9915
commit
743002cc26
|
@ -388,6 +388,12 @@ class ConnectionPropertiesDecoratorsTestCase(base.TestCase):
|
||||||
res = utils._device_path_from_symlink(symlink)
|
res = utils._device_path_from_symlink(symlink)
|
||||||
self.assertEqual('/dev/md/alias', res)
|
self.assertEqual('/dev/md/alias', res)
|
||||||
|
|
||||||
|
def test__device_path_from_symlink_file_handle(self):
|
||||||
|
"""Get device name for a file handle (eg: RBD)."""
|
||||||
|
handle = io.StringIO()
|
||||||
|
res = utils._device_path_from_symlink(handle)
|
||||||
|
self.assertEqual(handle, res)
|
||||||
|
|
||||||
@ddt.data(({}, {'type': 'block', 'path': '/dev/sda'}),
|
@ddt.data(({}, {'type': 'block', 'path': '/dev/sda'}),
|
||||||
({'encrypted': False}, {'type': 'block', 'path': '/dev/sda'}),
|
({'encrypted': False}, {'type': 'block', 'path': '/dev/sda'}),
|
||||||
({'encrypted': False}, {'type': 'block', 'path': b'/dev/sda'}),
|
({'encrypted': False}, {'type': 'block', 'path': b'/dev/sda'}),
|
||||||
|
|
|
@ -257,7 +257,8 @@ def _device_path_from_symlink(symlink):
|
||||||
This is the reverse operation of the one performed by the
|
This is the reverse operation of the one performed by the
|
||||||
_symlink_name_from_device_path method.
|
_symlink_name_from_device_path method.
|
||||||
"""
|
"""
|
||||||
if symlink and symlink.startswith(CUSTOM_LINK_PREFIX):
|
if (symlink and isinstance(symlink, str)
|
||||||
|
and symlink.startswith(CUSTOM_LINK_PREFIX)):
|
||||||
ending = symlink[len(CUSTOM_LINK_PREFIX):]
|
ending = symlink[len(CUSTOM_LINK_PREFIX):]
|
||||||
return ending.replace('+', '/')
|
return ending.replace('+', '/')
|
||||||
return symlink
|
return symlink
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- |
|
||||||
|
RBD connector `bug #1981455
|
||||||
|
<https://bugs.launchpad.net/cinder/+bug/1981455>`_: Fixed AttributeError
|
||||||
|
error on disconnect for RBD encrypted volumes not using host attachments.
|
Loading…
Reference in New Issue