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 988551FF133 for ; Mon, 11 May 2026 11:48:06 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5C3EF10B0B; Mon, 11 May 2026 11:47:36 +0200 (CEST) From: Daniel Kral To: pve-devel@lists.proxmox.com Subject: [PATCH ha-manager v3 11/17] manager: store global reference to service config hash Date: Mon, 11 May 2026 11:46:32 +0200 Message-ID: <20260511094707.142930-12-d.kral@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260511094707.142930-1-d.kral@proxmox.com> References: <20260511094707.142930-1-d.kral@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1778492723585 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: 7U5IBZR3GZIYLBWPGEUASEQXZ4F5DTAM X-Message-ID-Hash: 7U5IBZR3GZIYLBWPGEUASEQXZ4F5DTAM 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: This is in preparation for an upcoming patch, which makes get_resource_motion_info() aware of the HA resources' failback flag in conjunction with node affinity rules. This change is chosen in favor of passing down the $sc variable through several method calls that otherwise wouldn't need a reference to the service config hash in the upcoming patch. Signed-off-by: Daniel Kral --- changes v2 -> v3: - new src/PVE/HA/Manager.pm | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm index 2d1c6d5d..c4088dac 100644 --- a/src/PVE/HA/Manager.pm +++ b/src/PVE/HA/Manager.pm @@ -82,6 +82,7 @@ sub new { $self->{ns} = PVE::HA::NodeStatus->new($haenv, $old_ms->{node_status} || {}); # fixme: use separate class PVE::HA::ServiceStatus + $self->{sc} = {}; $self->{ss} = $old_ms->{service_status} || {}; $self->{ms} = { master_node => $haenv->nodename() }; @@ -1002,7 +1003,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 +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}->%*) { 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,10 @@ sub manage { # remove stale or ignored services from manager state foreach my $sid (keys %$ss) { - next if $sc->{$sid} && $sc->{$sid}->{state} ne 'ignored'; + 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 +1045,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 +1054,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 +1090,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