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

Fix VMWare leftovers when deleting VM without root disk #9735

Open
wants to merge 2 commits into
base: 4.19
Choose a base branch
from

Conversation

gpordeus
Copy link
Collaborator

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)
  • 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
  • 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 ❌ VM gone from vCenter ✅
Without data disks, detach root disk. Without expunge VM remains on vCenter ✅ VM remains on vCenter ✅
Without data disks, detach nothing With expunge VM gone from vCenter ✅ VM gone from vCenter ✅
With a data disk, detach root disk With expunge, without selecting data disk VM remains on vCenter ❌ VM gone from vCenter ✅
With a data disk, detach root disk With expunge, selecting the data disk VM remains on vCenter ❌ VM gone from vCenter ✅
With a data disk, detach nothing With expunge, without selecting the data disk VM gone from vCenter ✅ VM gone from vCenter ✅

Copy link

codecov bot commented Sep 26, 2024

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 15 commits behind head on 4.19.

Files with missing lines Patch % Lines
...ain/java/com/cloud/agent/api/CleanupVMCommand.java 0.00% 13 Missing ⚠️
...oud/hypervisor/vmware/resource/VmwareResource.java 0.00% 11 Missing and 1 partial ⚠️
...ain/java/com/cloud/hypervisor/guru/VMwareGuru.java 0.00% 6 Missing ⚠️
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%) ⬇️
unittests 15.80% <0.00%> (?)

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@sureshanaparti sureshanaparti left a comment

Choose a reason for hiding this comment

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

clgtm, needs testing.

Copy link
Contributor

@nvazquez nvazquez left a comment

Choose a reason for hiding this comment

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

Code LGTM

s_logger.debug(msg);
return new Answer(cmd, true, msg);
}
vmMo.destroy();
Copy link
Member

Choose a reason for hiding this comment

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

just curious, why not do it in the process for DestroyCommand ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

DestroyCommand centers around the volume. I guess I could have just added conditions around it, but keeping them separate seemed fitting.

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.

4 participants