Skip to content

Fix skip DRS for a VM - #12994

Merged
weizhouapache merged 4 commits into
apache:4.20from
shapeblue:fix-skip-drs
Jul 9, 2026
Merged

Fix skip DRS for a VM#12994
weizhouapache merged 4 commits into
apache:4.20from
shapeblue:fix-skip-drs

Conversation

@vishesh92

@vishesh92vishesh92 commented Apr 10, 2026

Copy link
Copy Markdown
Member

Description

When a VM has skipFromDRS detail set, it is still not getting skipped. This PR fixes it.
Doc PR - apache/cloudstack-documentation#653

Details

This pull request refactors how the system determines whether a VM should be skipped for DRS (Distributed Resource Scheduler) operations. The main improvement is centralizing and simplifying the skip logic, now using the `UserVmDetailsDao` to check VM details in the database rather than relying solely on in-memory details. This ensures more accurate and consistent behavior.

Key changes:

Refactoring skip logic for DRS:

  • Introduced a new shouldSkipVMForDRS method to encapsulate all logic for determining if a VM should be skipped, making the code cleaner and easier to maintain.
  • Updated the main DRS processing loop to use the new shouldSkipVMForDRS method, ensuring consistent skip checks throughout the codebase.

Improved VM detail retrieval:

  • Now retrieves the SKIP_DRS flag using UserVmDetailsDao from the database, instead of only checking the VM's in-memory details map. This makes the skip logic more robust and reliable.

Dependency injection:

  • Added dependency injection for UserVmDetailsDao to enable database access for VM details.
  • Imported UserVmDetailVO and UserVmDetailsDao for use in the new logic.

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?

@vishesh92
vishesh92 requested a review from CopilotApril 10, 2026 06:46
@apacheapache deleted a comment from blueorangutanApr 10, 2026
@vishesh92
vishesh92 requested review from Copilot and removed request for CopilotApril 10, 2026 06:52

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Fixes DRS skip behavior when the SKIP_DRS VM detail is set but not present in the in-memory VM details map by centralizing skip logic and consulting the DB-backed VM details DAO.

Changes:

  • Added DB-backed lookup of VmDetailConstants.SKIP_DRS via UserVmDetailsDao.
  • Centralized DRS skip logic into shouldSkipVMForDRS and reused it in both the main loop and skipDrs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov

codecovBot commented Apr 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 52.63158% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.26%. Comparing base (c267ad3) to head (dd4e94a).
⚠️ Report is 13 commits behind head on 4.20.

Files with missing linesPatch %Lines
...udstack/resourcedetail/ResourceDetailsDaoBase.java11.11%8 Missing ⚠️
...ache/cloudstack/cluster/ClusterDrsServiceImpl.java90.00%0 Missing and 1 partial ⚠️
Additional details and impacted files
@@ Coverage Diff @@## 4.20 #12994 +/- ##
============================================
- Coverage 16.26% 16.26% -0.01% + Complexity 13433 13432 -1 
============================================
Files 5665 5667 +2 Lines 500572 500681 +109 Branches 60792 60792 ============================================
- Hits 81417 81415 -2 - Misses 410047 410160 +113 + Partials 9108 9106 -2 
FlagCoverage Δ
uitests4.14% <ø> (-0.01%)⬇️
unittests17.11% <52.63%> (-0.01%)⬇️

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

☔ View full report in Codecov by Harness.
📢 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.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vishesh92

Copy link
Copy Markdown
MemberAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@vishesh92 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
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

[SF] Trillian Build Failed (tid-15852)

@sureshanaparti

Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

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

TestResultTime (s)Test File

@kiranchavalakiranchavala left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@vishesh92

As discussed, if we could add a log message saying we are skipping a vm from drs plan when "generateClusterDrsPlan" api is called it will be beneficial to the admin user when troubleshooting.

Also, please update the doc about the "skipFromDRS" in vmsettings

https://docs.cloudstack.apache.org/en/4.22.0.0/adminguide/clusters.html#cloudstack-drs

@weizhouapacheweizhouapache added this to the 4.20.4 milestone May 7, 2026
vishesh92and others added 3 commits May 20, 2026 16:01
@vishesh92

Copy link
Copy Markdown
MemberAuthor

@vishesh92

As discussed, if we could add a log message saying we are skipping a vm from drs plan when "generateClusterDrsPlan" api is called it will be beneficial to the admin user when troubleshooting.

Also, please update the doc about the "skipFromDRS" in vmsettings

https://docs.cloudstack.apache.org/en/4.22.0.0/adminguide/clusters.html#cloudstack-drs

Created a doc PR here: apache/cloudstack-documentation#653

@vishesh92

Copy link
Copy Markdown
MemberAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

@vishesh92 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
Copy Markdown

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

@apacheapache deleted a comment from blueorangutanMay 21, 2026
@apacheapache deleted a comment from blueorangutanMay 21, 2026
@vishesh92

Copy link
Copy Markdown
MemberAuthor

@blueorangutan test

@apacheapache deleted a comment from blueorangutanMay 22, 2026
@apacheapache deleted a comment from blueorangutanMay 22, 2026
@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

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

TestResultTime (s)Test File
test_01_deployVMInSharedNetworkFailure310.65test_network.py

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@vishesh92

Copy link
Copy Markdown
MemberAuthor

@blueorangutan package

@blueorangutan

Copy link
Copy Markdown

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

@weizhouapacheweizhouapache left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

code lgtm

not tested

@blueorangutan

Copy link
Copy Markdown

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

@vishesh92

Copy link
Copy Markdown
MemberAuthor

@blueorangutan test

@blueorangutan

Copy link
Copy Markdown

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

@blueorangutan

Copy link
Copy Markdown

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

TestResultTime (s)Test File

@weizhouapache
weizhouapache merged commit a4b102f into apache:4.20Jul 9, 2026
24 of 26 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@vishesh92@blueorangutan@sureshanaparti@kiranchavala@weizhouapache