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 7BCA11FF146 for ; Tue, 12 May 2026 13:52:00 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7B25A107CF; Tue, 12 May 2026 13:51:57 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 12 May 2026 13:51:47 +0200 Message-Id: From: "Dominik Rusovac" To: "Daniel Kral" , Subject: Re: [PATCH pve-ha-manager 3/3] fix #7557: introduce 'auto-rebalance' property X-Mailer: aerc 0.20.0 References: <20260511155734.149101-1-d.rusovac@proxmox.com> <20260511155734.149101-4-d.rusovac@proxmox.com> In-Reply-To: X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1778586595578 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.358 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [pvevm.pm,hardware.pm,status.pm,pvect.pm,config.pm,manager.pm,resources.pm] Message-ID-Hash: BKEVYSR4AKJ3MCMPZX4QVIQQWXB67BRT X-Message-ID-Hash: BKEVYSR4AKJ3MCMPZX4QVIQQWXB67BRT 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: thx for taking the time=20 will send a v2=20 On Tue May 12, 2026 at 11:07 AM CEST, Daniel Kral wrote: > 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 rebala= ncing.", > > seems to work fine. > ACK >> + type =3D> 'boolean', >> + optional =3D> 1, >> + default =3D> 1, >> + }, >> group =3D> get_standard_option('pve-ha-group-id', { optiona= l =3D> 1 }), >> max_restart =3D> { >> description =3D> "Maximal number of tries to restart th= e 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 durin= g" >> + . " automatic rebalancing.", > > same here > ACK >> + 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 fail= back comment)) { >> + foreach my $key (qw(group max_restart max_relocate fail= back 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}); > } > ACK >> $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'; # backwa= rd 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 = bundle >> # 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. > will update the description >> - 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 reso= urce >> 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 'relocat= e'; >> # do not add non-started resource to active bundle >> next if $state ne 'started'; >> + # do not consider stationary bundle if a dependent reso= urce 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_= bundles.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_affi= nity)}; >> + my ($ss, $sc, $resource_affinity) =3D $case->@{qw(services service_= config resource_affinity)}; >> =20 >> - my $result =3D PVE::HA::Manager::get_active_stationary_resource_bun= dles($ss, $resource_affinity); >> + my $result =3D PVE::HA::Manager::get_active_stationary_resource_bun= dles($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); > > ACK >> =20 >> is_deeply($result, $case->{resource_bundles}, $case->{description})= ; >> }