From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH ha-manager v2 1/4] sim: hardware: add manual-migrate command for ignored services
Date: Sun, 22 Mar 2026 00:42:50 +0100 [thread overview]
Message-ID: <20260321234350.2158438-2-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20260321234350.2158438-1-t.lamprecht@proxmox.com>
Add a 'manual-migrate' action to the simulator's service command
handler, allowing tests to simulate an admin migrating a VM outside
of HA control.
The command is guarded to only work when the service has 'ignored'
request state, mirroring the real-world constraint that only
services not actively managed by HA can be manually migrated.
Uses the same method in the HA sim as used for "stealing" on recovery of
fenced services.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---
New in v2.
src/PVE/HA/Sim/Hardware.pm | 20 +++++++++
src/test/test-manual-migrate-ignored1/cmdlist | 7 +++
.../hardware_status | 5 +++
.../test-manual-migrate-ignored1/log.expect | 44 +++++++++++++++++++
.../manager_status | 1 +
.../service_config | 5 +++
6 files changed, 82 insertions(+)
create mode 100644 src/test/test-manual-migrate-ignored1/cmdlist
create mode 100644 src/test/test-manual-migrate-ignored1/hardware_status
create mode 100644 src/test/test-manual-migrate-ignored1/log.expect
create mode 100644 src/test/test-manual-migrate-ignored1/manager_status
create mode 100644 src/test/test-manual-migrate-ignored1/service_config
diff --git a/src/PVE/HA/Sim/Hardware.pm b/src/PVE/HA/Sim/Hardware.pm
index 8cbf48d..301c391 100644
--- a/src/PVE/HA/Sim/Hardware.pm
+++ b/src/PVE/HA/Sim/Hardware.pm
@@ -879,6 +879,26 @@ sub sim_hardware_cmd {
{ maxcpu => $params[0], maxmem => $params[1] },
);
+ } elsif ($action eq 'manual-migrate') {
+
+ die "sim_hardware_cmd: missing target node for '$action' command"
+ if !$param;
+
+ my $conf = $self->read_service_config();
+
+ die "sim_hardware_cmd: service '$sid' not configured\n"
+ if !$conf->{$sid};
+
+ my $current_node = $conf->{$sid}->{node}
+ || die "sim_hardware_cmd: service '$sid' has no node\n";
+
+ die "sim_hardware_cmd: manual-migrate requires service"
+ . " in 'ignored' state\n"
+ if !defined($conf->{$sid}->{state})
+ || $conf->{$sid}->{state} ne 'ignored';
+
+ $self->change_service_location($sid, $current_node, $param);
+
} elsif ($action eq 'delete') {
$self->delete_service($sid);
diff --git a/src/test/test-manual-migrate-ignored1/cmdlist b/src/test/test-manual-migrate-ignored1/cmdlist
new file mode 100644
index 0000000..a791b3a
--- /dev/null
+++ b/src/test/test-manual-migrate-ignored1/cmdlist
@@ -0,0 +1,7 @@
+[
+ [ "power node1 on", "power node2 on", "power node3 on"],
+ [ "service vm:103 ignored" ],
+ [ "service vm:103 manual-migrate node1" ],
+ [ "service vm:103 started" ],
+ []
+]
diff --git a/src/test/test-manual-migrate-ignored1/hardware_status b/src/test/test-manual-migrate-ignored1/hardware_status
new file mode 100644
index 0000000..451beb1
--- /dev/null
+++ b/src/test/test-manual-migrate-ignored1/hardware_status
@@ -0,0 +1,5 @@
+{
+ "node1": { "power": "off", "network": "off" },
+ "node2": { "power": "off", "network": "off" },
+ "node3": { "power": "off", "network": "off" }
+}
diff --git a/src/test/test-manual-migrate-ignored1/log.expect b/src/test/test-manual-migrate-ignored1/log.expect
new file mode 100644
index 0000000..0060d76
--- /dev/null
+++ b/src/test/test-manual-migrate-ignored1/log.expect
@@ -0,0 +1,44 @@
+info 0 hardware: starting simulation
+info 20 cmdlist: execute power node1 on
+info 20 node1/crm: status change startup => wait_for_quorum
+info 20 node1/lrm: status change startup => wait_for_agent_lock
+info 20 cmdlist: execute power node2 on
+info 20 node2/crm: status change startup => wait_for_quorum
+info 20 node2/lrm: status change startup => wait_for_agent_lock
+info 20 cmdlist: execute power node3 on
+info 20 node3/crm: status change startup => wait_for_quorum
+info 20 node3/lrm: status change startup => wait_for_agent_lock
+info 20 node1/crm: got lock 'ha_manager_lock'
+info 20 node1/crm: status change wait_for_quorum => master
+info 20 node1/crm: node 'node1': state changed from 'unknown' => 'online'
+info 20 node1/crm: node 'node2': state changed from 'unknown' => 'online'
+info 20 node1/crm: node 'node3': state changed from 'unknown' => 'online'
+info 20 node1/crm: adding new service 'vm:101' on node 'node1'
+info 20 node1/crm: adding new service 'vm:102' on node 'node2'
+info 20 node1/crm: adding new service 'vm:103' on node 'node3'
+info 20 node1/crm: service 'vm:101': state changed from 'request_start' to 'started' (node = node1)
+info 20 node1/crm: service 'vm:102': state changed from 'request_start' to 'started' (node = node2)
+info 20 node1/crm: service 'vm:103': state changed from 'request_start' to 'started' (node = node3)
+info 21 node1/lrm: got lock 'ha_agent_node1_lock'
+info 21 node1/lrm: status change wait_for_agent_lock => active
+info 21 node1/lrm: starting service vm:101
+info 21 node1/lrm: service status vm:101 started
+info 22 node2/crm: status change wait_for_quorum => slave
+info 23 node2/lrm: got lock 'ha_agent_node2_lock'
+info 23 node2/lrm: status change wait_for_agent_lock => active
+info 23 node2/lrm: starting service vm:102
+info 23 node2/lrm: service status vm:102 started
+info 24 node3/crm: status change wait_for_quorum => slave
+info 25 node3/lrm: got lock 'ha_agent_node3_lock'
+info 25 node3/lrm: status change wait_for_agent_lock => active
+info 25 node3/lrm: starting service vm:103
+info 25 node3/lrm: service status vm:103 started
+info 120 cmdlist: execute service vm:103 ignored
+info 120 node1/crm: removing stale service 'vm:103' (ignored state requested)
+info 220 cmdlist: execute service vm:103 manual-migrate node1
+info 320 cmdlist: execute service vm:103 started
+info 320 node1/crm: adding new service 'vm:103' on node 'node1'
+info 320 node1/crm: service 'vm:103': state changed from 'request_start' to 'started' (node = node1)
+info 321 node1/lrm: starting service vm:103
+info 321 node1/lrm: service status vm:103 started
+info 920 hardware: exit simulation - done
diff --git a/src/test/test-manual-migrate-ignored1/manager_status b/src/test/test-manual-migrate-ignored1/manager_status
new file mode 100644
index 0000000..9e26dfe
--- /dev/null
+++ b/src/test/test-manual-migrate-ignored1/manager_status
@@ -0,0 +1 @@
+{}
\ No newline at end of file
diff --git a/src/test/test-manual-migrate-ignored1/service_config b/src/test/test-manual-migrate-ignored1/service_config
new file mode 100644
index 0000000..4b26f6b
--- /dev/null
+++ b/src/test/test-manual-migrate-ignored1/service_config
@@ -0,0 +1,5 @@
+{
+ "vm:101": { "node": "node1", "state": "started" },
+ "vm:102": { "node": "node2", "state": "started" },
+ "vm:103": { "node": "node3", "state": "started" }
+}
--
2.47.3
next prev parent reply other threads:[~2026-03-21 23:43 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-21 23:42 [PATCH ha-manager v2 0/4] fix #2751: implement disarm/arm HA for safer cluster maintenance Thomas Lamprecht
2026-03-21 23:42 ` Thomas Lamprecht [this message]
2026-03-21 23:42 ` [PATCH ha-manager v2 2/4] api: status: add fencing status entry with armed/standby state Thomas Lamprecht
2026-03-21 23:42 ` [PATCH ha-manager v2 3/4] fix #2751: implement disarm-ha and arm-ha for safe cluster maintenance Thomas Lamprecht
2026-03-23 13:04 ` Dominik Rusovac
2026-03-25 15:50 ` Fiona Ebner
2026-03-27 1:17 ` Thomas Lamprecht
2026-03-26 16:02 ` Daniel Kral
2026-03-26 23:15 ` Thomas Lamprecht
2026-03-27 10:21 ` Daniel Kral
2026-03-21 23:42 ` [PATCH ha-manager v2 4/4] api: status: add disarm-ha and arm-ha endpoints and CLI wiring Thomas Lamprecht
2026-03-23 13:05 ` [PATCH ha-manager v2 0/4] fix #2751: implement disarm/arm HA for safer cluster maintenance Dominik Rusovac
2026-03-25 12:06 ` applied: " Thomas Lamprecht
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=20260321234350.2158438-2-t.lamprecht@proxmox.com \
--to=t.lamprecht@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