diff options
author | Tom Ritter <tom@ritter.vg> | 2017-02-01 14:19:03 -0600 |
---|---|---|
committer | Tom Ritter <tom@ritter.vg> | 2017-02-01 14:19:03 -0600 |
commit | 8eae75fa67cd3febea1692f186fa179c9d5b19c4 (patch) | |
tree | 1b6d1ca9851fb3a9605146c95eeefad253f74937 /jobs | |
parent | e25776aea113142769bdc95f1f56692eab78ac0e (diff) |
Only notify on failures and successes after the number of failures required
Diffstat (limited to 'jobs')
-rwxr-xr-x | jobs/JobBase.py | 16 |
1 files changed, 8 insertions, 8 deletions
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 |