[pve-devel] [RFC PATCH cluster 2/2] cluster: cfs_update: option to die rather than warn

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Oct 11 09:36:44 CEST 2017


It can be useful to know whether we actually have an empty
vm list or whether the last cfs_update call simply failed.
Previously this only warned.

This way we can avoid a nasty type of race condition. For
instance in pvesr where it's possible that the vm list query
fails while everything else worked (eg. if the pmxcfs was
just starting up, or died between the queries), in which
case it would assume there are no guests and the
purge-old-states step would clear out the entire local state
file.
---
This will be used in PVE::ReplicationState::purge_old_states to verify
that it's not accidentally deleting valid states.

 data/PVE/Cluster.pm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/data/PVE/Cluster.pm b/data/PVE/Cluster.pm
index 05f144f..3e27c52 100644
--- a/data/PVE/Cluster.pm
+++ b/data/PVE/Cluster.pm
@@ -448,6 +448,7 @@ my $ipcc_get_cluster_log = sub {
 my $ccache = {};
 
 sub cfs_update {
+    my ($fail) = @_;
     eval {
 	my $res = &$ipcc_send_rec_json(1);
 	#warn "GOT1: " . Dumper($res);
@@ -469,6 +470,7 @@ sub cfs_update {
 	$vmlist = {};
 	$clinfo = {};
 	$ccache = {};
+	die $err if $fail;
 	warn $err;
     }
 
@@ -481,6 +483,7 @@ sub cfs_update {
     $err = $@;
     if ($err) {
 	$clinfo = {};
+	die $err if $fail;
 	warn $err;
     }
 
@@ -493,6 +496,7 @@ sub cfs_update {
     $err = $@;
     if ($err) {
 	$vmlist = {};
+	die $err if $fail;
 	warn $err;
     }
 }
-- 
2.11.0





More information about the pve-devel mailing list