Skip to content

Commit abdcee8

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "libvirt: Use specific user when probing encrypted rbd disks during extend"
2 parents 0c53f4b + b62a1ab commit abdcee8

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

nova/tests/unit/virt/libvirt/test_driver.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9764,6 +9764,8 @@ def test_extend_volume_luksv1_rbd(self, mock_qemu_img_info,
97649764
'serial': uuids.volume_id,
97659765
'driver_volume_type': 'rbd',
97669766
'data': {'name': 'pool/volume',
9767+
'auth_enabled': 'true',
9768+
'auth_username': 'username',
97679769
'access_mode': 'rw'}
97689770
}
97699771
disk_1 = mock.Mock(spec=vconfig.LibvirtConfigGuestDisk,
@@ -9805,7 +9807,8 @@ def test_extend_volume_luksv1_rbd(self, mock_qemu_img_info,
98059807

98069808
mock_get_encryption_metadata.assert_called_once_with(
98079809
self.context, drvr._volume_api, uuids.volume_id, connection_info)
9808-
mock_qemu_img_info.assert_called_once_with('rbd:pool/volume')
9810+
mock_qemu_img_info.assert_called_once_with(
9811+
'rbd:pool/volume:id=username')
98099812

98109813
# Assert that the Libvirt call to resize the device within the instance
98119814
# is called with the LUKSv1 payload offset taken into account.

nova/virt/libvirt/driver.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2056,7 +2056,11 @@ def _resize_attached_encrypted_volume(self, original_new_size,
20562056
if 'device_path' in connection_info['data']:
20572057
path = connection_info['data']['device_path']
20582058
elif connection_info['driver_volume_type'] == 'rbd':
2059-
path = 'rbd:%s' % (connection_info['data']['name'])
2059+
volume_name = connection_info['data']['name']
2060+
path = f"rbd:{volume_name}"
2061+
if connection_info['data'].get('auth_enabled'):
2062+
username = connection_info['data']['auth_username']
2063+
path = f"rbd:{volume_name}:id={username}"
20602064
else:
20612065
path = 'unknown'
20622066
raise exception.DiskNotFound(location='unknown')

0 commit comments

Comments
 (0)