Skip to content

Conversation

sudo87
Copy link
Collaborator

@sudo87 sudo87 commented Sep 1, 2025

Description

CS creates transient KVM domain.xml. When instance is unmanaged from CS, explicit dump of domain has to be taken to manage is outside of CS.

With this PR

  • domainXML gets backed up and becomes persistent for further management of Instance.
  • Stopped instance also can be unmanaged, last host for instance is considered for defining domain
  • hostid param is supported in unmanageVirtualMachine API for KVM hypervisor and for stopped Instances
  • hostid field in response of unmanageVirtualMachine, representing host used for unmanage operation
  • Disable unmanaging instance with config drive, use forced param from API for KVM

Doc PR:
apache/cloudstack-documentation#562

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):

Screenshot 2025-09-02 at 3 52 33 PM

In above screenshot, "i-2-3-VM" is no longer managed by CS and is brought down. It is still listed in response of:

virsh list --all

API payload and response:
Screenshot 2025-09-17 at 10 56 02 AM

How Has This Been Tested?

For Running Instance:

  1. Created an instance and verified listing it using 'virsh list --all'
  2. Unmanage the instance, xml is found in "/etc/libvirt/qemu" directory (persistent domains location)
  3. Brought that instance down with 'virsh destory '
  4. It is seen in response of 'virsh list --all'
  5. Imported KVM instance in the CS to manage

For Stopped Instance:

  1. Created an instance and verified listing it using 'virsh list --all'
  2. Stop the VM, confirm that domain disappears with virsh
  3. Unmanage the instance, xml gets registered in "/etc/libvirt/qemu" directory (persistent domains location)
  4. Start the instance with 'virsh start '
  5. Import KVM instance in the CS to manage

How did you try to break this feature and the system with this change?

@sudo87
Copy link
Collaborator Author

sudo87 commented Sep 1, 2025

@blueorangutan package

Copy link

codecov bot commented Sep 1, 2025

Codecov Report

❌ Patch coverage is 55.74468% with 104 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.53%. Comparing base (ec533cd) to head (c5d6b2f).
⚠️ Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
...wrapper/LibvirtUnmanageInstanceCommandWrapper.java 32.91% 51 Missing and 2 partials ⚠️
...ck/api/command/admin/vm/UnmanageVMInstanceCmd.java 0.00% 13 Missing ⚠️
...a/com/cloud/agent/api/UnmanageInstanceCommand.java 50.00% 12 Missing ⚠️
...n/java/com/cloud/vm/VirtualMachineManagerImpl.java 88.37% 5 Missing and 5 partials ⚠️
...stack/api/response/UnmanageVMInstanceResponse.java 0.00% 6 Missing ⚠️
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java 58.33% 5 Missing ⚠️
.../apache/cloudstack/vm/UnmanagedVMsManagerImpl.java 66.66% 0 Missing and 4 partials ⚠️
...va/com/cloud/agent/api/UnmanageInstanceAnswer.java 66.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #11541      +/-   ##
============================================
+ Coverage     17.42%   17.53%   +0.10%     
- Complexity    15336    15462     +126     
============================================
  Files          5892     5897       +5     
  Lines        526521   527054     +533     
  Branches      64293    64359      +66     
============================================
+ Hits          91767    92430     +663     
+ Misses       424401   424231     -170     
- Partials      10353    10393      +40     
Flag Coverage Δ
uitests 3.61% <ø> (ø)
unittests 18.59% <55.74%> (+0.11%) ⬆️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sudo87
Copy link
Collaborator Author

sudo87 commented Sep 1, 2025

@blueorangutan package

@blueorangutan
Copy link

@sudo87 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
Copy link

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

@sudo87
Copy link
Collaborator Author

sudo87 commented Sep 2, 2025

@blueorangutan package

@blueorangutan
Copy link

@sudo87 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
Copy link

Packaging result [SF]: ✖️ el8 ✖️ el9 ✖️ debian ✖️ suse15. SL-JID 14812

@sudo87
Copy link
Collaborator Author

sudo87 commented Sep 2, 2025

@blueorangutan package

@blueorangutan
Copy link

@sudo87 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
Copy link

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

@sudo87 sudo87 changed the title persist kvm domain when unmanaged from CS Persist kvm domain when unmanaged from CS Sep 2, 2025
@sudo87 sudo87 changed the title Persist kvm domain when unmanaged from CS Make kvm domain persistent when unmanaged from CS Sep 2, 2025
@sudo87
Copy link
Collaborator Author

sudo87 commented Sep 4, 2025

@blueorangutan package

@blueorangutan
Copy link

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

Copy link
Contributor

@shwstppr shwstppr left a comment

Choose a reason for hiding this comment

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

@sudo87 Looks interesting use-case but I'm bit concerned about making stopped VMs persistent.
Current approach of preparing and saving domain definition seems logical but we may have to make sure there are no differences in the definition when compared to a Running VM.
Will need a good amount of testing

@weizhouapache weizhouapache added this to the 4.22.0 milestone Sep 4, 2025
@blueorangutan
Copy link

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

@blueorangutan
Copy link

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

@sudo87
Copy link
Collaborator Author

sudo87 commented Sep 17, 2025

@blueorangutan package

@blueorangutan
Copy link

@sudo87 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
Copy link

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

@sudo87
Copy link
Collaborator Author

sudo87 commented Sep 18, 2025

@blueorangutan package

@blueorangutan
Copy link

@sudo87 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
Copy link

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

@sudo87
Copy link
Collaborator Author

sudo87 commented Sep 18, 2025

@blueorangutan test

@blueorangutan
Copy link

@sudo87 a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian test result (tid-14380)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 59343 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr11541-t14380-kvm-ol8.zip
Smoke tests completed. 147 look OK, 1 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_03_deploy_and_scale_kubernetes_cluster Failure 1.17 test_kubernetes_clusters.py
test_04_autoscale_kubernetes_cluster Failure 27.88 test_kubernetes_clusters.py

@DaanHoogland
Copy link
Contributor

@sudo87 , will this be symetric? (haven’t reviewed fully yet, forgive me) I mean will a persisted domain be removed on managing the VM?

@sudo87
Copy link
Collaborator Author

sudo87 commented Sep 22, 2025

@sudo87 , will this be symetric? (haven’t reviewed fully yet, forgive me) I mean will a persisted domain be removed on managing the VM?

CS always manages transient VMs, so yes. Once Instance is managed again with CS, domain looses Persistent property.

Copy link

This pull request has merge conflicts. Dear author, please fix the conflicts and sync your branch with the base branch.

@sudo87
Copy link
Collaborator Author

sudo87 commented Sep 25, 2025

@blueorangutan package

@blueorangutan
Copy link

@sudo87 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
Copy link

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

@sudo87
Copy link
Collaborator Author

sudo87 commented Sep 29, 2025

@blueorangutan package

@blueorangutan
Copy link

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

@sudo87 sudo87 closed this Sep 29, 2025
@sudo87 sudo87 reopened this Sep 29, 2025
@blueorangutan
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants