From e18b15ac78294f37b9f2ac12383c219b5d42e86a Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 28 Mar 2024 11:58:08 +0100 Subject: [PATCH] Consult Checkable#state_before_suppression only if there's a suppression It's only set along with adding NotificationProblem or NotificationRecovery to Checkable#suppressed_notifications and never reset. Also its default, ServiceOK, is an actual state. Not being aware of these facts confuses Checkable#NotificationReasonApplies() which is a condition for cleaning Notification#suppressed_notifications in FireSuppressedNotifications(). I.e. suppressed notifications can get lost. --- lib/icinga/checkable-notification.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/icinga/checkable-notification.cpp b/lib/icinga/checkable-notification.cpp index 79b59861280..b4133a1c10e 100644 --- a/lib/icinga/checkable-notification.cpp +++ b/lib/icinga/checkable-notification.cpp @@ -262,16 +262,20 @@ void Checkable::FireSuppressedNotificationsTimer(const Timer * const&) */ bool Checkable::NotificationReasonApplies(NotificationType type) { + const auto stateNotifications (NotificationRecovery | NotificationProblem); + switch (type) { case NotificationProblem: { auto cr (GetLastCheckResult()); - return cr && !IsStateOK(cr->GetState()) && cr->GetState() != GetStateBeforeSuppression(); + return cr && !IsStateOK(cr->GetState()) + && !(cr->GetState() == GetStateBeforeSuppression() && GetSuppressedNotifications() & stateNotifications); } case NotificationRecovery: { auto cr (GetLastCheckResult()); - return cr && IsStateOK(cr->GetState()) && cr->GetState() != GetStateBeforeSuppression(); + return cr && IsStateOK(cr->GetState()) + && !(cr->GetState() == GetStateBeforeSuppression() && GetSuppressedNotifications() & stateNotifications); } case NotificationFlappingStart: return IsFlapping();