Skip to content

Commit b62a1ab

Browse files
committed
libvirt: Use specific user when probing encrypted rbd disks during extend
I0c3f14100a18107f7e416293f3d4fcc641ce5e55 introduced new logic when extending LUKSv1 encrypted rbd volumes. As part of this qemu-img is used to probe the rbd volume to determine the size of the LUKSv1 header. The URI used to point to the rbd volume did not provide a user and assumed that n-cpu/privsep would have access to the admin keyring. This isn't always the case in most environments and would result in a failure to probe the disk when the admin keyring wasn't available. This change resolves this by appending the `id:$username` option to the end of the URI provided to qemu-img using the `auth_username` found in the connection_info from Cinder. Closes-Bug: #1913575 Change-Id: Ia6d6dcdd7042f2aef6b3abeb5cd0f7525678a3b7
1 parent b34a1ca commit b62a1ab

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
@@ -9767,6 +9767,8 @@ def test_extend_volume_luksv1_rbd(self, mock_qemu_img_info,
97679767
'serial': uuids.volume_id,
97689768
'driver_volume_type': 'rbd',
97699769
'data': {'name': 'pool/volume',
9770+
'auth_enabled': 'true',
9771+
'auth_username': 'username',
97709772
'access_mode': 'rw'}
97719773
}
97729774
disk_1 = mock.Mock(spec=vconfig.LibvirtConfigGuestDisk,
@@ -9808,7 +9810,8 @@ def test_extend_volume_luksv1_rbd(self, mock_qemu_img_info,
98089810

98099811
mock_get_encryption_metadata.assert_called_once_with(
98109812
self.context, drvr._volume_api, uuids.volume_id, connection_info)
9811-
mock_qemu_img_info.assert_called_once_with('rbd:pool/volume')
9813+
mock_qemu_img_info.assert_called_once_with(
9814+
'rbd:pool/volume:id=username')
98129815

98139816
# Assert that the Libvirt call to resize the device within the instance
98149817
# 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
@@ -2097,7 +2097,11 @@ def _resize_attached_encrypted_volume(self, original_new_size,
20972097
if 'device_path' in connection_info['data']:
20982098
path = connection_info['data']['device_path']
20992099
elif connection_info['driver_volume_type'] == 'rbd':
2100-
path = 'rbd:%s' % (connection_info['data']['name'])
2100+
volume_name = connection_info['data']['name']
2101+
path = f"rbd:{volume_name}"
2102+
if connection_info['data'].get('auth_enabled'):
2103+
username = connection_info['data']['auth_username']
2104+
path = f"rbd:{volume_name}:id={username}"
21012105
else:
21022106
path = 'unknown'
21032107
raise exception.DiskNotFound(location='unknown')

0 commit comments

Comments
 (0)