[pve-devel] [PATCH ha-manager 4/7] Revert "wrap possible problematic cfs_read_file calls in eval"

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Nov 22 11:53:09 CET 2017


This reverts commit bf7febe3771d6f9a2aef97bcd6eab4ece098c5aa.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/HA/Config.pm                      | 13 ++++---
 src/PVE/HA/Manager.pm                     |  1 -
 src/test/test-cfs-unavailable1/log.expect | 59 +++++++++++++++++++++++++++++++
 3 files changed, 65 insertions(+), 8 deletions(-)
 create mode 100644 src/test/test-cfs-unavailable1/log.expect

diff --git a/src/PVE/HA/Config.pm b/src/PVE/HA/Config.pm
index e7e8b88..bf37b04 100644
--- a/src/PVE/HA/Config.pm
+++ b/src/PVE/HA/Config.pm
@@ -81,13 +81,13 @@ sub parse_resources_config {
 
 sub read_resources_config {
 
-    return eval { cfs_read_file($ha_resources_config) };
+    return cfs_read_file($ha_resources_config);
 }
 
 # checks if resource exists and sets defaults for unset values
 sub read_and_check_resources_config {
 
-    my $res = eval { cfs_read_file($ha_resources_config) };
+    my $res = cfs_read_file($ha_resources_config);
 
     my $vmlist = PVE::Cluster::get_vmlist();
     my $conf = {};
@@ -122,7 +122,7 @@ sub read_and_check_resources_config {
 
 sub read_group_config {
 
-    return eval { cfs_read_file($ha_groups_config) };
+    return cfs_read_file($ha_groups_config);
 }
 
 sub write_group_config {
@@ -140,7 +140,7 @@ sub write_resources_config {
 sub read_manager_status {
     my () = @_;
 
-    return eval { cfs_read_file($manager_status_filename) };
+    return cfs_read_file($manager_status_filename);
 }
 
 sub write_manager_status {
@@ -152,7 +152,7 @@ sub write_manager_status {
 sub read_fence_config {
     my () = @_;
 
-    return eval { cfs_read_file($ha_fence_config) };
+    cfs_read_file($ha_fence_config);
 }
 
 sub write_fence_config {
@@ -189,8 +189,7 @@ sub queue_crm_commands {
 sub read_crm_commands {
 
     my $code = sub {
-	my $data = eval { cfs_read_file($crm_commands_filename) };
-	return undef if !$data;
+	my $data = cfs_read_file($crm_commands_filename);
 	cfs_write_file($crm_commands_filename, '');
 	return $data;
     };
diff --git a/src/PVE/HA/Manager.pm b/src/PVE/HA/Manager.pm
index 2933926..003db32 100644
--- a/src/PVE/HA/Manager.pm
+++ b/src/PVE/HA/Manager.pm
@@ -328,7 +328,6 @@ sub update_crm_commands {
     my ($haenv, $ms, $ns, $ss) = ($self->{haenv}, $self->{ms}, $self->{ns}, $self->{ss});
 
     my $cmdlist = $haenv->read_crm_commands();
-    return if !defined($cmdlist);
 
     foreach my $cmd (split(/\n/, $cmdlist)) {
 	chomp $cmd;
diff --git a/src/test/test-cfs-unavailable1/log.expect b/src/test/test-cfs-unavailable1/log.expect
new file mode 100644
index 0000000..d45afb3
--- /dev/null
+++ b/src/test/test-cfs-unavailable1/log.expect
@@ -0,0 +1,59 @@
+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     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     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     40    node1/crm: service 'vm:102': state changed from 'request_stop' to 'stopped'
+info    120      cmdlist: execute cfs node1 rw fail
+info    120      cmdlist: execute service vm:101 stopped
+err     120    node1/crm: got unexpected error - cfs connection refused - not mounted?
+err     121    node1/lrm: updating service status from manager failed: cfs connection refused - not mounted?
+err     121    node1/lrm: updating service status from manager failed: cfs connection refused - not mounted?
+err     121    node1/lrm: unable to write lrm status file - cfs connection refused - not mounted?
+err     140    node1/crm: got unexpected error - cfs connection refused - not mounted?
+err     141    node1/lrm: updating service status from manager failed: cfs connection refused - not mounted?
+err     141    node1/lrm: updating service status from manager failed: cfs connection refused - not mounted?
+err     141    node1/lrm: unable to write lrm status file - cfs connection refused - not mounted?
+err     160    node1/crm: got unexpected error - cfs connection refused - not mounted?
+err     161    node1/lrm: updating service status from manager failed: cfs connection refused - not mounted?
+err     161    node1/lrm: updating service status from manager failed: cfs connection refused - not mounted?
+err     161    node1/lrm: unable to write lrm status file - cfs connection refused - not mounted?
+err     180    node1/crm: got unexpected error - cfs connection refused - not mounted?
+err     181    node1/lrm: updating service status from manager failed: cfs connection refused - not mounted?
+err     181    node1/lrm: updating service status from manager failed: cfs connection refused - not mounted?
+err     181    node1/lrm: unable to write lrm status file - cfs connection refused - not mounted?
+err     200    node1/crm: got unexpected error - cfs connection refused - not mounted?
+err     201    node1/lrm: updating service status from manager failed: cfs connection refused - not mounted?
+err     201    node1/lrm: updating service status from manager failed: cfs connection refused - not mounted?
+err     201    node1/lrm: unable to write lrm status file - cfs connection refused - not mounted?
+info    220      cmdlist: execute cfs node1 rw work
+info    220    node1/crm: service 'vm:101': state changed from 'started' to 'request_stop'
+info    221    node1/lrm: stopping service vm:101
+info    221    node1/lrm: service status vm:101 stopped
+info    240    node1/crm: service 'vm:101': state changed from 'request_stop' to 'stopped'
+info    820     hardware: exit simulation - done
-- 
2.11.0





More information about the pve-devel mailing list