[pve-devel] [PATCH cluster] Disable errors in cfs_read_file by default.

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Nov 8 09:51:31 CET 2017


Turns out some of the HA code cannot properly deal with
cfs_read_file() die()ing, so make this behavior (introduced
in 7bac9ca573ad ("cluster: improve error handling when
reading files")) optional and off-by-default for now.

This can later be re-enabled once all affected callers have
been dealt with.

Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
 data/PVE/Cluster.pm | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/data/PVE/Cluster.pm b/data/PVE/Cluster.pm
index 70ce250..3a08325 100644
--- a/data/PVE/Cluster.pm
+++ b/data/PVE/Cluster.pm
@@ -397,13 +397,13 @@ my $ipcc_send_rec_json = sub {
 };
 
 my $ipcc_get_config = sub {
-    my ($path) = @_;
+    my ($path, $noerr) = @_;
 
     my $bindata = pack "Z*", $path;
     my $res = PVE::IPCC::ipcc_send_rec(6, $bindata);
     if (!defined($res)) {
 	if ($! != 0) {
-	    return undef if $! == ENOENT;
+	    return undef if $noerr || $! == ENOENT;
 	    die "$!\n";
 	}
 	return '';
@@ -762,9 +762,9 @@ sub create_rrd_graph {
 
 # a fast way to read files (avoid fuse overhead)
 sub get_config {
-    my ($path) = @_;
+    my ($path, $noerr) = @_;
 
-    return &$ipcc_get_config($path);
+    return &$ipcc_get_config($path, $noerr);
 }
 
 sub get_cluster_log {
@@ -789,7 +789,7 @@ sub cfs_register_file {
 }
 
 my $ccache_read = sub {
-    my ($filename, $parser, $version) = @_;
+    my ($filename, $parser, $version, $noerr) = @_;
 
     $ccache->{$filename} = {} if !$ccache->{$filename};
 
@@ -798,7 +798,7 @@ my $ccache_read = sub {
     if (!$ci->{version} || !$version || $ci->{version} != $version) {
 	# we always call the parser, even when the file does not exists
 	# (in that case $data is undef)
-	my $data = get_config($filename);
+	my $data = get_config($filename, $noerr);
 	$ci->{data} = &$parser("/etc/pve/$filename", $data);
 	$ci->{version} = $version;
     }
@@ -830,13 +830,15 @@ sub cfs_file_version {
     return wantarray ? ($version, $info) : $version;
 }
 
+# $noerr currently defaults to 1 until all affected code has been updated to do
+# proper error handling.
 sub cfs_read_file {
-    my ($filename) = @_;
+    my ($filename, $noerr) = @_;
 
     my ($version, $info) = cfs_file_version($filename);
     my $parser = $info->{parser};
 
-    return &$ccache_read($filename, $parser, $version);
+    return &$ccache_read($filename, $parser, $version, $noerr // 1);
 }
 
 sub cfs_write_file {
-- 
2.11.0





More information about the pve-devel mailing list