From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 41E0B1FF14B for ; Sun, 22 Mar 2026 00:43:59 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id EC0D937145; Sun, 22 Mar 2026 00:44:04 +0100 (CET) From: Thomas Lamprecht 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 Message-ID: <20260321234350.2158438-2-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260321234350.2158438-1-t.lamprecht@proxmox.com> References: <20260321234350.2158438-1-t.lamprecht@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1774136591863 X-SPAM-LEVEL: Spam detection results: 0 AWL -1.075 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 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.408 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.819 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.903 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. 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: HKNVZXD3TUPPTZ2YPI7VHH5S6JA5Y4LI X-Message-ID-Hash: HKNVZXD3TUPPTZ2YPI7VHH5S6JA5Y4LI X-MailFrom: t.lamprecht@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: 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 --- 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