all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Rusovac <d.rusovac@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-ha-manager v2 2/3] manager: set service config value in self
Date: Wed, 13 May 2026 12:46:56 +0200	[thread overview]
Message-ID: <20260513104657.1105858-3-d.rusovac@proxmox.com> (raw)
In-Reply-To: <20260513104657.1105858-1-d.rusovac@proxmox.com>

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>
---

Notes:
    changes since v1:
    * replace close by 'foreach's with 'for'
    * declare and use $cd variable for the sake of DRY
    * adjust calls to use $self->{sc}
    * init empty $self->{sc} in constructor

 src/PVE/HA/Manager.pm | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm
index b69a6bb..ff2a756 100644
--- a/src/PVE/HA/Manager.pm
+++ b/src/PVE/HA/Manager.pm
@@ -82,6 +82,8 @@ sub new {
     # fixme: use separate class  PVE::HA::ServiceStatus
     $self->{ss} = $old_ms->{service_status} || {};
 
+    $self->{sc} = {};
+
     $self->{ms} = { master_node => $haenv->nodename() };
 
     # take over node request state to ensure a node in (manual) maintenance mode stays that way
@@ -1002,7 +1004,7 @@ sub manage {
 
     $self->try_persistent_group_migration();
 
-    my ($sc, $services_digest) = $haenv->read_service_config();
+    ($self->{sc}, my $services_digest) = $haenv->read_service_config();
 
     $self->{groups} = $haenv->read_group_config(); # update
 
@@ -1011,9 +1013,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) {
+        for my $sid (sort keys $self->{sc}->%*) {
             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}'");
@@ -1027,10 +1029,11 @@ sub manage {
         }
 
         # remove stale or ignored services from manager state
-        foreach my $sid (keys %$ss) {
-            next if $sc->{$sid} && $sc->{$sid}->{state} ne 'ignored';
+        for my $sid (keys %$ss) {
+            my $cd = $self->{sc}->{$sid};
+            next if $cd && $cd->{state} ne 'ignored';
 
-            my $reason = defined($sc->{$sid}) ? 'ignored state requested' : 'no config';
+            my $reason = defined($cd) ? 'ignored state requested' : 'no config';
             $haenv->log('info', "removing stale service '$sid' ($reason)");
 
             # remove all service related state information
@@ -1043,7 +1046,7 @@ sub manage {
     my $new_rules = $haenv->read_rules_config();
 
     # TODO PVE 10: Remove group migration when HA groups have been fully migrated to rules
-    PVE::HA::Groups::migrate_groups_to_resources($self->{groups}, $sc);
+    PVE::HA::Groups::migrate_groups_to_resources($self->{groups}, $self->{sc});
 
     if (
         !$self->{compiled_rules}
@@ -1052,7 +1055,7 @@ sub manage {
         || $self->{groups}->{digest} ne $self->{last_groups_digest}
         || $services_digest && $services_digest ne $self->{last_services_digest}
     ) {
-        PVE::HA::Groups::migrate_groups_to_rules($new_rules, $self->{groups}, $sc);
+        PVE::HA::Groups::migrate_groups_to_rules($new_rules, $self->{groups}, $self->{sc});
 
         my $nodes = $self->{ns}->list_nodes();
         my $messages = PVE::HA::Rules->transform($new_rules, $nodes);
@@ -1088,7 +1091,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;
 
-- 
2.47.3





  parent reply	other threads:[~2026-05-13 10:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-13 10:46 [PATCH-SERIES ha-manager/manager v2 0/3] fix #7557: introduce 'auto-rebalance' property Dominik Rusovac
2026-05-13 10:46 ` [PATCH pve-manager v2 1/3] ui: ha: add auto-rebalance flag Dominik Rusovac
2026-05-13 10:46 ` Dominik Rusovac [this message]
2026-05-13 12:05 ` [PATCH-SERIES ha-manager/manager v2 0/3] fix #7557: introduce 'auto-rebalance' property Daniel Kral

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=20260513104657.1105858-3-d.rusovac@proxmox.com \
    --to=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal