From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 261571FF0B6 for ; Thu, 12 Nov 2026 10:46:30 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id A160521667; Thu, 12 Nov 2026 10:45:01 +0100 (CET) From: Dominik Rusovac 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 Message-ID: <20261112094437.1951271-16-d.rusovac@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261112094437.1951271-1-d.rusovac@proxmox.com> References: <20261112094437.1951271-1-d.rusovac@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1794476686356 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.036 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: DJGH4JKSHN3Y5MKPNIVNZ5YLRLCAFESA X-Message-ID-Hash: DJGH4JKSHN3Y5MKPNIVNZ5YLRLCAFESA X-MailFrom: d.rusovac@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: 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 Signed-off-by: Dominik Rusovac --- 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