public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Daniel Kral <d.kral@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH qemu-server v5 1/1] api: migration preconditions: add checks for ha resource affinity rules
Date: Wed, 30 Jul 2025 20:14:24 +0200	[thread overview]
Message-ID: <20250730181428.392906-21-d.kral@proxmox.com> (raw)
In-Reply-To: <20250730181428.392906-1-d.kral@proxmox.com>

Add information about positive and negative ha resource affinity rules,
which the VM is part of, to the migration precondition API endpoint.
These inform callees about any comigrated resources or blocking
resources that are caused by the resource affinity rules.

Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
 src/PVE/API2/Qemu.pm | 49 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/src/PVE/API2/Qemu.pm b/src/PVE/API2/Qemu.pm
index 09d4411b..6090f5a1 100644
--- a/src/PVE/API2/Qemu.pm
+++ b/src/PVE/API2/Qemu.pm
@@ -5092,6 +5092,28 @@ __PACKAGE__->register_method({
                             description => 'A storage',
                         },
                     },
+                    'blocking-ha-resources' => {
+                        description => "HA resources, which are blocking the"
+                            . " VM from being migrated to the node.",
+                        type => 'array',
+                        optional => 1,
+                        items => {
+                            description => "A blocking HA resource",
+                            type => 'object',
+                            properties => {
+                                sid => {
+                                    type => 'string',
+                                    description => "The blocking HA resource id",
+                                },
+                                cause => {
+                                    type => 'string',
+                                    description => "The reason why the HA"
+                                        . " resource is blocking the migration.",
+                                    enum => ['resource-affinity'],
+                                },
+                            },
+                        },
+                    },
                 },
                 description => "List of not allowed nodes with additional information.",
             },
@@ -5144,6 +5166,17 @@ __PACKAGE__->register_method({
                 description =>
                     "Object of mapped resources with additional information such if they're live migratable.",
             },
+            'comigrated-ha-resources' => {
+                description => "HA resources, which will be migrated to the"
+                    . " same target node as the VM, because these are in"
+                    . " positive affinity with the VM.",
+                type => 'array',
+                optional => 1,
+                items => {
+                    type => 'string',
+                    description => "A comigrated HA resource",
+                },
+            },
         },
     },
     code => sub {
@@ -5184,6 +5217,14 @@ __PACKAGE__->register_method({
         my $storage_nodehash =
             PVE::QemuServer::check_local_storage_availability($vmconf, $storecfg);
 
+        my $comigrated_ha_resources = {};
+        my $blocking_ha_resources_by_node = {};
+
+        if (PVE::HA::Config::vm_is_ha_managed($vmid)) {
+            ($comigrated_ha_resources, $blocking_ha_resources_by_node) =
+                PVE::HA::Config::get_resource_motion_info("vm:$vmid");
+        }
+
         my $nodelist = PVE::Cluster::get_nodelist();
         for my $node ($nodelist->@*) {
             next if $node eq $localnode;
@@ -5200,6 +5241,12 @@ __PACKAGE__->register_method({
                     $missing_mappings;
             }
 
+            # extracting blocking resources for current node
+            if (my $blocking_ha_resources = $blocking_ha_resources_by_node->{$node}) {
+                $res->{not_allowed_nodes}->{$node}->{'blocking-ha-resources'} =
+                    $blocking_ha_resources;
+            }
+
             # if nothing came up, add it to the allowed nodes
             if (scalar($res->{not_allowed_nodes}->{$node}->%*) == 0) {
                 push $res->{allowed_nodes}->@*, $node;
@@ -5213,6 +5260,8 @@ __PACKAGE__->register_method({
         $res->{'mapped-resources'} = [sort keys $mapped_resources->%*];
         $res->{'mapped-resource-info'} = $mapped_resources;
 
+        $res->{'comigrated-ha-resources'} = $comigrated_ha_resources;
+
         return $res;
 
     },
-- 
2.47.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  parent reply	other threads:[~2025-07-30 18:13 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-30 18:14 [pve-devel] [PATCH container/docs/ha-manager/manager/qemu-server v5 00/20] HA " Daniel Kral
2025-07-30 18:14 ` [pve-devel] [PATCH ha-manager v5 01/14] introduce PVE::HA::HashTools module Daniel Kral
2025-07-30 18:14 ` [pve-devel] [PATCH ha-manager v5 02/14] rules: introduce plugin-specific canonicalize routines Daniel Kral
2025-07-30 18:14 ` [pve-devel] [PATCH ha-manager v5 03/14] rules: add haenv node list to the rules' canonicalization stage Daniel Kral
2025-07-30 18:14 ` [pve-devel] [PATCH ha-manager v5 04/14] rules: introduce resource affinity rule plugin Daniel Kral
2025-07-30 18:14 ` [pve-devel] [PATCH ha-manager v5 05/14] rules: add global checks between node and resource affinity rules Daniel Kral
2025-07-30 18:14 ` [pve-devel] [PATCH ha-manager v5 06/14] usage: add information about a service's assigned nodes Daniel Kral
2025-07-30 18:14 ` [pve-devel] [PATCH ha-manager v5 07/14] manager: apply resource affinity rules when selecting service nodes Daniel Kral
2025-07-30 18:14 ` [pve-devel] [PATCH ha-manager v5 08/14] manager: handle resource affinity rules in manual migrations Daniel Kral
2025-07-30 18:14 ` [pve-devel] [PATCH ha-manager v5 09/14] sim: resources: add option to limit start and migrate tries to node Daniel Kral
2025-07-30 18:14 ` [pve-devel] [PATCH ha-manager v5 10/14] test: ha tester: add test cases for negative resource affinity rules Daniel Kral
2025-07-30 18:14 ` [pve-devel] [PATCH ha-manager v5 11/14] test: ha tester: add test cases for positive " Daniel Kral
2025-07-30 18:14 ` [pve-devel] [PATCH ha-manager v5 12/14] test: ha tester: add test cases for static scheduler resource affinity Daniel Kral
2025-07-30 18:14 ` [pve-devel] [PATCH ha-manager v5 13/14] test: rules: add test cases for resource affinity rules Daniel Kral
2025-07-30 18:14 ` [pve-devel] [PATCH ha-manager v5 14/14] api: resources: add check for resource affinity in resource migrations Daniel Kral
2025-07-30 18:14 ` [pve-devel] [PATCH docs v5 1/1] ha: add documentation about ha resource affinity rules Daniel Kral
2025-08-04 13:00   ` Hannes Duerr
2025-07-30 18:14 ` [pve-devel] [PATCH manager v5 1/3] ui: ha: rules: add " Daniel Kral
2025-07-30 18:14 ` [pve-devel] [PATCH manager v5 2/3] ui: migrate: lxc: display precondition messages for ha resource affinity Daniel Kral
2025-07-30 18:14 ` [pve-devel] [PATCH manager v5 3/3] ui: migrate: vm: " Daniel Kral
2025-07-30 18:14 ` [pve-devel] [PATCH container v5 1/1] api: introduce migration preconditions api endpoint Daniel Kral
2025-07-30 18:14 ` Daniel Kral [this message]
2025-08-04  9:50 ` [pve-devel] applied-series: [PATCH container/docs/ha-manager/manager/qemu-server v5 00/20] HA resource affinity rules Fiona Ebner

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=20250730181428.392906-21-d.kral@proxmox.com \
    --to=d.kral@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