apache / cloudstack

Apache CloudStack is an opensource Infrastructure as a Service (IaaS) cloud computing platform
https://cloudstack.apache.org/
Apache License 2.0
2.11k stars 1.11k forks source link

[VMware] Consider CD/DVD drive when calculating next free unit number for volume attachment over IDE controller #9644

Open winterhazel opened 2 months ago

winterhazel commented 2 months ago

Description

When attaching a volume to an instance, CloudStack calculates the next free unit number of the disk controller that should be associated with the volume. However, for IDE disk controllers, CD/DVD drives associated with the controller are not taken into consideration when calculating the next available unit number. Due to this, an error happens in some situations when trying to attach a volume to an instance over IDE controllers because CloudStack tries to associate the volume to an unit number that is already being used.

The generic method of reproducing this problem is:

  1. Deploy a VM
  2. Set dataDiskController to ide
  3. If there are any volumes using IDE controllers, detach them
  4. Try to attach a volume

This PR fixes the issue by making the code also consider CD/DVD drives. Tests will be added in another PR alongside an extension for the disk controllers that I'm currently working on, as it will require me to modify this code again.

Types of changes

Feature/Enhancement Scale or Bug Severity

Bug Severity

How Has This Been Tested?

  1. I deployed a VM from a template with both rootDiskController and dataDiskController set to ide, with only a root disk
  2. I detached the root disk
  3. I reattached the root disk. Before, an exception would be thrown in this step. After the changes, I verified that the volume was associated successfully to IDE(0:1)
  4. I attached a data disk. I verified that the volume was associated successfully to IDE(1:0)
  5. I attached another data disk. I verified that the volume was associated successfully to IDE(1:1)
  6. I tried to attach another data disk. I verified that an exception was thrown because the maximum number of devices over IDE controllers was reached
winterhazel commented 2 months ago

@blueorangutan package

blueorangutan commented 2 months ago

@winterhazel a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

codecov[bot] commented 2 months ago

Codecov Report

Attention: Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.

Project coverage is 15.08%. Comparing base (0204cb7) to head (dddfea4). Report is 28 commits behind head on 4.19.

Files with missing lines Patch % Lines
...m/cloud/hypervisor/vmware/mo/VirtualMachineMO.java 0.00% 4 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## 4.19 #9644 +/- ## =========================================== Coverage 15.08% 15.08% - Complexity 11185 11193 +8 =========================================== Files 5406 5406 Lines 473123 473215 +92 Branches 58163 60800 +2637 =========================================== + Hits 71371 71390 +19 - Misses 393810 393877 +67 - Partials 7942 7948 +6 ``` | [Flag](https://app.codecov.io/gh/apache/cloudstack/pull/9644/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | | |---|---|---| | [uitests](https://app.codecov.io/gh/apache/cloudstack/pull/9644/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `4.30% <ø> (-0.01%)` | :arrow_down: | | [unittests](https://app.codecov.io/gh/apache/cloudstack/pull/9644/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `15.80% <0.00%> (+<0.01%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

blueorangutan commented 2 months ago

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ debian ✔️ suse15. SL-JID 11021

rohityadavcloud commented 2 months ago

@blueorangutan test ol8 vmware-70u3

blueorangutan commented 2 months ago

@rohityadavcloud a [SL] Trillian-Jenkins test job (ol8 mgmt + vmware-70u3) has been kicked to run smoke tests

blueorangutan commented 2 months ago

[SF] Trillian test result (tid-11398) Environment: vmware-70u3 (x2), Advanced Networking with Mgmt server ol8 Total time taken: 52194 seconds Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr9644-t11398-vmware-70u3.zip Smoke tests completed. 131 look OK, 2 have errors, 0 did not run Only failed and skipped tests results shown below:

Test Result Time (s) Test File
ContextSuite context=TestPrivateGwACL>:setup Error 0.00 test_privategw_acl.py
test_09_project_suspend Error 1.11 test_projects.py
test_10_project_activation Error 1.09 test_projects.py