[pve-devel] [PATCH ha-manager 4/4] reduce frequency of useless error logging

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Feb 16 16:46:45 CET 2016


If a service is in the error state we got an not rather useful log
message about every 5 seconds, this sums up rather quickly and is
not quite helpful.

This changes the behaviour so that we get an initial log message
and then once per minute.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 src/PVE/HA/LRM.pm | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/src/PVE/HA/LRM.pm b/src/PVE/HA/LRM.pm
index 9e8d046..17863ba 100644
--- a/src/PVE/HA/LRM.pm
+++ b/src/PVE/HA/LRM.pm
@@ -359,6 +359,9 @@ sub do_one_iteration {
     return 1;
 }
 
+# for not logging the error state every round
+my $log_error = 0;
+
 sub run_workers {
     my ($self) = @_;
 
@@ -379,6 +382,8 @@ sub run_workers {
 
 	    my $w = $self->{workers}->{$sid};
 	    if (!$w->{pid}) {
+		my @agent_params = ($sid, $sc->{$sid}, $w->{state}, $w->{target},
+				    $log_error);
 		# only fork if we may else call exec_resource_agent
 		# directly (e.g. for regression tests)
 		if ($max_workers > 0) {
@@ -392,7 +397,7 @@ sub run_workers {
 			# do work
 			my $res = -1;
 			eval {
-			    $res = $self->exec_resource_agent($sid, $sc->{$sid}, $w->{state}, $w->{target});
+			    $res = $self->exec_resource_agent(@agent_params );
 			};
 			if (my $err = $@) {
 			    $haenv->log('err', $err);
@@ -406,7 +411,7 @@ sub run_workers {
 		} else {
 		    my $res = -1;
 		    eval {
-			$res = $self->exec_resource_agent($sid, $sc->{$sid}, $w->{state}, $w->{target});
+			$res = $self->exec_resource_agent(@agent_params);
 			$res = $res << 8 if $res > 0;
 		    };
 		    if (my $err = $@) {
@@ -423,6 +428,9 @@ sub run_workers {
 
 	last if !$count;
 
+	# log errors every 60 seconds
+	$log_error = ($log_error + 1) % 12;
+
 	$haenv->sleep(1);
     }
 
-- 
2.1.4





More information about the pve-devel mailing list