[pve-devel] [RFC ha-manager v5 21/23] api: resources: exclude group property in reading endpoints if migrated

Daniel Kral d.kral at proxmox.com
Wed Jul 30 19:59:48 CEST 2025


The group property is removed during the HA groups migration, but if
there is any reason that it still is in the file, exclude it from output
as soon as the HA groups have been fully migrated.

Signed-off-by: Daniel Kral <d.kral at proxmox.com>
---
should we die here?

 src/PVE/API2/HA/Resources.pm | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/src/PVE/API2/HA/Resources.pm b/src/PVE/API2/HA/Resources.pm
index 26ef9e33..cdd62ec9 100644
--- a/src/PVE/API2/HA/Resources.pm
+++ b/src/PVE/API2/HA/Resources.pm
@@ -22,13 +22,14 @@ use base qw(PVE::RESTHandler);
 my $resource_type_enum = PVE::HA::Resources->lookup_types();
 
 my $api_copy_config = sub {
-    my ($cfg, $sid) = @_;
+    my ($cfg, $sid, $exclude_group_property) = @_;
 
     die "no such resource '$sid'\n" if !$cfg->{ids}->{$sid};
 
     my $scfg = dclone($cfg->{ids}->{$sid});
     $scfg->{sid} = $sid;
     $scfg->{digest} = $cfg->{digest};
+    delete $scfg->{group} if $exclude_group_property;
 
     return $scfg;
 };
@@ -77,10 +78,11 @@ __PACKAGE__->register_method({
 
         my $cfg = PVE::HA::Config::read_resources_config();
         my $groups = PVE::HA::Config::read_group_config();
+        my $exclude_group_property = PVE::HA::Config::have_groups_been_migrated($groups);
 
         my $res = [];
         foreach my $sid (keys %{ $cfg->{ids} }) {
-            my $scfg = &$api_copy_config($cfg, $sid);
+            my $scfg = &$api_copy_config($cfg, $sid, $exclude_group_property);
             next if $param->{type} && $param->{type} ne $scfg->{type};
             if ($scfg->{group} && !$groups->{ids}->{ $scfg->{group} }) {
                 $scfg->{errors}->{group} = "group '$scfg->{group}' does not exist";
@@ -160,10 +162,11 @@ __PACKAGE__->register_method({
         my ($param) = @_;
 
         my $cfg = PVE::HA::Config::read_resources_config();
+        my $exclude_group_property = PVE::HA::Config::have_groups_been_migrated();
 
         my $sid = PVE::HA::Config::parse_sid($param->{sid});
 
-        return &$api_copy_config($cfg, $sid);
+        return &$api_copy_config($cfg, $sid, $exclude_group_property);
     },
 });
 
-- 
2.47.2





More information about the pve-devel mailing list