]> git.proxmox.com Git - pve-cluster.git/blobdiff - data/PVE/Cluster.pm
cluster: improve error handling when reading files
[pve-cluster.git] / data / PVE / Cluster.pm
index 38c5fdbd845c4edd8fe6c6b7ae5928099de9237d..70ce250a0095dd2f40151d446e42c11fc80ff958 100644 (file)
@@ -2,7 +2,7 @@ package PVE::Cluster;
 
 use strict;
 use warnings;
-use POSIX qw(EEXIST);
+use POSIX qw(EEXIST ENOENT);
 use File::stat qw();
 use Socket;
 use Storable qw(dclone);
@@ -402,7 +402,10 @@ my $ipcc_get_config = sub {
     my $bindata = pack "Z*", $path;
     my $res = PVE::IPCC::ipcc_send_rec(6, $bindata);
     if (!defined($res)) {
-       return undef if ($! != 0);
+       if ($! != 0) {
+           return undef if $! == ENOENT;
+           die "$!\n";
+       }
        return '';
     }
 
@@ -447,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);
@@ -468,6 +472,7 @@ sub cfs_update {
        $vmlist = {};
        $clinfo = {};
        $ccache = {};
+       die $err if $fail;
        warn $err;
     }
 
@@ -480,6 +485,7 @@ sub cfs_update {
     $err = $@;
     if ($err) {
        $clinfo = {};
+       die $err if $fail;
        warn $err;
     }
 
@@ -492,6 +498,7 @@ sub cfs_update {
     $err = $@;
     if ($err) {
        $vmlist = {};
+       die $err if $fail;
        warn $err;
     }
 }
@@ -523,9 +530,18 @@ sub get_nodelist {
     return [ keys %$nodelist ];
 }
 
+# $data must be a chronological descending ordered array of tasks
 sub broadcast_tasklist {
     my ($data) = @_;
 
+    # the serialized list may not get bigger than 32kb (CFS_MAX_STATUS_SIZE
+    # from pmxcfs) - drop older items until we satisfy this constraint
+    my $size = length(encode_json($data));
+    while ($size >= (32 * 1024)) {
+       pop @$data;
+       $size = length(encode_json($data));
+    }
+
     eval {
        &$ipcc_update_status("tasklist", $data);
     };
@@ -736,7 +752,7 @@ sub create_rrd_graph {
     push @args, '--full-size-mode';
 
     # we do not really store data into the file
-    my $res = RRDs::graphv('', @args);
+    my $res = RRDs::graphv('-', @args);
 
     my $err = RRDs::error;
     die "RRD error: $err\n" if $err;
@@ -1132,8 +1148,9 @@ sub setup_rootsshconfig {
     if (! -f $rootsshconfig) {
         mkdir '/root/.ssh';
         if (my $fh = IO::File->new($rootsshconfig, O_CREAT|O_WRONLY|O_EXCL, 0640)) {
-            # this is the default ciphers list from debian openssl0.9.8 except blowfish is added as prefered
-            print $fh "Ciphers blowfish-cbc,aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc\n";
+            # this is the default ciphers list from Debian's OpenSSH package (OpenSSH_7.4p1 Debian-10, OpenSSL 1.0.2k  26 Jan 2017)
+           # changed order to put AES before Chacha20 (most hardware has AESNI)
+            print $fh "Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm\@openssh.com,aes256-gcm\@openssh.com,chacha20-poly1305\@openssh.com\n";
             close($fh);
         }
     }