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 D1A121FF165 for ; Thu, 31 Jul 2025 10:34:28 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9DA1035FC4; Thu, 31 Jul 2025 10:35:55 +0200 (CEST) Mime-Version: 1.0 Date: Thu, 31 Jul 2025 10:35:52 +0200 Message-Id: To: "Proxmox VE development discussion" From: "Daniel Kral" X-Mailer: aerc 0.20.0 References: <20250730175957.386674-1-d.kral@proxmox.com> <20250730175957.386674-11-d.kral@proxmox.com> In-Reply-To: <20250730175957.386674-11-d.kral@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1753950940474 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.014 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 Subject: Re: [pve-devel] [PATCH ha-manager v5 10/23] manager: migrate ha groups to node affinity rules in-memory X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Cc: pve-devel , Thomas Lamprecht Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" On Wed Jul 30, 2025 at 7:59 PM CEST, Daniel Kral wrote: > diff --git a/src/PVE/HA/Groups.pm b/src/PVE/HA/Groups.pm > index 821d969b..4bb943e5 100644 > --- a/src/PVE/HA/Groups.pm > +++ b/src/PVE/HA/Groups.pm > @@ -107,4 +107,53 @@ sub parse_section_header { > __PACKAGE__->register(); > __PACKAGE__->init(); > > +# Migrate nofailback flag from $groups to $resources > +sub migrate_groups_to_resources { > + my ($groups, $resources) = @_; > + > + for my $sid (keys %$resources) { > + my $groupid = $resources->{$sid}->{group} > + or next; # skip resources without groups > + > + $resources->{$sid}->{failback} = int(!$groups->{ids}->{$groupid}->{nofailback}); > + } > +} > + > +# Migrate groups from groups from $groups and $resources to node affinity rules in $rules > +sub migrate_groups_to_rules { > + my ($rules, $groups, $resources) = @_; FWIW, this will also only migrate those HA groups which are referenced in a HA resource config and will not migrate any "empty" HA groups, which are not referenced by any HA resource. I did this as it was only relevant for migrating the HA groups to HA rules in-memory at the time. I'll send a follow-up patch which will at least log that (something like 'do not migrate group xxx as it has no group members' in the HA Manager's log and maybe also the pve8to9 script). We could also die here (only for the persistent migration) if there's a HA group, which is not referenced by anyone, but that could be too much.. > + > + my $group_resources = {}; > + > + for my $sid (keys %$resources) { > + my $groupid = $resources->{$sid}->{group} > + or next; # skip resources without groups > + > + $group_resources->{$groupid}->{$sid} = 1; > + } > + > + while (my ($group, $resources) = each %$group_resources) { > + next if !$groups->{ids}->{$group}; # skip non-existant groups > + > + my $nodes = {}; > + for my $entry (keys $groups->{ids}->{$group}->{nodes}->%*) { > + my ($node, $priority) = PVE::HA::Tools::parse_node_priority($entry); > + > + $nodes->{$node} = { priority => $priority }; > + } > + > + my $new_ruleid = "ha-group-$group"; > + $rules->{ids}->{$new_ruleid} = { > + type => 'node-affinity', > + resources => $resources, > + nodes => $nodes, > + strict => $groups->{ids}->{$group}->{restricted}, > + comment => $groups->{ids}->{$group}->{comment}, > + }; > + $rules->{ids}->{$new_ruleid}->{comment} = "Generated from HA group '$group'." > + if !$rules->{ids}->{$new_ruleid}->{comment}; > + $rules->{order}->{$new_ruleid} = PVE::HA::Rules::get_next_ordinal($rules); > + } > +} > + > 1; _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel