public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Daniel Kral" <d.kral@proxmox.com>
To: "Dominik Rusovac" <d.rusovac@proxmox.com>, <pve-devel@lists.proxmox.com>
Subject: Re: [PATCH pve-ha-manager 2/3] manager: set service config value in self
Date: Tue, 12 May 2026 11:06:14 +0200	[thread overview]
Message-ID: <DIGKUIL9KIXT.1Q88CZJSWGEP@proxmox.com> (raw)
In-Reply-To: <20260511155734.149101-3-d.rusovac@proxmox.com>

Looks good to me, left a few nits inline, with those resolved consider
this patch as:

Reviewed-by: Daniel Kral <d.kral@proxmox.com>

On Mon May 11, 2026 at 5:57 PM CEST, Dominik Rusovac wrote:
> This is in preparation for the follow-up patch.
>
> Reading the value of 'auto-rebalance'-flag in the service config of an
> HA resource is required to perform proper resource bundling.
>
> Signed-off-by: Dominik Rusovac <d.rusovac@proxmox.com>
> ---
>  src/PVE/HA/Manager.pm | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm
> index b69a6bb..2a4b31e 100644
> --- a/src/PVE/HA/Manager.pm
> +++ b/src/PVE/HA/Manager.pm
> @@ -1003,6 +1003,7 @@ sub manage {
>      $self->try_persistent_group_migration();
>  
>      my ($sc, $services_digest) = $haenv->read_service_config();
> +    $self->{sc} = $sc;

nit: could be

    ($self->{sc}, my $services_digest) = $haenv->read_service_config();

would need a few more s/$sc/$self->{sc}/

>  
>      $self->{groups} = $haenv->read_group_config(); # update
>  
> @@ -1011,9 +1012,9 @@ sub manage {
>      # skip service add/remove when disarmed - handle_disarm manages service status
>      if (!$ms->{disarm}) {
>          # add new service
> -        foreach my $sid (sort keys %$sc) {
> +        foreach my $sid (sort keys $self->{sc}->%*) {

nit: pre-existing, but foreach is a synonym for for and we prefer the
latter according to our Perl Style Guide.

We don't change all at once to cause unnecessary merge conflicts for
already existing patch series, but usually change these when we touch
the relevant line/context, so it can be changed here and for other
foreach's you touch (at least I do so ^^).

>              next if $ss->{$sid}; # already there
> -            my $cd = $sc->{$sid};
> +            my $cd = $self->{sc}->{$sid};
>              next if $cd->{state} eq 'ignored';
>  
>              $haenv->log('info', "adding new service '$sid' on node '$cd->{node}'");
> @@ -1028,9 +1029,9 @@ sub manage {
>  
>          # remove stale or ignored services from manager state
>          foreach my $sid (keys %$ss) {

nit: could also have a

    my $cd = $self->{sc}->{$sid};

so we don't need to repeat the $self->{sc}->{$sid}

> -            next if $sc->{$sid} && $sc->{$sid}->{state} ne 'ignored';
> +            next if $self->{sc}->{$sid} && $self->{sc}->{$sid}->{state} ne 'ignored';
>  
> -            my $reason = defined($sc->{$sid}) ? 'ignored state requested' : 'no config';
> +            my $reason = defined($self->{sc}->{$sid}) ? 'ignored state requested' : 'no config';
>              $haenv->log('info', "removing stale service '$sid' ($reason)");
>  
>              # remove all service related state information
> @@ -1088,7 +1089,7 @@ sub manage {
>          foreach my $sid (sort keys %$ss) {
>              next if $deferred_sids && !$deferred_sids->{$sid};
>              my $sd = $ss->{$sid};
> -            my $cd = $sc->{$sid} || { state => 'disabled' };
> +            my $cd = $self->{sc}->{$sid} || { state => 'disabled' };
>  
>              my $lrm_res = $sd->{uid} ? $lrm_results->{ $sd->{uid} } : undef;
>  

The migrate_groups_to_{resources,rules}() calls later in manage() should
use $self->{sc} too.

nit: Also to be safe, add

    $self->{sc} = {};

to PVE::HA::Manager::new(), or maybe even initialize it with
$haenv->read_service_config(), though we don't have any need to read it
before the assignment in PVE::HA::Manager::manage().




  reply	other threads:[~2026-05-12  9:06 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-11 15:57 [PATCH-SERIES ha-manager/manager 0/3] fix #7557: introduce 'auto-rebalance' property Dominik Rusovac
2026-05-11 15:57 ` [PATCH pve-manager 1/3] ui: ha: add auto-rebalance flag Dominik Rusovac
2026-05-12  9:05   ` Daniel Kral
2026-05-11 15:57 ` [PATCH pve-ha-manager 2/3] manager: set service config value in self Dominik Rusovac
2026-05-12  9:06   ` Daniel Kral [this message]
2026-05-12 11:55     ` Dominik Rusovac
2026-05-11 15:57 ` [PATCH pve-ha-manager 3/3] fix #7557: introduce 'auto-rebalance' property Dominik Rusovac
2026-05-12  9:07   ` Daniel Kral
2026-05-12 11:51     ` Dominik Rusovac
2026-05-12  9:21 ` [PATCH-SERIES ha-manager/manager 0/3] " Daniel Kral
2026-05-12 11:53   ` Dominik Rusovac

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DIGKUIL9KIXT.1Q88CZJSWGEP@proxmox.com \
    --to=d.kral@proxmox.com \
    --cc=d.rusovac@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal