Skip to content

cluster-drs: trigger DRS on VM power-state events and add a combined cpu+memory metric - #14043

Open
nagaboinaramgopal wants to merge 2 commits into
apache:mainfrom
nagaboinaramgopal:feature/cluster-drs-event-driven
Open

cluster-drs: trigger DRS on VM power-state events and add a combined cpu+memory metric#14043
nagaboinaramgopal wants to merge 2 commits into
apache:mainfrom
nagaboinaramgopal:feature/cluster-drs-event-driven

Conversation

@nagaboinaramgopal

Copy link
Copy Markdown

Description

Two cluster-DRS improvements.

  1. Event-driven DRS. Cluster DRS previously ran only on the periodic timer, so an imbalance created when a VM starts or stops was not corrected until the next scheduled run. This subscribes the DRS service to VM power-state events and triggers a DRS pass for the affected cluster when one fires. Two new cluster-scoped settings control it: drs.event.driven.enable (default false, off) and drs.event.driven.interval (default 5, the minimum seconds between event-driven runs, so a burst of power events is debounced into a single pass). Event-driven runs still require automatic DRS to be enabled for the cluster and honour the existing DRS algorithm and thresholds. Off by default, so nothing changes until an operator opts in.

  2. A "both" DRS metric. In addition to balancing on cpu or memory, the new both metric balances on both together by scoring a candidate migration on the worse of its cpu and memory post-migration imbalance, so a cluster is only considered balanced when both dimensions are.

Types of changes

  • New feature (non-breaking change which adds functionality)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Minor

How Has This Been Tested?

Added unit tests in ClusterDrsServiceImplTest:

  • testShouldTriggerEventDrivenDrsDisabledByDefault: no event-driven run when the setting is off (the default).
  • testShouldTriggerEventDrivenDrsRequiresAutomaticDrs: event-driven runs only when automatic DRS is enabled.
  • testShouldTriggerEventDrivenDrsEnabledThenDebounced: a second event within the interval is debounced.
  • testTriggerEventDrivenDrsForVmSchedulesWhenEnabled and testTriggerEventDrivenDrsForVmDoesNotScheduleWhenDisabled: a VM power-state event schedules a DRS pass only when enabled.

Also built the standard packages and deployed on a KVM advanced zone.

@codecov

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 25.71429% with 78 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.78%. Comparing base (44ab7dd) to head (16076fd).

Files with missing lines Patch % Lines
...ache/cloudstack/cluster/ClusterDrsServiceImpl.java 28.20% 51 Missing and 5 partials ⚠️
...apache/cloudstack/cluster/ClusterDrsAlgorithm.java 4.34% 21 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               main   #14043   +/-   ##
=========================================
  Coverage     19.77%   19.78%           
- Complexity    19989    20001   +12     
=========================================
  Files          6371     6371           
  Lines        575899   575977   +78     
  Branches      70495    70502    +7     
=========================================
+ Hits         113912   113979   +67     
  Misses       449563   449563           
- Partials      12424    12435   +11     
Flag Coverage Δ
uitests 3.53% <ø> (ø)
unittests 21.06% <25.71%> (+<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.

drs.metric gains a "both" option. Cluster imbalance and each candidate
migration's post-imbalance are measured as the worse (max) of the cpu and
memory imbalance, so DRS acts whenever either resource is contended
instead of only the single configured metric.
Adds drs.event.driven.enable (default false) and drs.event.driven.interval
(default 5 min). When enabled for a cluster, ClusterDrsServiceImpl
subscribes to the vm.powerstate message bus, resolves the affected
cluster on each event and generates a plan for it within minutes (rate-
limited per cluster), off the message-bus thread. The existing poll then
executes the plan. Requires drs.automatic.enable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

3 participants