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 EE5591FF09F for ; Tue, 01 Dec 2026 11:18:50 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 53AFD21861; Tue, 01 Dec 2026 11:17:33 +0100 (CET) From: Dominik Rusovac To: pve-devel@lists.proxmox.com Subject: [PATCH pve-ha-manager v3 15/19] manager: factor out crs option update helper Date: Tue, 1 Dec 2026 11:16:55 +0100 Message-ID: <20261201101659.3690943-16-d.rusovac@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261201101659.3690943-1-d.rusovac@proxmox.com> References: <20261201101659.3690943-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: 1796120225389 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.020 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: PIEA2ETL2SXGPUF5BOW63L7KK7SFDY4C X-Message-ID-Hash: PIEA2ETL2SXGPUF5BOW63L7KK7SFDY4C 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 Reviewed-by: Daniel Kral --- Notes: changes since v2: * drop unnecessary fallback 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 | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm index bfc4584..51991cd 100644 --- a/src/PVE/HA/Manager.pm +++ b/src/PVE/HA/Manager.pm @@ -101,6 +101,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) = @_; @@ -108,6 +127,10 @@ 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', + ); + $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 @@ -121,19 +144,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