Skip to content
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

Add the volume to the root disk (vda) if the selected flavor has a ro… #894

Merged
merged 4 commits into from
Dec 10, 2024

Conversation

Dhamo1107
Copy link
Contributor

@Dhamo1107 Dhamo1107 commented Oct 19, 2024

This Pull Request addresses the handling of root disk provisioning when using flavors with a root disk size of 0. Specifically, if a flavor has a root disk size of 0, the volume provided during provisioning will be designated as the root disk (vda). Conversely, if the flavor has a non-zero root disk size (e.g., 100GB), the specified volume will be treated as an additional volume (vdb).

Before the change:

  • Volume specified during provisioning would not be correctly set as the root disk when using a 0 root disk size flavor (10GB volume specified on the add volume page is assigned under vdb).
    image

After the change:

  • Volume specified during provisioning is correctly assigned as the root disk (vda) if the flavor's root disk size is 0 (25GB volume specified on the add volume page is assigned under vda).
    image

  • Additional volumes specified will automatically come under vdb when the flavor has a root disk size greater than 0 (With a 100GB root disk size flavor, the root disk is assigned under vda, while the 50GB volume specified on the add volume page is assigned under vdb).
    image

Fixes #892

@agrare
Copy link
Member

agrare commented Oct 24, 2024

We should have spec tests covering this new case, I'll write some up and push to your branch if that is okay with you @Dhamo1107

@agrare
Copy link
Member

agrare commented Oct 24, 2024

Specs look like they fail to start due to ManageIQ/manageiq-schema#757 this should be resolved shortly

@agrare
Copy link
Member

agrare commented Oct 24, 2024

Since I have a significant amount of (test) code in here now I'm going to assign to @Fryguy

@Fryguy I refactored the openstack volume_attachment specs to make it easier to write the following tests in a separate commit (79b51f4), then this commit adds tests (8eb0bdc)

@agrare agrare assigned Fryguy and unassigned agrare Oct 24, 2024
@agrare agrare added the bug label Oct 24, 2024
Comment on lines +8 to +9
if instance_type.root_disk_size == 0 # Handle root disk logic only when root_disk_size is 0
if index == 0 # The first volume should be the root disk, typically assigned to vda
Copy link
Member

@agrare agrare Oct 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be better done up above like

     # Handle root disk logic only when root_disk_size is 0
    if instance_type.root_disk_size > 0
      volumes_attrs_list = [default_volume_attributes]
    else
      volumes_attrs_list = []
      # The first volume should be the root disk, typically assigned to vda
      requested_volumes.first&.merge!(:imageRef => source.ems_ref, :bootable => true, :boot_index => 0)
    end

NOTE do the other requested volumes have to have boot_index = -1? It doesn't appear that they did before.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like the -1, but if that we there previously, then it's fine. I would think null would be a better choice.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like the -1, but if that we there previously, then it's fine. I would think null would be a better choice.

I don't think that is a choice since these volume_attrs are for fog-openstack volume create. From https://docs.openstack.org/nova/rocky/user/launch-instance-from-volume.html I don't see any mention of -1 so I'm going to drop this part so we can try to get this in.

@agrare agrare force-pushed the add-volume-to-root-disk branch from 835a879 to 8eb0bdc Compare October 24, 2024 15:31
@agrare agrare closed this Oct 24, 2024
@agrare agrare reopened this Oct 24, 2024
allow(service).to receive_message_chain('volumes.create').and_return @volume
allow(@task.source.ext_management_system).to receive(:with_provider_connection)\
before do
allow(service).to receive_message_chain('volumes.create').and_return(volume)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this was here already, but I generally prefer

Suggested change
allow(service).to receive_message_chain('volumes.create').and_return(volume)
allow(service).to receive_message_chain(:volumes, :create).and_return(volume)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it was here previously, I do have a "cleanup specs" commit in here already though so I'd rather change all of them to be consistent

@Fryguy
Copy link
Member

Fryguy commented Oct 30, 2024

Overall LGTM- have one question about -1 vs null

@agrare agrare force-pushed the add-volume-to-root-disk branch from 8eb0bdc to 687edb5 Compare October 30, 2024 13:31
Dhamo1107 and others added 3 commits December 10, 2024 09:04
…ot disk size of 0 during instance provisioning
This spec made heavy use of instance vars rather than `let()` which
makes it more difficult to override these in sub-contexts.
If a flavor has no root disk we have to set up the bootable volume
manually based on the first requested volume.
@agrare agrare force-pushed the add-volume-to-root-disk branch from 687edb5 to 1c76db5 Compare December 10, 2024 14:09
@agrare
Copy link
Member

agrare commented Dec 10, 2024

@Fryguy I forgot this was still open, if I drop the -1 are you good with this?

@agrare agrare force-pushed the add-volume-to-root-disk branch from 1c76db5 to b5f9b0f Compare December 10, 2024 14:11
@Fryguy Fryguy merged commit 12c8aa3 into ManageIQ:master Dec 10, 2024
1 check passed
@agrare
Copy link
Member

agrare commented Dec 10, 2024

Thanks @Dhamo1107 for starting this, if you get a chance can you confirm that my changes still work for you?

@Dhamo1107
Copy link
Contributor Author

Sure @agrare I'll confirm it by tomorrow

@Dhamo1107
Copy link
Contributor Author

Hi @agrare, I’ve tested the changes, and they’re working correctly on my end!

@agrare
Copy link
Member

agrare commented Dec 11, 2024

Awesome great news thanks @Dhamo1107 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issue in provisioning instance with zero root disk flavor in OpenStack
3 participants