Skip to content

Commit f9b6789

Browse files
committed
compute: Skip cinder_encryption_key_id check when booting from volume
Idf84ccff254d26fa13473fe9741ddac21cbcf321 added this check in order for Nova to avoid booting encrypted images created by Cinder as there is currently no support for using such images (rotating keys etc). The check however missed the slightly convoluted use case where this image property is found against a volume after the volume in question is created using an encrypted image created by cinder from an encrypted volume. In other words: - Cinder creates an encrypted volume A - Glance creates an encrypted image A from volume A - Cinder creates an encrypted volume B from image A - Nova attempts to boot an instance using volume B Note that Nova may request the creation of volume B or a user could also do this directly through Cinder. As such this change simply ensures that the instance isn't booting from a volume when preforming the check as it is only valid when booting from an image. Closes-Bug: #1895696 Change-Id: Ic92cab7362fa25050e5bbef5c3e360108365b5c7
1 parent e76cccd commit f9b6789

File tree

2 files changed

+12
-19
lines changed

2 files changed

+12
-19
lines changed

nova/compute/api.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,12 @@ def _detect_nonbootable_image_from_properties(image_id, image):
627627
return
628628

629629
image_properties = image.get('properties', {})
630-
if image_properties.get('cinder_encryption_key_id'):
630+
# NOTE(lyarwood) Skip this check when image_id is None indicating that
631+
# the instance is booting from a volume that was itself initially
632+
# created from an image. As such we don't care if
633+
# cinder_encryption_key_id was against the original image as we are now
634+
# booting from an encrypted volume.
635+
if image_properties.get('cinder_encryption_key_id') and image_id:
631636
reason = _('Direct booting of an image uploaded from an '
632637
'encrypted volume is unsupported.')
633638
raise exception.ImageUnacceptable(image_id=image_id,

nova/tests/functional/regressions/test_bug_1895696.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,9 @@ def test_nonbootable_metadata_bfv_image_metadata(self):
122122
'volume_size': 1,
123123
}]
124124

125-
# FIXME(lyarwood) n-api should ignore cinder_encryption_key_id in the
126-
# original image in this case and accept the request.
127-
ex = self.assertRaises(
128-
client.OpenStackApiException, self.api.post_server,
129-
{'server': server})
130-
self.assertEqual(400, ex.response.status_code)
131-
self.assertIn(
132-
"Direct booting of an image uploaded from an encrypted volume is "
133-
"unsupported", str(ex))
125+
# Assert that this request is accepted and the server moves to ACTIVE
126+
server = self.api.post_server({'server': server})
127+
self._wait_for_state_change(server, 'ACTIVE')
134128

135129
def test_nonbootable_metadata_bfv_volume_image_metadata(self):
136130
"""Assert behaviour when c-api has created volume using encrypted image
@@ -147,12 +141,6 @@ def test_nonbootable_metadata_bfv_volume_image_metadata(self):
147141
'uuid': uuids.cinder_encrypted_volume_uuid,
148142
}]
149143

150-
# FIXME(lyarwood) n-api should ignore cinder_encryption_key_id in the
151-
# volume volume_image_metadata in this case and accept the request.
152-
ex = self.assertRaises(
153-
client.OpenStackApiException, self.api.post_server,
154-
{'server': server})
155-
self.assertEqual(400, ex.response.status_code)
156-
self.assertIn(
157-
"Direct booting of an image uploaded from an encrypted volume is "
158-
"unsupported", str(ex))
144+
# Assert that this request is accepted and the server moves to ACTIVE
145+
server = self.api.post_server({'server': server})
146+
self._wait_for_state_change(server, 'ACTIVE')

0 commit comments

Comments
 (0)