public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Rusovac <d.rusovac@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-ha-manager v2 15/19] manager: factor out crs option update helper
Date: Thu, 12 Nov 2026 10:44:33 +0100	[thread overview]
Message-ID: <20261112094437.1951271-16-d.rusovac@proxmox.com> (raw)
In-Reply-To: <20261112094437.1951271-1-d.rusovac@proxmox.com>

factor out logic that updates the scheduler mode and logs its changes
into a helper, so that it can be reused for the other CRS options. the
logged messages for the scheduler mode stay the same

scheduler mode is now updated first, so that it is logged before any
other CRS option once these are logged too

Suggested-by: Daniel Kral <d.kral@proxmox.com>
Signed-off-by: Dominik Rusovac <d.rusovac@proxmox.com>
---

Notes:
    new with changes regarding patch [0] in v1:
    * add helper suggested by daniel
    * as suggested, split out of patch [0] in v1
    
    [0] https://lore.proxmox.com/pve-devel/20261021085932.1196302-13-d.rusovac@proxmox.com/

 src/PVE/HA/Manager.pm | 39 ++++++++++++++++++++++++++-------------
 1 file changed, 26 insertions(+), 13 deletions(-)

diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm
index b206719..a91eec3 100644
--- a/src/PVE/HA/Manager.pm
+++ b/src/PVE/HA/Manager.pm
@@ -99,6 +99,25 @@ sub new {
     return $self;
 }
 
+sub update_crs_option {
+    my ($self, $name, $option_ref, $value, $default) = @_;
+
+    my $haenv = $self->{haenv};
+
+    my $old_value = $$option_ref;
+    my $new_value = $value // $default;
+
+    if (!defined($old_value)) {
+        $haenv->log('info', "using $name '$new_value'") if $new_value ne $default;
+    } elsif ($old_value ne $new_value) {
+        $haenv->log('info', "switching $name from '$old_value' to '$new_value'");
+    }
+
+    $$option_ref = $new_value;
+
+    return;
+}
+
 sub update_crs_settings {
     my ($self) = @_;
 
@@ -106,6 +125,13 @@ sub update_crs_settings {
     my $dc_cfg = $haenv->get_datacenter_settings();
     my $crs_cfg = $dc_cfg->{crs} // {};
 
+    $self->update_crs_option(
+        'scheduler mode',
+        \$self->{crs}->{scheduler},
+        $crs_cfg->{ha} || 'basic',
+        'basic',
+    );
+
     $self->{crs}->{rebalance_on_request_start} = !!$crs_cfg->{'ha-rebalance-on-start'};
     $self->{crs}->{auto_rebalance}->{enable} = !!$crs_cfg->{'ha-auto-rebalance'};
     # configured as percent for UI/config consistency, scaled to [0, 1] to match the
@@ -119,19 +145,6 @@ sub update_crs_settings {
     $self->{crs}->{auto_rebalance}->{margin} =
         ($crs_cfg->{'ha-auto-rebalance-margin'} // 10) / 100.0;
 
-    my $old_mode = $self->{crs}->{scheduler};
-    my $new_mode = $crs_cfg->{ha} || 'basic';
-
-    if (!defined($old_mode)) {
-        $haenv->log('info', "using scheduler mode '$new_mode'") if $new_mode ne 'basic';
-    } elsif ($new_mode eq $old_mode) {
-        return; # nothing to do
-    } else {
-        $haenv->log('info', "switching scheduler mode from '$old_mode' to '$new_mode'");
-    }
-
-    $self->{crs}->{scheduler} = $new_mode;
-
     return;
 }
 
-- 
2.47.3





  parent reply	other threads:[~2026-11-12  9:46 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12  9:44 [RFC PATCH-SERIES cluster/ha-manager/manager/proxmox{,-perl-rs} v2 00/19] fix #7993: implement weighted crs load balancing Dominik Rusovac
2026-11-12  9:44 ` [PATCH proxmox v2 01/19] resource-scheduling: fix typos Dominik Rusovac
2026-11-19 12:27   ` Daniel Kral
2026-11-12  9:44 ` [PATCH proxmox v2 02/19] resource-scheduling: scheduler: refine score_* docs Dominik Rusovac
2026-11-19 12:27   ` Daniel Kral
2026-11-19 12:47     ` Dominik Rusovac
2026-11-12  9:44 ` [PATCH proxmox v2 03/19] resource-scheduling: scheduler: abstract post-migration stats logic Dominik Rusovac
2026-11-19 12:28   ` Daniel Kral
2026-11-19 12:47     ` Dominik Rusovac
2026-11-12  9:44 ` [PATCH proxmox v2 04/19] fix #7993: resource-scheduling: node: add weighted node load Dominik Rusovac
2026-11-19 12:28   ` Daniel Kral
2026-11-19 12:50     ` Dominik Rusovac
2026-11-12  9:44 ` [PATCH proxmox v2 05/19] resource-scheduling: scheduler: make imbalance with candidate public Dominik Rusovac
2026-11-19 12:41   ` Daniel Kral
2026-11-19 12:52     ` Dominik Rusovac
2026-11-12  9:44 ` [PATCH proxmox v2 06/19] fix #7993: resource-scheduling: scheduler: add weights Dominik Rusovac
2026-11-19 12:40   ` Daniel Kral
2026-11-19 13:52     ` Dominik Rusovac
2026-11-12  9:44 ` [PATCH proxmox v2 07/19] workspace,resource-scheduling: add proptest as dev-dependency Dominik Rusovac
2026-11-12  9:44 ` [PATCH proxmox v2 08/19] resource-scheduling: scheduler: add property tests for weights Dominik Rusovac
2026-11-12  9:44 ` [PATCH proxmox-perl-rs v2 09/19] fix #7993: pve-rs: resource-scheduling: add scheduler options Dominik Rusovac
2026-11-19 12:45   ` Daniel Kral
2026-11-19 13:28     ` Dominik Rusovac
2026-11-12  9:44 ` [PATCH pve-cluster v2 10/19] fix #7993: datacenter config: ad ha-{cpu,mem}-weight crs options Dominik Rusovac
2026-11-12  9:44 ` [PATCH pve-manager v2 11/19] ui: form: crs options: make fine-tuning options advanced Dominik Rusovac
2026-11-12  9:44 ` [PATCH pve-manager v2 12/19] fix #7993: ui: form: crs options: add weights Dominik Rusovac
2026-11-12  9:44 ` [PATCH pve-ha-manager v2 13/19] manager: remove obsolete argument Dominik Rusovac
2026-11-12  9:44 ` [PATCH pve-ha-manager v2 14/19] manager: rename update_crs_scheduler_mod to update_crs_settings Dominik Rusovac
2026-11-12  9:44 ` Dominik Rusovac [this message]
2026-11-12  9:44 ` [PATCH pve-ha-manager v2 16/19] manager: log changes to crs settings Dominik Rusovac
2026-11-12  9:44 ` [PATCH pve-ha-manager v2 17/19] sim: hardware: allow changing datacenter settings at runtime Dominik Rusovac
2026-11-12  9:44 ` [PATCH pve-ha-manager v2 18/19] fix #7993: manager,usage: use weights for static and dynamic mode Dominik Rusovac
2026-11-12  9:44 ` [PATCH pve-ha-manager v2 19/19] test: add automatic rebalancing test cases with weights 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=20261112094437.1951271-16-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 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