From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id CB8F11FF0AF for ; Fri, 20 Nov 2026 14:46:46 +0100 (CET) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 5ABB621766; Fri, 20 Nov 2026 14:46:45 +0100 (CET) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 20 Nov 2026 14:46:41 +0100 Message-Id: To: "Dominik Rusovac" , Subject: Re: [PATCH pve-ha-manager v2 15/19] manager: factor out crs option update helper From: "Daniel Kral" X-Mailer: aerc 0.22.0-45-gc30c872fde7b-dirty References: <20261112094437.1951271-1-d.rusovac@proxmox.com> <20261112094437.1951271-16-d.rusovac@proxmox.com> In-Reply-To: <20261112094437.1951271-16-d.rusovac@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1795182401097 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.422 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: KRXJJBM25PE75SBKZWK7RY464FIGW55Z X-Message-ID-Hash: KRXJJBM25PE75SBKZWK7RY464FIGW55Z X-MailFrom: d.kral@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: Modulo the nit, consider as: Reviewed-by: Daniel Kral On Thu Nov 12, 2026 at 10:44 AM CET, Dominik Rusovac wrote: > 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 > =20 > [0] https://lore.proxmox.com/pve-devel/20261021085932.1196302-13-d.ru= sovac@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; > } > =20 > +sub update_crs_option { > + my ($self, $name, $option_ref, $value, $default) =3D @_; > + > + my $haenv =3D $self->{haenv}; > + > + my $old_value =3D $$option_ref; > + my $new_value =3D $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 =3D $new_value; > + > + return; > +} > + > sub update_crs_settings { > my ($self) =3D @_; > =20 > @@ -106,6 +125,13 @@ sub update_crs_settings { > my $dc_cfg =3D $haenv->get_datacenter_settings(); > my $crs_cfg =3D $dc_cfg->{crs} // {}; > =20 > + $self->update_crs_option( > + 'scheduler mode', > + \$self->{crs}->{scheduler}, > + $crs_cfg->{ha} || 'basic', nit: the `|| 'basic'` shouldn't be needed here, no? > + 'basic', > + ); > + > $self->{crs}->{rebalance_on_request_start} =3D !!$crs_cfg->{'ha-reba= lance-on-start'}; > $self->{crs}->{auto_rebalance}->{enable} =3D !!$crs_cfg->{'ha-auto-r= ebalance'}; > # 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} =3D > ($crs_cfg->{'ha-auto-rebalance-margin'} // 10) / 100.0; > =20 > - my $old_mode =3D $self->{crs}->{scheduler}; > - my $new_mode =3D $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' t= o '$new_mode'"); > - } > - > - $self->{crs}->{scheduler} =3D $new_mode; > - > return; > } > =20