[pve-devel] [PATCH v2 cluster 3/3] corosync: die in check_conf_exists if !$noerr
Stefan Reiter
s.reiter at proxmox.com
Tue Nov 19 10:28:29 CET 2019
...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 at proxmox.com>
---
data/PVE/CLI/pvecm.pm | 6 ++----
data/PVE/Corosync.pm | 8 +++-----
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/data/PVE/CLI/pvecm.pm b/data/PVE/CLI/pvecm.pm
index cf5e448..ad39e3f 100755
--- a/data/PVE/CLI/pvecm.pm
+++ b/data/PVE/CLI/pvecm.pm
@@ -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) {
diff --git a/data/PVE/Corosync.pm b/data/PVE/Corosync.pm
index d1b85dc..dee75b4 100644
--- a/data/PVE/Corosync.pm
+++ b/data/PVE/Corosync.pm
@@ -181,14 +181,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;
}
--
2.20.1
More information about the pve-devel
mailing list