public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH cluster/ha-manager/manager/docs v2 00/14] auto rebalance: fix failure retry loop and oscillation
@ 2026-10-18 12:45 Michael Ryom
  2026-10-18 12:45 ` [PATCH cluster v2 01/14] datacenter config: add HA auto-rebalance margin mode and cooldown Michael Ryom
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: Michael Ryom @ 2026-10-18 12:45 UTC (permalink / raw)
  To: pve-devel; +Cc: Michael Ryom

The automatic load balancer shows two problematic behaviors on a small
cluster, found while deliberately stress-testing CRS with ha=dynamic and
ha-auto-rebalance on a two-node PVE 9.2 cluster, see bug #8059:

1. A rebalance migration that fails (e.g. local CD-ROM attached) is
   re-issued every ~40 seconds, indefinitely - 25 identical failing
   attempts in 20 minutes were observed.

2. A single dominant resource oscillates between two nodes: the
   relative margin provides almost no hysteresis (a base load
   difference of ~0.5 percentage points qualifies a motion and later
   its reverse), and the point-in-time usage samples of the load that
   is not caused by HA resources are noisy. Five moves of the same VM
   in 27 minutes were observed on an otherwise idle cluster.

Changes since v1
----------------

Thanks to Dominik and Daniel for the reviews!

v1: https://lore.proxmox.com/pve-devel/20260920162220.574802-1-Michael@RyomHerold.dk/

* Failed rebalance motions (patches 3-4) are now handled per
  rebalancing attempt instead of with a time-based backoff, as
  suggested by Daniel: a failed motion is never retried in the same
  attempt, so the next best motion is tried instead; it is considered
  again in the next attempt, and if it keeps failing, it is skipped in
  exponentially more of the following attempts. With the time-based
  backoff of v1, two failing motions of the same resource to different
  nodes could take turns before the next best motion was ever tried -
  the new test-crs-dynamic-auto-rebalance5 reproduces exactly the
  fa:109 example from the review.
* Failures are recorded in next_state_migrate_relocate() when the LRM
  reports them, for every resource moved by the balancer, i.e. also for
  the dependent resources of a resource bundle. A change of the
  bundle's leader no longer resets the failure state.
* The cooldown after a successful motion is a separate patch (5-6) and
  an option (ha-auto-rebalance-cooldown), which defaults to 0, i.e. it
  is disabled.
* The minimum absolute improvement is no longer a separate threshold,
  but a mode of the existing margin (ha-auto-rebalance-margin-mode,
  relative or absolute), defaulting to relative (patches 7-8).
* The pressure-gating patch (7/7 of v1) is dropped. I agree with
  Daniel's points: PSI can tell that a node has a problem, but not what
  should be moved where, it reacts late, cpu and memory pressure need
  different standards, and it should not depend on whether a node
  broadcasts the information. I'll follow up separately with a
  proposal that addresses the "what and where" with a per-guest model
  instead of a node-local gate.
* Each behavior change is preceded by a patch which adds its test case
  with the current behavior, so the change is visible in the expected
  log of the changing patch (patches 4, 6, 8 and 12).
* Nits: is_resource_motion_queued_or_running() factored out (patch 2),
  `my sub` instead of `my $name = sub`, no combined `//=` with an
  increment.
