From: Dominik Rusovac <d.rusovac@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-ha-manager 11/15] sim: hardware: enable datacenter config changes at runtime
Date: Wed, 21 Oct 2026 10:59:28 +0200 [thread overview]
Message-ID: <20261021085932.1196302-12-d.rusovac@proxmox.com> (raw)
In-Reply-To: <20261021085932.1196302-1-d.rusovac@proxmox.com>
This adds commands to change CRS settings or shutdown policy at test
runtime.
Signed-off-by: Dominik Rusovac <d.rusovac@proxmox.com>
---
src/PVE/HA/Sim/Hardware.pm | 62 ++++++++++++++++++++++++++++++++++++++
1 file changed, 62 insertions(+)
diff --git a/src/PVE/HA/Sim/Hardware.pm b/src/PVE/HA/Sim/Hardware.pm
index e1a9ddd..e75229c 100644
--- a/src/PVE/HA/Sim/Hardware.pm
+++ b/src/PVE/HA/Sim/Hardware.pm
@@ -59,6 +59,7 @@ my $default_node_maxmem = 131072 * 1024**2;
# $testdir/status/service_config Service configuration
# $testdir/status/service_status_<node> Service status
# $testdir/status/groups HA groups configuration
+# $testdir/status/datacenter.cfg Datacenter wide HA configuration
sub read_lrm_status {
my ($self, $node) = @_;
@@ -699,6 +700,58 @@ sub write_datacenter_conf {
PVE::HA::Tools::write_json_to_file($filename, $conf);
}
+my $datacenter_settings = {
+ ha => {
+ shutdown_policy => qr/^(?:conditional|freeze|failover||migrate)$/,
+ },
+ crs => {
+ ha => qr/^(?:basic|static|dynamic)$/,
+ 'ha-rebalance-on-start' => qr/^[01]$/,
+ 'ha-auto-rebalance' => qr/^[01]$/,
+ 'ha-auto-rebalance-threshold' => qr/^\d+(?:\.\d+)?$/,
+ 'ha-auto-rebalance-method' => qr/^(?:bruteforce|topsis)$/,
+ 'ha-auto-rebalance-hold-duration' => qr/^\d+$/,
+ 'ha-auto-rebalance-margin' => qr/^\d+(?:\.\d+)?$/,
+ 'ha-auto-rebalance-cpu-weight' => qr/^\d+$/,
+ 'ha-auto-rebalance-mem-weight' => qr/^\d+$/,
+ },
+};
+
+sub update_datacenter_setting {
+ my ($self, $section, $action, $key, $value) = @_;
+
+ my $section_props = $datacenter_settings->{$section}
+ or die "sim_hardware_cmd: unknown datacenter section '$section'\n";
+
+ die "sim_hardware_cmd: missing property for 'datacenter $section $action' command\n"
+ if !defined($key);
+
+ my $verifier = $section_props->{$key}
+ or die "sim_hardware_cmd: unknown datacenter property '$key' in section '$section'\n";
+
+ my $conf = $self->read_datacenter_conf();
+
+ if ($action eq 'set') {
+ die "sim_hardware_cmd: missing value for 'datacenter $section set $key' command\n"
+ if !defined($value);
+ die "sim_hardware_cmd: invalid value '$value' for datacenter property '$section.$key'\n"
+ if $value !~ $verifier;
+
+ $value = $value + 0 if $value =~ m/^\d+(?:\.\d+)?$/;
+
+ $conf->{$section}->{$key} = $value;
+ } elsif ($action eq 'delete') {
+ delete $conf->{$section}->{$key} if $conf->{$section};
+ delete $conf->{$section} if $conf->{$section} && !%{ $conf->{$section} };
+ } else {
+ die "sim_hardware_cmd: unknown datacenter action '$action'\n";
+ }
+
+ $self->write_datacenter_conf($conf);
+
+ return $conf;
+}
+
sub global_lock {
my ($self, $code, @param) = @_;
@@ -802,6 +855,8 @@ sub get_cfs_state {
# service <sid> set-static-stats [maxcpu <cores>] [maxmem <MiB>]
# service <sid> set-dynamic-stats [cpu <cores>] [mem <MiB>]
# service <sid> delete
+# datacenter <ha|crs> set <property> <value>
+# datacenter <ha|crs> delete <property>
sub sim_hardware_cmd {
my ($self, $cmdstr, $logid) = @_;
@@ -820,6 +875,8 @@ sub sim_hardware_cmd {
if ($cmd eq 'service') {
$sid = PVE::HA::Tools::pve_verify_ha_resource_id($objid);
+ } elsif ($cmd eq 'datacenter') {
+ # cluster-wide, neither node nor service specific
} else {
$node = $objid;
$d = $self->{nodes}->{$node}
@@ -1028,6 +1085,11 @@ sub sim_hardware_cmd {
die "sim_hardware_cmd: unknown service action '$action' "
. "- not implemented\n";
}
+ } elsif ($cmd eq 'datacenter') {
+ die "sim_hardware_cmd: missing action for 'datacenter $objid' command\n"
+ if !defined($action);
+
+ $self->update_datacenter_setting($objid, $action, @params);
} else {
die "sim_hardware_cmd: unknown command '$cmdstr'\n";
}
--
2.47.3
next prev parent reply other threads:[~2026-10-21 9:00 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 8:59 [RFC PATCH-SERIES cluster/ha-manager/manager/proxmox{,-perl-rs} 00/15] fix #7993: implement weighted auto rebalancing Dominik Rusovac
2026-10-21 8:59 ` [PATCH proxmox 01/15] resource-scheduling: scheduler: fix typos Dominik Rusovac
2026-10-21 8:59 ` [PATCH proxmox 02/15] resource-scheduling: scheduler: abstract post-migration stats logic Dominik Rusovac
2026-10-21 12:49 ` Daniel Kral
2026-10-21 8:59 ` [PATCH proxmox 03/15] fix #7993: resource-scheduling: lift to weighted load balancing Dominik Rusovac
2026-10-21 8:59 ` [PATCH proxmox 04/15] workspace,resource-scheduling: add proptest crate Dominik Rusovac
2026-10-21 8:59 ` [PATCH proxmox 05/15] resource-scheduling: scheduler: proptest weights Dominik Rusovac
2026-10-21 8:59 ` [PATCH proxmox-perl-rs 06/15] fix #7993: pve-rs: resource-scheduling: add weights to pve bindings Dominik Rusovac
2026-10-21 8:59 ` [PATCH pve-manager 07/15] fix #7993: ui: form: crs options: add weights Dominik Rusovac
2026-10-21 8:59 ` [PATCH pve-manager 08/15] ui: form: crs options: make options advanced Dominik Rusovac
2026-10-21 8:59 ` [PATCH pve-ha-manager 09/15] manager: remove obsolete argument Dominik Rusovac
2026-10-21 8:59 ` [PATCH pve-ha-manager 10/15] fix #7993: manager,usage: implement weighted auto rebalancing Dominik Rusovac
2026-10-21 8:59 ` Dominik Rusovac [this message]
2026-10-21 8:59 ` [PATCH pve-ha-manager 12/15] manager: log changes to crs settings Dominik Rusovac
2026-10-21 8:59 ` [PATCH pve-ha-manager 13/15] test: add auto rebalance with weights test cases Dominik Rusovac
2026-10-21 8:59 ` [PATCH pve-ha-manager 14/15] manager: rename update_crs_scheduler_mode Dominik Rusovac
2026-10-21 8:59 ` [PATCH pve-cluster 15/15] fix #7993: datacenter config: add ha-auto-rebalance-{cpu,mem}-weight Dominik Rusovac
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=20261021085932.1196302-12-d.rusovac@proxmox.com \
--to=d.rusovac@proxmox.com \
--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.