[pve-devel] [PATCH ha-manager v3 2/6] fix 'uninitialized value' on online node usage computation

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Feb 19 18:41:03 CET 2016


This fixes a bug introduced by commit 9da84a0 which set the wrong
hash when a disabled service got a migrate/relocate command.

We set "node => $target", while our state machine could handle that
we got some "uninitialized value" warnings when migrating a disabled
service to an inactive LRM. Better set "target => $target"

Further add a test for this scenario.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/HA/Manager.pm                              |  3 +-
 src/test/test-relocate-to-inactive-node/README     |  1 +
 src/test/test-relocate-to-inactive-node/cmdlist    |  4 +++
 .../test-relocate-to-inactive-node/hardware_status |  5 ++++
 src/test/test-relocate-to-inactive-node/log.expect | 33 ++++++++++++++++++++++
 .../test-relocate-to-inactive-node/manager_status  |  1 +
 .../test-relocate-to-inactive-node/service_config  |  3 ++
 7 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 src/test/test-relocate-to-inactive-node/README
 create mode 100644 src/test/test-relocate-to-inactive-node/cmdlist
 create mode 100644 src/test/test-relocate-to-inactive-node/hardware_status
 create mode 100644 src/test/test-relocate-to-inactive-node/log.expect
 create mode 100644 src/test/test-relocate-to-inactive-node/manager_status
 create mode 100644 src/test/test-relocate-to-inactive-node/service_config

diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm
index a482ef2..c03690f 100644
--- a/src/PVE/HA/Manager.pm
+++ b/src/PVE/HA/Manager.pm
@@ -509,7 +509,8 @@ sub next_state_stopped {
 	    } elsif ($sd->{node} eq $target) {
 		$haenv->log('info', "ignore service '$sid' $cmd request - service already on node '$target'");
 	    } else {
-		&$change_service_state($self, $sid, $cmd, node => $target);
+		&$change_service_state($self, $sid, $cmd, node => $sd->{node},
+				       target => $target);
 		return;
 	    }
 	} else {
diff --git a/src/test/test-relocate-to-inactive-node/README b/src/test/test-relocate-to-inactive-node/README
new file mode 100644
index 0000000..f8bffe3
--- /dev/null
+++ b/src/test/test-relocate-to-inactive-node/README
@@ -0,0 +1 @@
+Test user triggered service migration.
diff --git a/src/test/test-relocate-to-inactive-node/cmdlist b/src/test/test-relocate-to-inactive-node/cmdlist
new file mode 100644
index 0000000..4238140
--- /dev/null
+++ b/src/test/test-relocate-to-inactive-node/cmdlist
@@ -0,0 +1,4 @@
+[
+    [ "power node1 on", "power node2 on", "power node3 on"],
+    [ "service vm:103 relocate node2" ]
+]
diff --git a/src/test/test-relocate-to-inactive-node/hardware_status b/src/test/test-relocate-to-inactive-node/hardware_status
new file mode 100644
index 0000000..451beb1
--- /dev/null
+++ b/src/test/test-relocate-to-inactive-node/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-relocate-to-inactive-node/log.expect b/src/test/test-relocate-to-inactive-node/log.expect
new file mode 100644
index 0000000..c4e6d02
--- /dev/null
+++ b/src/test/test-relocate-to-inactive-node/log.expect
@@ -0,0 +1,33 @@
+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:103' on node 'node3'
+info     20    node1/crm: service 'vm:103': state changed from 'started' to 'request_stop'
+info     22    node2/crm: status change wait_for_quorum => slave
+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     40    node1/crm: service 'vm:103': state changed from 'request_stop' to 'stopped'
+info    120      cmdlist: execute service vm:103 relocate node2
+info    120    node1/crm: got crm command: relocate vm:103 node2
+info    120    node1/crm: service 'vm:103': state changed from 'stopped' to 'relocate'  (node = node3, target = node2)
+info    125    node3/lrm: service vm:103 - start relocate to node 'node2'
+info    125    node3/lrm: service vm:103 - end relocate to node 'node2'
+info    140    node1/crm: service 'vm:103': state changed from 'relocate' to 'started'  (node = node2)
+info    140    node1/crm: service 'vm:103': state changed from 'started' to 'request_stop'
+info    143    node2/lrm: got lock 'ha_agent_node2_lock'
+info    143    node2/lrm: status change wait_for_agent_lock => active
+info    160    node1/crm: service 'vm:103': state changed from 'request_stop' to 'stopped'
+info    720     hardware: exit simulation - done
diff --git a/src/test/test-relocate-to-inactive-node/manager_status b/src/test/test-relocate-to-inactive-node/manager_status
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/src/test/test-relocate-to-inactive-node/manager_status
@@ -0,0 +1 @@
+{}
diff --git a/src/test/test-relocate-to-inactive-node/service_config b/src/test/test-relocate-to-inactive-node/service_config
new file mode 100644
index 0000000..fe1359f
--- /dev/null
+++ b/src/test/test-relocate-to-inactive-node/service_config
@@ -0,0 +1,3 @@
+{
+    "vm:103": { "node": "node3", "state": "disabled" }
+}
-- 
2.1.4





More information about the pve-devel mailing list