Skip to content

Commit

Permalink
Consult Checkable#state_before_suppression only if there's a suppression
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Al2Klimov committed Mar 28, 2024
1 parent d551eae commit e18b15a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/icinga/checkable-notification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e18b15a

Please sign in to comment.