* The memhost patch of v1 is dropped, as the same fix has landed as
  commit 28c31e4 ("fix #7974: env: pve2: set dynamic service mem value
  to host memory usage"). The series is rebased on top of it.

The series
----------

Patch 1 adds the schema of the two new options to pve-cluster.
pve-ha-manager falls back to the defaults when the options are absent,
so it also works with an older libpve-cluster-perl.

Patch 2 is a preparatory refactoring.

Patches 3-4 fix the retry loop of failed rebalance motions (bug #8059).

Patches 5-6 add an optional cooldown for resources moved by the
balancer, which suppresses an immediate reverse motion.

Patches 7-8 add the absolute margin mode, which creates a dead band for
motions that only shuffle load without meaningfully improving the
cluster balance.

Patches 9-10 extend the simulator (actual running state in the cluster
service stats, like the RRD-based stats on a real cluster; an optional
node base load), so that the following patches are regression-testable.

Patches 11-12 decompose each node's load into the usage of the
HA-managed services running on it plus a residual, and smooth only the
residual with an exponentially moving average kept across scheduling
rounds. Known structural changes (a service was migrated, started or
stopped) take effect immediately; only load that cannot be attributed
to any HA-managed service - which drives the oscillation but cannot be
acted upon - is averaged. This is unchanged from v1 and is the only
behavior change of the series that is not opt-in; no expected log of an
existing test case changes.

Patch 13 adds the matching UI fields to pve-manager, and patch 14
documents the new options and the handling of failed migrations,
together with an overview table of all load balancer options.

Testing
-------

The full src/test suite (158 test cases, including 5 new ones) passes,
both against the pve-rs bindings and in a build chroot, and each
test-adding patch was run on its own to record the behavior before the
change. The residual smoothing (patches 11-12) ran on the reporting
cluster for several weeks as part of v1. The new attempt-based failure
handling and the margin mode are tested in the simulator only so far.

Known remaining gaps, kept out of this series and described in bug
#8059: candidate migratability is not checked before scoring (Daniel
mentioned he is working on inferring such constraints from the guest
configuration - I have a draft for the same that I'm happy to drop or
contribute to his series), and migration cost is not part of the
scoring (see also bug #7650).

pve-ha-manager:

 src/PVE/HA/Manager.pm           | 201 ++++++-
 src/PVE/HA/Sim/Hardware.pm      |  39 +-
 src/PVE/HA/Usage/Dynamic.pm     |  73 ++-
 src/test/...                    | 503 ++++++++ (45 files, 5 new tests)

pve-cluster:

 src/PVE/DataCenterConfig.pm     |  28 +-

pve-manager:

 www/manager6/form/CRSOptions.js |  35 +-

pve-docs:

 ha-manager.adoc                 |  62 +



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2026-10-18 12:48 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-18 12:45 [PATCH cluster/ha-manager/manager/docs v2 00/14] auto rebalance: fix failure retry loop and oscillation Michael Ryom
2026-10-18 12:45 ` [PATCH cluster v2 01/14] datacenter config: add HA auto-rebalance margin mode and cooldown Michael Ryom
2026-10-18 12:45 ` [PATCH ha-manager v2 02/14] manager: factor out checking whether a resource motion is queued or running Michael Ryom
2026-10-18 12:45 ` [PATCH ha-manager v2 03/14] test: add auto rebalance test cases for failing rebalance motions Michael Ryom
2026-10-18 12:45 ` [PATCH ha-manager v2 04/14] fix #8059: manager: auto rebalance: do not retry failed rebalance motions right away Michael Ryom
2026-10-18 12:45 ` [PATCH ha-manager v2 05/14] test: add auto rebalance test case for an immediate reverse motion Michael Ryom
2026-10-18 12:45 ` [PATCH ha-manager v2 06/14] manager: auto rebalance: add optional cooldown for moved resources Michael Ryom
2026-10-18 12:45 ` [PATCH ha-manager v2 07/14] test: add auto rebalance test case for a marginal absolute improvement Michael Ryom
2026-10-18 12:45 ` [PATCH ha-manager v2 08/14] manager: auto rebalance: allow an absolute margin Michael Ryom
2026-10-18 12:45 ` [PATCH ha-manager v2 09/14] sim: hardware: report actual running state in cluster service stats Michael Ryom
2026-10-18 12:45 ` [PATCH ha-manager v2 10/14] sim: hardware: allow setting a base load for nodes Michael Ryom
2026-10-18 12:45 ` [PATCH ha-manager v2 11/14] test: add auto rebalance test case for fluctuating node base loads Michael Ryom
2026-10-18 12:45 ` [PATCH ha-manager v2 12/14] usage: dynamic: smooth the unaccounted node load Michael Ryom
2026-10-18 12:45 ` [PATCH manager v2 13/14] ui: crs options: expose the auto-rebalance margin mode and cooldown Michael Ryom
2026-10-18 12:45 ` [PATCH docs v2 14/14] ha-manager: document the auto-rebalance margin mode, cooldown and failed migrations Michael Ryom

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal