[pve-devel] [PATCH ha-manager 3/3] improve logging on crm command queueing
Thomas Lamprecht
t.lamprecht at proxmox.com
Thu Nov 24 16:58:48 CET 2016
crm commands are ignored if a service is in 'ignored' state or still
queued for addition.
Do not log this both cases as error and adapt the log message
respectively
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
src/PVE/HA/Manager.pm | 11 ++++++++++-
src/test/test-service-ignore3/README | 4 ++++
src/test/test-service-ignore3/cmdlist | 5 +++++
src/test/test-service-ignore3/hardware_status | 5 +++++
src/test/test-service-ignore3/log.expect | 27 +++++++++++++++++++++++++++
src/test/test-service-ignore3/manager_status | 1 +
src/test/test-service-ignore3/service_config | 3 +++
7 files changed, 55 insertions(+), 1 deletion(-)
create mode 100644 src/test/test-service-ignore3/README
create mode 100644 src/test/test-service-ignore3/cmdlist
create mode 100644 src/test/test-service-ignore3/hardware_status
create mode 100644 src/test/test-service-ignore3/log.expect
create mode 100644 src/test/test-service-ignore3/manager_status
create mode 100644 src/test/test-service-ignore3/service_config
diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm
index eeda5d6..a5e90df 100644
--- a/src/PVE/HA/Manager.pm
+++ b/src/PVE/HA/Manager.pm
@@ -347,7 +347,16 @@ sub update_crm_commands {
}
}
} else {
- $haenv->log('err', "crm command error - no such service: $cmd");
+ my $sc = $haenv->read_service_config();
+ if (my $cd = $sc->{$sid}) {
+ if (defined($cd->{state}) && $cd->{state} eq 'ignored') {
+ $haenv->log('notice', "crm command ignored - service is in 'ignored' state: $cmd");
+ } else {
+ $haenv->log('notice', "crm command ignored - new service still queued for addition: $cmd");
+ }
+ } else {
+ $haenv->log('err', "crm command error - no such service: $cmd");
+ }
}
} else {
diff --git a/src/test/test-service-ignore3/README b/src/test/test-service-ignore3/README
new file mode 100644
index 0000000..ea535b2
--- /dev/null
+++ b/src/test/test-service-ignore3/README
@@ -0,0 +1,4 @@
+Set the request state of a service to ignored. Then request a crm command
+(migrate) which should be ignored.
+This ensures that no outdated command gets executed when making a request
+state transition from ignore to another state.
diff --git a/src/test/test-service-ignore3/cmdlist b/src/test/test-service-ignore3/cmdlist
new file mode 100644
index 0000000..b1c3f54
--- /dev/null
+++ b/src/test/test-service-ignore3/cmdlist
@@ -0,0 +1,5 @@
+[
+ [ "power node1 on", "power node2 on", "power node3 on"],
+ [ "service vm:103 ignored" ],
+ [ "service vm:103 migrate node2" ]
+]
diff --git a/src/test/test-service-ignore3/hardware_status b/src/test/test-service-ignore3/hardware_status
new file mode 100644
index 0000000..451beb1
--- /dev/null
+++ b/src/test/test-service-ignore3/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-service-ignore3/log.expect b/src/test/test-service-ignore3/log.expect
new file mode 100644
index 0000000..e2f46fb
--- /dev/null
+++ b/src/test/test-service-ignore3/log.expect
@@ -0,0 +1,27 @@
+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 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 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' (in ignored state)
+info 220 cmdlist: execute service vm:103 migrate node2
+noti 220 node1/crm: crm command ignored - service is in 'ignored' state: migrate vm:103 node2
+info 820 hardware: exit simulation - done
diff --git a/src/test/test-service-ignore3/manager_status b/src/test/test-service-ignore3/manager_status
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/src/test/test-service-ignore3/manager_status
@@ -0,0 +1 @@
+{}
diff --git a/src/test/test-service-ignore3/service_config b/src/test/test-service-ignore3/service_config
new file mode 100644
index 0000000..c6860e7
--- /dev/null
+++ b/src/test/test-service-ignore3/service_config
@@ -0,0 +1,3 @@
+{
+ "vm:103": { "node": "node3", "state": "enabled" }
+}
--
2.1.4
More information about the pve-devel
mailing list