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

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Oct 11 14:24:57 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.

Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
No changes

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

diff --git a/data/PVE/Cluster.pm b/data/PVE/Cluster.pm
index 999e955..70ce250 100644
--- a/data/PVE/Cluster.pm
+++ b/data/PVE/Cluster.pm
@@ -450,6 +450,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);
@@ -471,6 +472,7 @@ sub cfs_update {
 	$vmlist = {};
 	$clinfo = {};
 	$ccache = {};
+	die $err if $fail;
 	warn $err;
     }
 
@@ -483,6 +485,7 @@ sub cfs_update {
     $err = $@;
     if ($err) {
 	$clinfo = {};
+	die $err if $fail;
 	warn $err;
     }
 
@@ -495,6 +498,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