-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enforce boot-from-volume via flavor #190
base: stable/rocky-m3
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See some stylistic comments below:
@@ -8774,6 +8774,81 @@ def test_create_instance_associates_security_groups(self): | |||
self.assertEqual(1, len(reqspec.security_groups)) | |||
self.assertEqual(group.name, reqspec.security_groups[0].name) | |||
|
|||
def test_create_instance_enforced_bfv(self): | |||
# Tests that, if a user creates a instance from an image, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Tests that, if a user creates a instance from an image, | |
# Tests that, if a user creates an instance from an image, |
nova/compute/api.py
Outdated
return | ||
elif (root_bdm.get('destination_type') == 'local' and | ||
root_bdm.get('source_type') == 'image'): | ||
# In this case overwrite the image mapping to a volume. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment feels redundant and/or possibly misleading. I guess it's supposed to describe what's happening in all the rest of the function, but it looks like it's only describing the next line.
The code does describe itself well enough without this comment.
The other comment above is not quite as obvious, but the early return
is a pretty strong indicator of "we're done early here". Personally, I'd also remove it.
nova/compute/api.py
Outdated
elif (root_bdm.get('destination_type') == 'local' and | ||
root_bdm.get('source_type') == 'image'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd switch the order here. Source -> Destination.
Or even refactor out into a separate variable or function that describes what this combination of conditions actually means. I read in the docs that image -> local is special for booting directly from a Glance image(?), and this could be made more explicit here.
Two other questions:
|
I skimmed through the spec and from the problem-to-solve it seems to be the same. The spec is just not as restrictive as we want to be. We want to *force` BFV while the spec wants to default to BFV but allow the user to override it. |
The point of this is prohibiting use of ephemeral storage, because we will not have any. Therefore, anything having the destination "local" needs to be prohibited. In the docs you link, I only see 2 options that don't have |
read_deleted="yes"): | ||
instance_type = orig_get_flavor_by_flavor_id(flavor_id, | ||
ctxt, | ||
read_deleted) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines don't look like they're indented correctly. Is this only github?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think it is a Github issue. pep8 passes.
nova/compute/api.py
Outdated
elif (root_bdm.get('source_type') == 'image' and | ||
root_bdm.get('destination_type') == 'local'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As Jakob pointed out, there could be a blank disk/swap disk added via blank -> local
. We don't support ephemeral storage and thus also cannot support that case. Anything requesting destination_type == 'local'
needs to be prohibited.
nova/compute/api.py
Outdated
self._enforce_boot_from_volume(image_meta, instance_type, | ||
block_device_mapping) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't the above-called block_device.from_legacy_mapping()
already add the image-bdm?
Lines 355 to 356 in 5b05204
if not volume_backed and image_uuid: | |
image_bdm = create_image_bdm(image_uuid, boot_index=0) |
The flavor would then be unusable ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, right. This worked well initially, when the image mapping was silently overwritten to a volume mapping.
But now since we throw an error, it will indeed make it unusable. I'll revisit this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please have another look. Thanks.
511b92c
to
949dfee
Compare
Booting from volume can now be enforced via flavor. A flavor must have extra property `boot_from_volume=true` to enable this. It works by enforcing a boot_index=0 block device mapping based on the source image, like the user would have requested it. If the user specifies a root volume explicitly, this enforcement will be skipped.
Booting from volume can now be enforced via flavor.
A flavor must have extra property
boot_from_volume=true
toenable this.
It works by enforcing a boot_index=0 block device mapping based on
the source image, like the user would have requested it.
If the user specifies a root volume explicitly, this enforcement
will be skipped.