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.

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

codecov Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 3.53%. Comparing base (3d70ce4) to head (216282d).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff           @@
##            main   #14043   +/-   ##
======================================
  Coverage   3.53%    3.53%           
======================================
  Files        487      487           
  Lines      41863    41863           
  Branches    7912     7912           
======================================
  Hits        1479     1479           
  Misses     40170    40170           
  Partials     214      214           
Flag Coverage Δ
uitests 3.53% <ø> (ø)

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.

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.

1 participant