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 customizable disk_size to vm post-provision #22251

Merged
merged 1 commit into from Dec 8, 2022

Conversation

OrGur1987
Copy link
Contributor

@OrGur1987 OrGur1987 commented Nov 27, 2022

add the field to set_or_default_hardware_field_values, so that it would show the default template disk size

image

related PRs:
providers-vmware: ManageIQ/manageiq-providers-vmware#839

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

@OrGur1987
Copy link
Contributor Author

OrGur1987 commented Nov 27, 2022

the check failure here seems general and unrelated to the requested changes
https://github.com/ManageIQ/manageiq/actions/runs/3557641206/jobs/5975775349

Copy link
Member

@kbrock kbrock left a comment

Choose a reason for hiding this comment

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

@agrare - question around changing Hardware.used_disk_storage/allocated_disk_storage from referencing disks to hard_disks. hardware.rb

@OrGur1987 Question around changing to allocated_disk_storage or used

I did not have an opinion on the feature itself.

@@ -5,7 +5,8 @@ def set_or_default_hardware_field_values(vm)
:cpu_limit => vm.cpu_limit,
:memory_limit => vm.memory_limit,
:cpu_reserve => vm.cpu_reserve,
:memory_reserve => vm.memory_reserve
:memory_reserve => vm.memory_reserve,
:disk_size => vm.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.

A few things.

In hardware.rb I notice that we have a number of different device_type values called out but none are "disk" in particular. I can't imagine that this is a new concept. Maybe we want to use hard_disks instead?

size is the count of the disks (e.g.: 1-4), and / (1024**3) is definitely talking about disk storage (e.g.: 3.5 * 10^9), so there is a disconnect here.

I'm thinking allocated_disk_storage or used_disk_storage would work here. The desire to not display CDRom values in disk size makes me wonder if used_disk_storage should not disks.sum(:used_disk_storage) but hard_disks.sum(:used_disk_storage). (I'm not sure if we've tested a virtual sum with a where() clause, so we probably want to put a test in here and over in virtual_attributes gem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kbrock changed to allocated_disk_storage

Copy link
Member

Choose a reason for hiding this comment

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

@kbrock I think allocated_disk_storage is confusing here, this is the size of a single disk that we're going to be creating and isn't intended to map to any columns.

@OrGur1987 OrGur1987 force-pushed the 411361_vmware_disk_size branch 3 times, most recently from 1ab9741 to 9531be6 Compare November 29, 2022 11:51
@agrare agrare self-assigned this Nov 30, 2022
:memory_limit => vm.memory_limit,
:cpu_reserve => vm.cpu_reserve,
:memory_reserve => vm.memory_reserve,
:allocated_disk_storage => vm.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.

I know in the VMware PR we're discussing finding the "first" disk as an initial solution, that is relatively simple for a specific provider but it is going to be very tricky here since this code is common to all Infra providers.

In MiqProvisionVirtWorkflow#set_on_vm_id_changed we build a map of the NICs and LANs: https://github.com/ManageIQ/manageiq/blob/master/app/models/miq_provision_virt_workflow.rb#L137-L138

I wonder if we do the same with the template's disks and then we could more easily set a different size for each disk.

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 change this, but speaking of this code specifically:

  1. Prefer 1.gigabyte over 1024**3 for readability
  2. It would be better tot pass around bytes if we have it rather than GB, we can always convert to GB but not the other way around without losing precision (also if we're going to use GB should be a float e.g. if a user wants 1.5GB disk)

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 changed the field to string and now the user can input a float-like value.
regarding bytes, the .size attribute of a disk is indeed in bytes, but is converted to a human readable GB to provide the default value, and is received from the user in GB scale as well.
afterwards, VirtualDisk reconfiguration expects it in KB for dev.capacityInKB (in ManageIQ::Providers::Vmware::InfraManager::Provision::Configuration::Disk#set_disk_allocation).
so I'm not sure where in that flow will it be effective to convert it to bytes

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.

I know in the VMware PR we're discussing finding the "first" disk as an initial solution, that is relatively simple for a specific provider but it is going to be very tricky here since this code is common to all Infra providers.

In MiqProvisionVirtWorkflow#set_on_vm_id_changed we build a map of the NICs and LANs: https://github.com/ManageIQ/manageiq/blob/master/app/models/miq_provision_virt_workflow.rb#L137-L138

I wonder if we do the same with the template's disks and then we could more easily set a different size for each disk.

in line with the short-term fix you suggested in the vmware repo PR, the code now adds the default :allocated_disk_storage only when there's exactly 1 hard-disk.

@OrGur1987 OrGur1987 force-pushed the 411361_vmware_disk_size branch 3 times, most recently from ae5f5da to d5c2511 Compare November 30, 2022 16:51
… field to `set_or_default_hardware_field_values`
@miq-bot
Copy link
Member

miq-bot commented Nov 30, 2022

Checked commit Autosde@e82de23 with ruby 2.6.10, rubocop 1.28.2, haml-lint 0.35.0, and yamllint
2 files checked, 0 offenses detected
Everything looks fine. 🍰

@OrGur1987
Copy link
Contributor Author

hi @agrare @kbrock
any other change required?
the related PRs in the two other repos are already approved
thanks

@agrare
Copy link
Member

agrare commented Dec 6, 2022

@OrGur1987 core tests were broken yesterday so was waiting for that fix for the tests to pass on this PR

@agrare agrare closed this Dec 6, 2022
@agrare agrare reopened this Dec 6, 2022
@OrGur1987
Copy link
Contributor Author

@OrGur1987 core tests were broken yesterday so was waiting for that fix for the tests to pass on this PR

and does this PR pass the tests now?

@agrare
Copy link
Member

agrare commented Dec 8, 2022

I still think allocated_disk_storage is overly confusing and disk_size would be simpler but we can do that in a follow-up

@agrare agrare merged commit 2a05ed5 into ManageIQ:master Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants