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 a customizable disk_size field to vm post-provision #839

Merged
merged 1 commit into from Dec 8, 2022

Conversation

OrGur1987
Copy link
Contributor

add a customizable disk_size field to vm post-provision, including refactoring to separate between container reconfiguration (memory, CPU) and disk resize.

related PRs:
manageiq: ManageIQ/manageiq#22251

ui-classic: ManageIQ/manageiq-ui-classic#8547

@OrGur1987
Copy link
Contributor Author

OrGur1987 commented Nov 27, 2022

any chance we could overlook these "similar code" issues?
https://codeclimate.com/github/ManageIQ/manageiq-providers-vmware/pull/839

the issues here too were "inherited" from the original code
#839 (comment)

@agrare agrare self-assigned this Nov 28, 2022
@@ -107,8 +107,7 @@ def get_next_device_idx
@new_device_idx -= 1
end

def set_cpu_and_memory_allocation(vm)
config_spec = VimHash.new("VirtualMachineConfigSpec") do |vmcs|
def set_cpu_and_memory_allocation(vmcs)
vmcs.cpuAllocation = VimHash.new("ResourceAllocationInfo") do |rai|
Copy link
Member

Choose a reason for hiding this comment

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

It looks like the indentation is off here now that we dropped the config_spec = VimHash.new("VirtualMachineConfigSpec") do |vmcs| above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

# Do we need to perform a post-clone hardware reconfigure on the new VM?
[:cpu_limit, :memory_limit, :cpu_reserve, :memory_reserve].any? do |k|
return false unless options.key?(k)
destination.send(k) != options[k]
end
end

def reconfigure_disk_on_destination?(destination)
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 think you need to pass destination in since it is an association on this class (and it wasn't passed in for the old reconfigure_hardware_on_destination?)

Copy link
Member

Choose a reason for hiding this comment

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

I think we should return false unless options.key?(:disk_size) otherwise you'll be comparing nil to default_size if it isn't passed

@agrare
Copy link
Member

agrare commented Nov 28, 2022

@OrGur1987 overall looking very good, and don't worry about the codeclimate/rubocop warnings I'll let you know if there are issues that need to be fixed.

@agrare
Copy link
Member

agrare commented Nov 28, 2022

I gave this a quick test on a live VC and confirmed that this will reconfigure the resulting VM to resize the disk prior to powering the VM on.

@OrGur1987 I'm thinking we'll want to add the :disk_size option to the other content/miq_dialogs and in the future we can have it as an option on the normal provision dialog as well.

# Do we need to perform a post-clone hardware reconfigure on the new VM?
[:cpu_limit, :memory_limit, :cpu_reserve, :memory_reserve].any? do |k|
return false unless options.key?(k)
destination.send(k) != options[k]
end
end

def reconfigure_disk_on_destination?(destination)
default_size = destination.hardware.disks.find_by(:device_type => "disk").size / (1024**3)
Copy link
Member

Choose a reason for hiding this comment

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

We're going to need to decide how we want to handle multiple disks.

I could see by default this only works with the boot disk, but we could allow passing additional disk sizes by specifying the device_name/location

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I gave this a quick test on a live VC and confirmed that this will reconfigure the resulting VM to resize the disk prior to powering the VM on.

@OrGur1987 I'm thinking we'll want to add the :disk_size option to the other content/miq_dialogs and in the future we can have it as an option on the normal provision dialog as well.

I added it to the rest of the yamls, but not sure how to check that they work.
do these yamls have their own hamls that must be adjusted, or do the changes I already made in ui-classic cover this?

We're going to need to decide how we want to handle multiple disks.

I could see by default this only works with the boot disk, but we could allow passing additional disk sizes by specifying the device_name/location

do you want me to add this in this PR or is it for a future enhancement?

Copy link
Member

Choose a reason for hiding this comment

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

I think we need to deal with it in this PR, since the return order of records isn't guaranteed using find_by with multiple matching records can produce erratic results and we could end up making a second or third disk dramatically smaller by accident.

I think the quickest fix for this in the short term is to only allow changing the disk size if there is 1 disk on the template. We can doc this and work on improving it going forward.

The intermediate fix would be to sort disks by Hard Disk X and apply the disk_size to the "first" disk only.

Longer term allowing users to specify different disk sizes for each of the disks on the template would be nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks!
I'll work on the short term fix, can't promise I'll be available to contribute to the intermediate and long term ones :)

Copy link
Member

Choose a reason for hiding this comment

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

Yeah of course not a problem this is a huge start we can pick it up from there

Copy link
Contributor Author

@OrGur1987 OrGur1987 Nov 30, 2022

Choose a reason for hiding this comment

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

reconfigure_disk_on_destination? now checks if there's more than one hard disk, and if so logs that it's not currently supported and returns false.

provision_spec.rb tests this condition

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hi @agrare
is the recent update ok?

@OrGur1987 OrGur1987 force-pushed the 411361_vmware_disk_size branch 6 times, most recently from 21261d4 to 54a49ef Compare November 30, 2022 17:11
… including refactoring to separate between container reconfiguration (memory, CPU) and disk resize
@miq-bot
Copy link
Member

miq-bot commented Nov 30, 2022

Checked commit Autosde@ec33f2e with ruby 2.6.10, rubocop 1.28.2, haml-lint 0.35.0, and yamllint
12 files checked, 2 offenses detected

app/models/manageiq/providers/vmware/infra_manager/provision/configuration.rb

app/models/manageiq/providers/vmware/infra_manager/provision/configuration/container.rb

@agrare agrare closed this Dec 8, 2022
@agrare agrare reopened this Dec 8, 2022
@agrare agrare merged commit db73578 into ManageIQ:master Dec 8, 2022
@Fryguy Fryguy added this to the Petrosian milestone Sep 14, 2023
@Fryguy Fryguy added this to Petrosian in Roadmap Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Roadmap
  
Petrosian
Development

Successfully merging this pull request may close these issues.

None yet

4 participants