From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 312151FF146 for ; Tue, 12 May 2026 11:08:27 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 0D332AE48; Tue, 12 May 2026 11:08:27 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 12 May 2026 11:07:47 +0200 Message-Id: From: "Daniel Kral" To: "Dominik Rusovac" , Subject: Re: [PATCH pve-ha-manager 3/3] fix #7557: introduce 'auto-rebalance' property X-Mailer: aerc 0.21.0-136-gdb9fe9896a79-dirty References: <20260511155734.149101-1-d.rusovac@proxmox.com> <20260511155734.149101-4-d.rusovac@proxmox.com> In-Reply-To: <20260511155734.149101-4-d.rusovac@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1778576755798 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.076 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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: N5PUG6GT3J3X6A6B7EX2RARMPIZBXU3D X-Message-ID-Hash: N5PUG6GT3J3X6A6B7EX2RARMPIZBXU3D 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: Very nice test case additions for the new functionality, thanks for the series! Only a small nit about a method name and some make tidy notes, but otherwise it looks good to me, so with those resolved consider this as: Reviewed-by: Daniel Kral On Mon May 11, 2026 at 5:57 PM CEST, Dominik Rusovac wrote: > Add 'auto-rebalance' property to HA resources config, which gives users > control over which HA resources may be moved by dynamic CRS during > automatic rebalancing. > > The 'auto-rebalance' flag is set to true by default. Disabling > 'auto-rebalance' for some HA resource, say vm:100, means that vm:100 > will be disregarded as a migration candidate during auto-rebalancing. > Any HA resource with a positive affinity for vm:100 will be disregarded > too. > > Tests validate that an entire resource bundle will be disregarded if any > resource belonging to the bundle has 'auto-rebalance' disabled. > > Signed-off-by: Dominik Rusovac > --- > src/PVE/API2/HA/Resources.pm | 7 ++ > src/PVE/API2/HA/Status.pm | 9 +- > src/PVE/HA/Config.pm | 2 + > src/PVE/HA/Manager.pm | 12 ++- > src/PVE/HA/Resources.pm | 6 ++ > src/PVE/HA/Resources/PVECT.pm | 1 + > src/PVE/HA/Resources/PVEVM.pm | 1 + > src/PVE/HA/Sim/Hardware.pm | 1 + > src/test/test_resource_bundles.pl | 134 +++++++++++++++++++++++++++++- > 9 files changed, 166 insertions(+), 7 deletions(-) > > diff --git a/src/PVE/API2/HA/Resources.pm b/src/PVE/API2/HA/Resources.pm > index e0690d5..181cdbb 100644 > --- a/src/PVE/API2/HA/Resources.pm > +++ b/src/PVE/API2/HA/Resources.pm > @@ -142,6 +142,13 @@ __PACKAGE__->register_method({ > optional =3D> 1, > default =3D> 1, > }, > + 'auto-rebalance' =3D> { > + description =3D> "HA resource may be migrated during" > + . " automatic rebalancing.", make tidy wants this to be in a single line, but description =3D> "HA resource may be migrated during automatic rebalanc= ing.", seems to work fine. > + type =3D> 'boolean', > + optional =3D> 1, > + default =3D> 1, > + }, > group =3D> get_standard_option('pve-ha-group-id', { optional= =3D> 1 }), > max_restart =3D> { > description =3D> "Maximal number of tries to restart the= service on" > diff --git a/src/PVE/API2/HA/Status.pm b/src/PVE/API2/HA/Status.pm > index 4894f3b..c352aa1 100644 > --- a/src/PVE/API2/HA/Status.pm > +++ b/src/PVE/API2/HA/Status.pm > @@ -121,6 +121,13 @@ __PACKAGE__->register_method({ > optional =3D> 1, > default =3D> 1, > }, > + 'auto-rebalance' =3D> { > + description =3D> "HA resource may be migrated during= " > + . " automatic rebalancing.", same here > + type =3D> 'boolean', > + optional =3D> 1, > + default =3D> 1, > + }, > max_relocate =3D> { > description =3D> "For type 'service'.", > type =3D> "integer", > @@ -333,7 +340,7 @@ __PACKAGE__->register_method({ > # also return common resource attributes > if (defined($sc)) { > $data->{request_state} =3D $sc->{state}; > - foreach my $key (qw(group max_restart max_relocate failb= ack comment)) { > + foreach my $key (qw(group max_restart max_relocate failb= ack comment auto-rebalance)) { make tidy wants to move the quoted whitespace array to a new line... Might look just a little bit nicer with: my @exported_service_properties =3D qw(group max_restart max_relocate failback comment auto-rebalance); for my $key (@exported_service_properties) { $data->{$key} =3D $sc->{$key} if defined($sc->{$key}); } > $data->{$key} =3D $sc->{$key} if defined($sc->{$key}= ); > } > } > diff --git a/src/PVE/HA/Config.pm b/src/PVE/HA/Config.pm > index a34a302..54a6503 100644 > --- a/src/PVE/HA/Config.pm > +++ b/src/PVE/HA/Config.pm > @@ -118,8 +118,10 @@ sub read_and_check_resources_config { > $d->{state} =3D 'started' if !defined($d->{state}); > $d->{state} =3D 'started' if $d->{state} eq 'enabled'; # backwar= d compatibility > $d->{failback} =3D 1 if !defined($d->{failback}); > + $d->{'auto-rebalance'} =3D 1 if !defined($d->{'auto-rebalance'})= ; > $d->{max_restart} =3D 1 if !defined($d->{max_restart}); > $d->{max_relocate} =3D 1 if !defined($d->{max_relocate}); > + > if (PVE::HA::Resources->lookup($d->{type})) { > if (my $vmd =3D $vmlist->{ids}->{$name}) { > $d->{node} =3D $vmd->{node}; > diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm > index 2a4b31e..68e3cd6 100644 > --- a/src/PVE/HA/Manager.pm > +++ b/src/PVE/HA/Manager.pm > @@ -136,12 +136,14 @@ sub update_crs_scheduler_mode { > # HA resource in the resource bundle and also the key of each resource b= undle > # in the returned hash. > sub get_active_stationary_resource_bundles { nit: Hm, might need a better name now that we have an additional condition on which resource bundles are gathered, e.g. get_active_stationary_movable_resource_bundles though that's rather long. No hard feelings though, but updating the description would be nice. > - my ($ss, $resource_affinity) =3D @_; > + my ($ss, $sc, $resource_affinity) =3D @_; > =20 > my $resource_bundles =3D {}; > OUTER: for my $sid (sort keys %$ss) { > # do not consider non-started resource as 'active' leading resou= rce > next if $ss->{$sid}->{state} ne 'started'; > + # do not consider resource if it may not be moved > + next if !$sc->{$sid}->{'auto-rebalance'}; > =20 > my @resources =3D ($sid); > my $nodes =3D { $ss->{$sid}->{node} =3D> 1 }; > @@ -156,6 +158,8 @@ OUTER: for my $sid (sort keys %$ss) { > next OUTER if $state eq 'migrate' || $state eq 'relocate= '; > # do not add non-started resource to active bundle > next if $state ne 'started'; > + # do not consider stationary bundle if a dependent resou= rce may not be moved > + next OUTER if !$sc->{$csid}->{'auto-rebalance'}; > =20 > $nodes->{$node} =3D 1; > =20 [ ... ] > diff --git a/src/test/test_resource_bundles.pl b/src/test/test_resource_b= undles.pl > index d38dc51..7df96a9 100755 > --- a/src/test/test_resource_bundles.pl > +++ b/src/test/test_resource_bundles.pl > @@ -224,9 +354,9 @@ my $tests =3D [ > plan(tests =3D> scalar($tests->@*)); > =20 > for my $case ($get_active_stationary_resource_bundle_tests->@*) { > - my ($ss, $resource_affinity) =3D $case->@{qw(services resource_affin= ity)}; > + my ($ss, $sc, $resource_affinity) =3D $case->@{qw(services service_c= onfig resource_affinity)}; > =20 > - my $result =3D PVE::HA::Manager::get_active_stationary_resource_bund= les($ss, $resource_affinity); > + my $result =3D PVE::HA::Manager::get_active_stationary_resource_bund= les($ss, $sc, $resource_affinity); make tidy wants this to be my $result =3D PVE::HA::Manager::get_active_stationary_resource_bundles($ss, $sc, = $resource_affinity); > =20 > is_deeply($result, $case->{resource_bundles}, $case->{description}); > }