Skip to content

Commit ee2f43d

Browse files
Subtract inapplicable suppressed notifications at a later point
Without this commit, every time the NotificationTimerHandler runs it will discard notifications that don't apply to the reason of the latest check result. This is probably intended to clear outdated suppressed notifications immediately when the TimePeriod resumes, but it also clears out important ones (see the test case). This commit fixes that by clearing out inapplicable notifications when the timer runs the first time after the TimePeriod resumes. By that time we can expect that no new suppressed notifications will be added and all notifications that don't conflict with the last check-result can still be run. Fixes #10575
1 parent 155d115 commit ee2f43d

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

lib/notification/notificationcomponent.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,23 +81,20 @@ void FireSuppressedNotifications(const Notification::Ptr& notification)
8181
return;
8282

8383
int subtract = 0;
84-
auto checkable (notification->GetCheckable());
85-
86-
for (auto type : {NotificationProblem, NotificationRecovery, NotificationFlappingStart, NotificationFlappingEnd}) {
87-
if ((suppressedTypes & type) && !checkable->NotificationReasonApplies(type)) {
88-
subtract |= type;
89-
suppressedTypes &= ~type;
90-
}
91-
}
92-
9384
if (suppressedTypes) {
9485
auto tp (notification->GetPeriod());
86+
auto checkable (notification->GetCheckable());
9587

9688
if ((!tp || tp->IsInside(Utility::GetTime())) && !checkable->IsLikelyToBeCheckedSoon()) {
9789
for (auto type : {NotificationProblem, NotificationRecovery, NotificationFlappingStart, NotificationFlappingEnd}) {
9890
if (!(suppressedTypes & type) || checkable->NotificationReasonSuppressed(type))
9991
continue;
10092

93+
if ((suppressedTypes & type) && !checkable->NotificationReasonApplies(type)) {
94+
subtract |= type;
95+
continue;
96+
}
97+
10198
auto notificationName (notification->GetName());
10299

103100
Log(LogNotice, "NotificationComponent")

0 commit comments

Comments
 (0)