Skip to content

[4.22] Prevent unmanaging or recovering a VM if it is part of a CKS cluster#12800

Open
nvazquez wants to merge 6 commits intoapache:4.22from
shapeblue:422-fix-cks-node-unmanage-vm
Open

[4.22] Prevent unmanaging or recovering a VM if it is part of a CKS cluster#12800
nvazquez wants to merge 6 commits intoapache:4.22from
shapeblue:422-fix-cks-node-unmanage-vm

Conversation

@nvazquez
Copy link
Contributor

@nvazquez nvazquez commented Mar 12, 2026

Description

This PR prevents unmanaging or recovering a VM if it belongs to a CKS cluster, with a descriptive message

Fixes: #12783
Fixes: #12837

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?

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

@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

❌ Patch coverage is 28.57143% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.61%. Comparing base (09ee092) to head (48073b3).
⚠️ Report is 1 commits behind head on 4.22.

Files with missing lines Patch % Lines
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.22   #12800   +/-   ##
=========================================
  Coverage     17.61%   17.61%           
- Complexity    15661    15668    +7     
=========================================
  Files          5917     5917           
  Lines        531423   531437   +14     
  Branches      64973    64975    +2     
=========================================
+ Hits          93586    93607   +21     
+ Misses       427280   427272    -8     
- Partials      10557    10558    +1     
Flag Coverage Δ
uitests 3.70% <ø> (ø)
unittests 18.68% <28.57%> (+<0.01%) ⬆️

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.

@kiranchavala kiranchavala self-assigned this Mar 12, 2026
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

@nvazquez
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@nvazquez 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

@DaanHoogland DaanHoogland left a comment

Choose a reason for hiding this comment

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

clgtm

@blueorangutan
Copy link

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

@nvazquez
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

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

@blueorangutan
Copy link

[SF] Trillian Build Failed (tid-15632)

@nvazquez
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

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

@blueorangutan
Copy link

[SF] Trillian Build Failed (tid-15633)

@kiranchavala
Copy link
Member

@blueorangutan test

@blueorangutan
Copy link

@nvazquez 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 17168

@kiranchavala
Copy link
Member

@blueorangutan test

@blueorangutan
Copy link

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

Copy link
Member

@kiranchavala kiranchavala left a comment

Choose a reason for hiding this comment

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

@nvazquez Please provide proper error message when a end user unamanges a instance which is a part of a cks cluster

Image
(localcloud) 🐱 > unmanage virtualmachine id=0aa8147a-1002-49e9-bcc6-5af4b35f05d2
{
  "account": "admin",
  "accountid": "7f089b6c-21c6-11f1-92f3-1e004e000380",
  "cmd": "org.apache.cloudstack.api.command.admin.vm.UnmanageVMInstanceCmd",
  "completed": "2026-03-17T07:33:20+0000",
  "created": "2026-03-17T07:33:20+0000",
  "domainid": "28ca91c8-21c6-11f1-92f3-1e004e000380",
  "domainpath": "ROOT",
  "jobid": "59a56976-d640-419b-b135-86706c5fee19",
  "jobinstanceid": "0aa8147a-1002-49e9-bcc6-5af4b35f05d2",
  "jobinstancetype": "VirtualMachine",
  "jobprocstatus": 0,
  "jobresult": {
    "errorcode": 530,
    "errortext": "No bean named 'com.cloud.kubernetes.cluster.KubernetesServiceHelper' available"
  },
  "jobresultcode": 530,
  "jobresulttype": "object",
  "jobstatus": 2,
  "userid": "7f09fbfa-21c6-11f1-92f3-1e004e000380"
}
🙈 Error: async API failed for job 59a56976-d640-419b-b135-86706c5fee19

The message can be similar to the one when a end user tries to destroy a machine which is part of the cks cluster

Image

@nvazquez
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@nvazquez 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 17173

@nvazquez
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@nvazquez 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 17175

@blueorangutan
Copy link

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

Test Result Time (s) Test File
test_create_pvlan_network Error 0.13 test_pvlan.py
test_01_unmanage_vm_cycle_persistent_domain Error 58.14 test_vm_lifecycle_unmanage_kvm_import.py
test_01_unmanage_vm_cycle_persistent_domain Error 58.14 test_vm_lifecycle_unmanage_kvm_import.py
test_02_unmanage_stopped_vm_cycle_persistent_domain Error 190.26 test_vm_lifecycle_unmanage_kvm_import.py
test_02_unmanage_stopped_vm_cycle_persistent_domain Error 190.27 test_vm_lifecycle_unmanage_kvm_import.py
ContextSuite context=TestUnmanageKvmVM>:teardown Error 190.31 test_vm_lifecycle_unmanage_kvm_import.py

@nvazquez
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

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

@blueorangutan
Copy link

[SF] Trillian Build Failed (tid-15686)

@nvazquez
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

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

@nvazquez nvazquez changed the title [4.22] Prevent unmanaging VM from CloudStack if it is part of a CKS cluster [4.22] Prevent unmanaging or recovering a VM if it is part of a CKS cluster Mar 18, 2026
@nvazquez
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@nvazquez 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

[SF] Trillian Build Failed (tid-15687)

@blueorangutan
Copy link

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

@nvazquez
Copy link
Contributor Author

@blueorangutan test

@blueorangutan
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

Validate and don't allow the api recoverVirtualMachine for cks clusters CKS cluster goes into alert state when worker node is unmanaged

5 participants