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.
This commit is contained in:
Alexander A. Klimov 2024-03-28 11:58:08 +01:00
parent be50050d2b
commit cafbe5e670
1 changed files with 6 additions and 2 deletions

View File

@ -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();