cloudstack icon indicating copy to clipboard operation
cloudstack copied to clipboard

Fix VMWare leftovers when deleting VM without root disk

Open gpordeus opened this issue 1 year ago • 1 comments

Description

The MS sends the destroy/delete command of a VM to vCenter when cleaning up its volumes. If the VM does not have a root volume, the VM with its folder and metadata files remain in vCenter.

To reproduce, deploy a VM, detach its volume, and delete the VM. Then, check vCenter and the VM will still be there.

This PR fixes it by implementing finalizeExpunge for VMWareGuru, which queues a Cleanup Command that, if the VM still exists, sends a destroy command to vCenter to cleanup whatever remained.

Types of changes

  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] New feature (non-breaking change which adds functionality)
  • [X] Bug fix (non-breaking change which fixes an issue)
  • [ ] Enhancement (improves an existing feature and functionality)
  • [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
  • [ ] build/CI
  • [ ] test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • [ ] Major
  • [ ] Minor

Bug Severity

  • [ ] BLOCKER
  • [ ] Critical
  • [ ] Major
  • [X] Minor
  • [ ] Trivial

Screenshots (if appropriate):

How Has This Been Tested?

Deploy VM Destroy VM Before PR After PR
Without data disks, detach root disk. With expunge VM remains on vCenter :x: VM gone from vCenter :white_check_mark:
Without data disks, detach root disk. Without expunge VM remains on vCenter :white_check_mark: VM remains on vCenter :white_check_mark:
Without data disks, detach nothing With expunge VM gone from vCenter :white_check_mark: VM gone from vCenter :white_check_mark:
With a data disk, detach root disk With expunge, without selecting data disk VM remains on vCenter :x: VM gone from vCenter :white_check_mark:
With a data disk, detach root disk With expunge, selecting the data disk VM remains on vCenter :x: VM gone from vCenter :white_check_mark:
With a data disk, detach nothing With expunge, without selecting the data disk VM gone from vCenter :white_check_mark: VM gone from vCenter :white_check_mark:

gpordeus avatar Sep 26 '24 20:09 gpordeus

Codecov Report

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

Project coverage is 15.08%. Comparing base (89482a2) to head (14fd10e). Report is 147 commits behind head on 4.19.

Files with missing lines Patch % Lines
...ain/java/com/cloud/agent/api/CleanupVMCommand.java 0.00% 13 Missing :warning:
...oud/hypervisor/vmware/resource/VmwareResource.java 0.00% 11 Missing and 1 partial :warning:
...ain/java/com/cloud/hypervisor/guru/VMwareGuru.java 0.00% 6 Missing :warning:
Additional details and impacted files
@@             Coverage Diff              @@
##              4.19    #9735       +/-   ##
============================================
+ Coverage     4.76%   15.08%   +10.31%     
- Complexity       0    11188    +11188     
============================================
  Files          366     5403     +5037     
  Lines        29525   473174   +443649     
  Branches      5167    59662    +54495     
============================================
+ Hits          1408    71379    +69971     
- Misses       28111   393852   +365741     
- Partials         6     7943     +7937     
Flag Coverage Δ
uitests 4.30% <ø> (-0.47%) :arrow_down:
unittests 15.80% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

codecov[bot] avatar Sep 26 '24 20:09 codecov[bot]

@blueorangutan package

vladimirpetrov avatar Nov 13 '24 09:11 vladimirpetrov

@vladimirpetrov 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.

blueorangutan avatar Nov 13 '24 09:11 blueorangutan

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

blueorangutan avatar Nov 13 '24 10:11 blueorangutan