From 8eae75fa67cd3febea1692f186fa179c9d5b19c4 Mon Sep 17 00:00:00 2001 From: Tom Ritter Date: Wed, 1 Feb 2017 14:19:03 -0600 Subject: Only notify on failures and successes after the number of failures required --- jobs/JobBase.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'jobs') diff --git a/jobs/JobBase.py b/jobs/JobBase.py index d7ec2a1..1882443 100755 --- a/jobs/JobBase.py +++ b/jobs/JobBase.py @@ -23,8 +23,8 @@ class JobFailureNotificationFrequency: ONSTATECHANGE = "state_change" class JobFailureCountMinimumBeforeNotification: - ONE = "one" - TWO = "two" + ONE = 1 + TWO = 2 class JobBase(object): def __init__(self, config, *args): @@ -48,16 +48,16 @@ class JobBase(object): return True return False - """Returns True if the jobmanager should call 'onFailure' to alert the admin""" + """Returns True if the jobmanager should call 'onFailure' to alert the admin after a job failed""" def shouldNotifyFailure(self, jobState): notifyFrequency = self.notifyOnFailureEvery() minFailureCount = self.numberFailuresBeforeNotification() + currentFailureCount = jobState.NumFailures - if minFailureCount == JobFailureCountMinimumBeforeNotification.ONE: - pass - elif minFailureCount == JobFailureCountMinimumBeforeNotification.TWO: - if jobState.CurrentStateSuccess: - return False + if 1 + currentFailureCount >= minFailureCount: + pass #keep evaluating + else: + return False #Do not notify if notifyFrequency == JobFailureNotificationFrequency.EVERYTIME: return True -- cgit v1.2.3