From: Michael Ryom <Michael@RyomHerold.dk>
To: pve-devel@lists.proxmox.com
Cc: Michael Ryom <Michael@RyomHerold.dk>
Subject: [PATCH ha-manager v2 10/14] sim: hardware: allow setting a base load for nodes
Date: Sun, 18 Oct 2026 14:45:54 +0200 [thread overview]
Message-ID: <20261018124559.24305-11-Michael@RyomHerold.dk> (raw)
In-Reply-To: <20261018124559.24305-1-Michael@RyomHerold.dk>
The dynamic node usage stats of the simulated hardware only consisted
of the usage of the running HA-managed services. On a real cluster, the
node usage additionally contains everything else running on the node:
non-HA guests, storage daemons like Ceph or the ZFS ARC, and other host
processes, which fluctuate independently of the HA-managed services.
Read an optional base load ('cpu' and 'mem') for each node from the
hardware status and add a hardware command
node <node> set-dynamic-stats [cpu <cores>] [mem <MiB>]
to change it during a test, so that regression tests can simulate load
that cannot be attributed to any HA-managed service.
Signed-off-by: Michael Ryom <Michael@RyomHerold.dk>
---
src/PVE/HA/Sim/Hardware.pm | 30 +++++++++++++++++++++++++++---
1 file changed, 27 insertions(+), 3 deletions(-)
diff --git a/src/PVE/HA/Sim/Hardware.pm b/src/PVE/HA/Sim/Hardware.pm
index 538bc4e..aa1a886 100644
--- a/src/PVE/HA/Sim/Hardware.pm
+++ b/src/PVE/HA/Sim/Hardware.pm
@@ -791,6 +791,7 @@ sub get_cfs_state {
# crm enable-node-maintenance <node>
# crm disable-node-maintenance <node>
# pve-manager-version <node> set <version> # note: this is NOT the *ha*-manager version
+# node <node> set-dynamic-stats [cpu <cores>] [mem <MiB>] # load outside HA services
# reboot <node>
# shutdown <node>
# restart-lrm <node>
@@ -881,6 +882,26 @@ sub sim_hardware_cmd {
$self->write_hardware_status_nolock($cstatus);
+ } elsif ($cmd eq 'node') {
+ die "sim_hardware_cmd: unknown node action '$action'"
+ if $action ne 'set-dynamic-stats';
+ die "sim_hardware_cmd: missing target stat for '$action' command"
+ if !@params;
+
+ my $conversions = { cpu => sub { 0.0 + $_[0] }, mem => sub { $_[0] * 1024**2 } };
+
+ for my ($target, $val) (@params) {
+ die "sim_hardware_cmd: missing value for '$action $target' command"
+ if !defined($val);
+
+ my $convert = $conversions->{$target}
+ or die "sim_hardware_cmd: unknown target stat '$target' for '$action' command";
+
+ $cstatus->{$node}->{$target} = $convert->($val);
+ }
+
+ $self->write_hardware_status_nolock($cstatus);
+
} elsif ($cmd eq 'cfs') {
die "sim_hardware_cmd: unknown cfs action '$action' for node '$node'"
if $action !~ m/^(rw|update)$/;
@@ -1281,18 +1302,21 @@ sub get_static_node_stats {
sub get_dynamic_node_stats {
my ($self) = @_;
+ my $cstatus = $self->read_hardware_status_nolock();
+
my $stats = $self->get_static_node_stats();
for my $node (keys %$stats) {
$stats->{$node}->{maxcpu} = $stats->{$node}->{maxcpu} // $default_node_maxcpu;
- $stats->{$node}->{cpu} = $stats->{$node}->{cpu} // 0.0;
+ # base load of the node outside of the HA-managed services, e.g.
+ # non-HA guests or other host processes
+ $stats->{$node}->{cpu} = $cstatus->{$node}->{cpu} // 0.0;
$stats->{$node}->{maxmem} = $stats->{$node}->{maxmem} // $default_node_maxmem;
- $stats->{$node}->{mem} = $stats->{$node}->{mem} // 0;
+ $stats->{$node}->{mem} = $cstatus->{$node}->{mem} // 0;
}
my $service_conf = $self->read_service_config();
my $dynamic_service_stats = $self->get_dynamic_service_stats();
- my $cstatus = $self->read_hardware_status_nolock();
my $node_service_status = { map { $_ => $self->read_service_status($_) } keys %$cstatus };
for my $sid (keys %$service_conf) {
--
2.47.3
next prev parent reply other threads:[~2026-10-18 12:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Michael Ryom [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261018124559.24305-11-Michael@RyomHerold.dk \
--to=michael@ryomherold.dk \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.