]> git.proxmox.com Git - pve-cluster.git/commitdiff
corosync: die in check_conf_exists if !$noerr
authorStefan Reiter <s.reiter@proxmox.com>
Tue, 19 Nov 2019 09:28:29 +0000 (10:28 +0100)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Fri, 22 Nov 2019 08:12:23 +0000 (09:12 +0100)
...and change $silent to $noerr for consistency.

Commit 3df092f9 (fix #1380: pvecm status: add general cluster
information) broke "pvecm status" on non-cluster nodes (well, it made
the error look worse, ofc it didn't "work" before either) because it
tries to access a totem that cannot exist without a corosync.conf.

pvecm status/nodes/expected already fail without a cluster, so it makes
more sense to fail early. But instead of copying the way the qdevice API
handles it, move the die to check_conf_exists directly, which makes
more sense then a warn anyway IMHO.

check_conf_exists is never called without $noerr = 1 outside of
pvecm.pm, so this change does not require any versioned depends/breaks.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
data/PVE/CLI/pvecm.pm
data/PVE/Corosync.pm

index cf5e4488431cdbbeb2e5fa2449d9770150008999..ad39e3f7eb6ec184bbbd4c6a286dc1699bb17dc9 100755 (executable)
@@ -109,8 +109,7 @@ __PACKAGE__->register_method ({
     code => sub {
        my ($param) = @_;
 
-       die "Node not in a cluster. Aborting.\n"
-           if !PVE::Corosync::check_conf_exists(1);
+       PVE::Corosync::check_conf_exists();
 
        my $members = PVE::Cluster::get_members();
        foreach my $node (sort keys %$members) {
@@ -266,8 +265,7 @@ __PACKAGE__->register_method ({
     code => sub {
        my ($param) = @_;
 
-       die "Node not in a cluster. Aborting.\n"
-           if !PVE::Corosync::check_conf_exists(1);
+       PVE::Corosync::check_conf_exists();
 
        my $members = PVE::Cluster::get_members();
        foreach my $node (sort keys %$members) {
index 63d5e3aa895d53b94dfa0fd11f5cf9c5390953d4..1b92ea37ef9764926c43bf8c350ac20d98c442d9 100644 (file)
@@ -184,14 +184,12 @@ PVE::Cluster::cfs_register_file('corosync.conf.new', \&parse_conf,
                                \&write_conf);
 
 sub check_conf_exists {
-    my ($silent) = @_;
-
-    $silent = $silent // 0;
+    my ($noerr) = @_;
 
     my $exists = -f "$basedir/corosync.conf";
 
-    warn "Corosync config '$basedir/corosync.conf' does not exist - is this node part of a cluster?\n"
-       if !$silent && !$exists;
+    die "Error: Corosync config '$basedir/corosync.conf' does not exist - is this node part of a cluster?\n"
+       if !$noerr && !$exists;
 
     return $exists;
 }