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

api: EnsureDisksHaveControllers helper #3474

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

akutz
Copy link
Member

@akutz akutz commented Jun 20, 2024

Description

This patch adds a function for ensuring all disks in a ConfigSpec point to a valid controller.

Closes: NA

Type of change

Please mark options that are relevant:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Build related change

How Has This Been Tested?

  • The command go test -v -count 1 -run 'TestVirtualMachineConfigSpec/EnsureDisksHaveControllers' ./vim25/types produced the following output:

    === RUN   TestVirtualMachineConfigSpec
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/nil_configSpec_arg_should_return_an_error
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/do_nothing_if_configSpec_has_no_disks
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/do_nothing_if_configSpec_has_a_disk,_but_it_is_being_removed
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/do_nothing_if_configSpec_has_a_disk,_but_it_is_already_attached_to_a_controller_from_existing_devices
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_and_there_is_a_nil_base_device_change_in_ConfigSpec_and_existing_device_includes_only_PCI_controller
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_and_there_is_a_nil_device_change_in_ConfigSpec_and_existing_device_includes_only_PCI_controller
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_and_there_is_a_nil_base_device_in_ConfigSpec_and_existing_device_includes_only_PCI_controller
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_and_there_is_a_nil_device_in_ConfigSpec_and_existing_device_includes_only_PCI_controller
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_and_existing_device_includes_PCI_controller_and_nil_base_device
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_and_existing_device_includes_PCI_controller_and_nil_device
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_while_removing_SATA_controller_and_existing_device_includes_only_PCI_controller
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_that_references_SATA_controller_being_removed_and_existing_device_includes_only_PCI_controller
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_that_references_non-existent_controller_and_existing_device_includes_only_PCI_controller
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_sans_controller_and_no_existing_devices
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_PCI_controller_and_disk_sans_controller_and_no_existing_devices
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_sans_controller_and_existing_devices_only_includes_PCI_controller
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_existing_controller_when_adding_disk_and_existing_devices_includes_PCI_and_PVSCSI_controllers
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_existing_controller_when_adding_disk_and_existing_devices_includes_PCI_and_Bus_Logic_controllers
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_existing_controller_when_adding_disk_and_existing_devices_includes_PCI_and_LSI_Logic_controllers
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_existing_controller_when_adding_disk_and_existing_devices_includes_PCI_and_LSI_Logic_SAS_controllers
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_existing_controller_when_adding_disk_and_existing_devices_includes_PCI_and_SCSI_controllers
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_existing_controller_when_adding_disk_and_existing_devices_includes_PCI_and_SATA_controllers
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_existing_controller_when_adding_disk_and_existing_devices_includes_PCI_and_AHCI_controllers
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_existing_controller_when_adding_disk_and_existing_devices_includes_PCI_and_NVME_controllers
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_PVSCSI_controller_in_ConfigSpec_when_adding_disk_and_existing_devices_includes_only_PCI_controller
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_Bus_Logic_controller_in_ConfigSpec_when_adding_disk_and_existing_devices_includes_only_PCI_controller
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_LSI_Logic_controller_in_ConfigSpec_when_adding_disk_and_existing_devices_includes_only_PCI_controller
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_LSI_Logic_SAS_controller_in_ConfigSpec_when_adding_disk_and_existing_devices_includes_only_PCI_controller
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_SCSI_controller_in_ConfigSpec_when_adding_disk_and_existing_devices_includes_only_PCI_controller
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_SATA_controller_in_ConfigSpec_when_adding_disk_and_existing_devices_includes_only_PCI_controller
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_AHCI_controller_in_ConfigSpec_when_adding_disk_and_existing_devices_includes_only_PCI_controller
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_NVME_controller_in_ConfigSpec_when_adding_disk_and_existing_devices_includes_only_PCI_controller
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_and_existing_devices_includes_PCI_controller_and_LSI_Logic_controller_with_no_free_slots
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_and_existing_devices_includes_PCI_controller_and_two_existing_SCSI_controllers_have_no_free_slots
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_and_existing_devices_includes_PCI_controller_and_three_existing_SCSI_controllers_have_no_free_slots
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_(bus_number_three)_when_adding_disk_and_existing_devices_includes_PCI_controller_and_three_existing_SCSI_controllers_have_no_free_slots
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_SATA_controller_when_adding_disk_and_existing_devices_includes_PCI_controller_and_there_are_already_four_SCSI_controllers_with_no_free_slots
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_NVME_controller_when_adding_disk_and_existing_devices_includes_PCI_controller_and_there_are_already_four_SCSI_and_SATA_controllers_with_no_free_slots
    === RUN   TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/return_an_error_that_there_are_no_available_controllers_when_adding_a_disk_and_existing_devices_includes_PCI_controller_and_there_are_already_four_SCSI,_SATA,_and_NVME_controllers_with_no_free_slots
    --- PASS: TestVirtualMachineConfigSpec (0.00s)
        --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/nil_configSpec_arg_should_return_an_error (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/do_nothing_if_configSpec_has_no_disks (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/do_nothing_if_configSpec_has_a_disk,_but_it_is_being_removed (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/do_nothing_if_configSpec_has_a_disk,_but_it_is_already_attached_to_a_controller_from_existing_devices (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_and_there_is_a_nil_base_device_change_in_ConfigSpec_and_existing_device_includes_only_PCI_controller (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_and_there_is_a_nil_device_change_in_ConfigSpec_and_existing_device_includes_only_PCI_controller (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_and_there_is_a_nil_base_device_in_ConfigSpec_and_existing_device_includes_only_PCI_controller (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_and_there_is_a_nil_device_in_ConfigSpec_and_existing_device_includes_only_PCI_controller (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_and_existing_device_includes_PCI_controller_and_nil_base_device (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_and_existing_device_includes_PCI_controller_and_nil_device (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_while_removing_SATA_controller_and_existing_device_includes_only_PCI_controller (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_that_references_SATA_controller_being_removed_and_existing_device_includes_only_PCI_controller (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_that_references_non-existent_controller_and_existing_device_includes_only_PCI_controller (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_sans_controller_and_no_existing_devices (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_PCI_controller_and_disk_sans_controller_and_no_existing_devices (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_sans_controller_and_existing_devices_only_includes_PCI_controller (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_existing_controller_when_adding_disk_and_existing_devices_includes_PCI_and_PVSCSI_controllers (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_existing_controller_when_adding_disk_and_existing_devices_includes_PCI_and_Bus_Logic_controllers (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_existing_controller_when_adding_disk_and_existing_devices_includes_PCI_and_LSI_Logic_controllers (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_existing_controller_when_adding_disk_and_existing_devices_includes_PCI_and_LSI_Logic_SAS_controllers (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_existing_controller_when_adding_disk_and_existing_devices_includes_PCI_and_SCSI_controllers (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_existing_controller_when_adding_disk_and_existing_devices_includes_PCI_and_SATA_controllers (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_existing_controller_when_adding_disk_and_existing_devices_includes_PCI_and_AHCI_controllers (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_existing_controller_when_adding_disk_and_existing_devices_includes_PCI_and_NVME_controllers (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_PVSCSI_controller_in_ConfigSpec_when_adding_disk_and_existing_devices_includes_only_PCI_controller (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_Bus_Logic_controller_in_ConfigSpec_when_adding_disk_and_existing_devices_includes_only_PCI_controller (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_LSI_Logic_controller_in_ConfigSpec_when_adding_disk_and_existing_devices_includes_only_PCI_controller (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_LSI_Logic_SAS_controller_in_ConfigSpec_when_adding_disk_and_existing_devices_includes_only_PCI_controller (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_SCSI_controller_in_ConfigSpec_when_adding_disk_and_existing_devices_includes_only_PCI_controller (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_SATA_controller_in_ConfigSpec_when_adding_disk_and_existing_devices_includes_only_PCI_controller (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_AHCI_controller_in_ConfigSpec_when_adding_disk_and_existing_devices_includes_only_PCI_controller (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_NVME_controller_in_ConfigSpec_when_adding_disk_and_existing_devices_includes_only_PCI_controller (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_and_existing_devices_includes_PCI_controller_and_LSI_Logic_controller_with_no_free_slots (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_and_existing_devices_includes_PCI_controller_and_two_existing_SCSI_controllers_have_no_free_slots (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_when_adding_disk_and_existing_devices_includes_PCI_controller_and_three_existing_SCSI_controllers_have_no_free_slots (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_PVSCSI_controller_(bus_number_three)_when_adding_disk_and_existing_devices_includes_PCI_controller_and_three_existing_SCSI_controllers_have_no_free_slots (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_SATA_controller_when_adding_disk_and_existing_devices_includes_PCI_controller_and_there_are_already_four_SCSI_controllers_with_no_free_slots (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/attach_disk_to_new_NVME_controller_when_adding_disk_and_existing_devices_includes_PCI_controller_and_there_are_already_four_SCSI_and_SATA_controllers_with_no_free_slots (0.00s)
            --- PASS: TestVirtualMachineConfigSpec/EnsureDisksHaveControllers/return_an_error_that_there_are_no_available_controllers_when_adding_a_disk_and_existing_devices_includes_PCI_controller_and_there_are_already_four_SCSI,_SATA,_and_NVME_controllers_with_no_free_slots (0.00s)
    PASS
    ok  	github.com/vmware/govmomi/vim25/types	0.291s
  • The file code related to this change has 100% coverage:

image image image image image image image image image

Checklist:

  • My code follows the CONTRIBUTION guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged

@akutz akutz force-pushed the feature/ensure-disks-have-controllers branch from ea1cc2a to 9ad281b Compare June 20, 2024 16:42
dougm
dougm previously approved these changes Jun 20, 2024
Copy link
Member

@dougm dougm left a comment

Choose a reason for hiding this comment

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

Wow this is awesome, thank you @akutz !

Has me thinking (for after this PR is merged):

  • Can we also use this logic on the simulator side? As in a dry-run mode that helps vcsim detect invalid device controller config, resulting in a Fault. Then again, if everything uses this helper client side, might not be a need for such vcsim testing ;)

  • Can we collapse / get rid of related code in VirtualDeviceList? As in the VirtualDeviceList.*Controller methods.

  • We should add some GH action for code coverage. But that probably won't include all the coverage we have from the bats tests, sigh.

vim25/types/configspec.go Outdated Show resolved Hide resolved
@akutz
Copy link
Member Author

akutz commented Jun 20, 2024

  • Can we also use this logic on the simulator side? As in a dry-run mode that helps vcsim detect invalid device controller config, resulting in a Fault. Then again, if everything uses this helper client side, might not be a need for such vcsim testing ;)

Oh, possibly!

  • Can we collapse / get rid of related code in VirtualDeviceList? As in the VirtualDeviceList.*Controller methods.

I can take a look to see what we might be able to remove.

Do you want me to block this PR on either of the above pieces of feedback? I am fine doing so, I just wanted to be clear if that was your expectation. Thanks!

Nevemind, I missed the part where you said "after this PR is merged" :) Thanks again!

This patch adds a function for ensuring all disks in a ConfigSpec
point to a valid controller.
@akutz akutz force-pushed the feature/ensure-disks-have-controllers branch from 9ad281b to 0de9553 Compare June 20, 2024 17:38
Copy link
Member

@dougm dougm left a comment

Choose a reason for hiding this comment

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

Thanks @akutz !

@akutz akutz merged commit 78199c0 into vmware:main Jun 20, 2024
10 checks passed
@akutz akutz deleted the feature/ensure-disks-have-controllers branch June 20, 2024 20:29
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

3 participants