[pmg-devel] [PATCH pmg-api 2/3] pmgqm: warn if not running on master

Stoiko Ivanov s.ivanov at proxmox.com
Thu Mar 19 14:02:26 CET 2020


pmgqm should exit when running on a non-master node (instead of e.g. sending
out spam report mails multiple times).
However this condition should not be an error - a warning printed should
suffice.

changing the die to warn + return in the calls for 'status' and 'send'
achieves this effect.

Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 src/PMG/CLI/pmgqm.pm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/PMG/CLI/pmgqm.pm b/src/PMG/CLI/pmgqm.pm
index 0f8c4d2..64bafc5 100755
--- a/src/PMG/CLI/pmgqm.pm
+++ b/src/PMG/CLI/pmgqm.pm
@@ -126,7 +126,8 @@ __PACKAGE__->register_method ({
 	my $role = $cinfo->{local}->{type} // '-';
 
 	if (!(($role eq '-') || ($role eq 'master'))) {
-	   die "local node is not master\n";
+	   warn "local node is not master\n";
+	   return;
 	}
 
 	my $cfg = PMG::Config->new();
@@ -217,7 +218,8 @@ __PACKAGE__->register_method ({
 	my $role = $cinfo->{local}->{type} // '-';
 
 	if (!(($role eq '-') || ($role eq 'master'))) {
-	   die "local node is not master - not sending spam report\n";
+	   warn "local node is not master - not sending spam report\n";
+	   return;
 	}
 
 	my $cfg = PMG::Config->new();
-- 
2.20.1




More information about the pmg-devel mailing list