Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notification: Fix incorrectly dropped recovery & ACK notifications #10223

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions lib/icinga/notification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,16 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe
continue;
}

// Verify if the 'Problem' filter is configured at both the User and Notification object levels.
bool foundProblemFilter = NotificationProblem & user->GetTypeFilter() & GetTypeFilter();

/* on recovery, check if user was notified before */
if (type == NotificationRecovery) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a point in doing this in advance. What if type doesn't match?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a point in doing this in advance.

The point is to deduplicate the logic, ensuring that changes to one part will automatically be reflected in the other, preventing any oversight.

What if type doesn't match?

And what issue do you see in that case? It's just a simple boolean flag performing bitwise checks, so the type matching shouldn't be relevant.

if (!notifiedProblemUsers->Contains(userName) && (NotificationProblem & user->GetTypeFilter())) {
// Do not notify the user about the recovery of a problem that they have not been notified about,
// unless they are explicitly configured to receive recovery notifications but no problem ones, or
// this Notification instance isn't allowed to send problem notifications (doesn't contain the
// 'Problem' type filter).
if (!notifiedProblemUsers->Contains(userName) && foundProblemFilter) {
Log(LogNotice, "Notification")
<< "Notification object '" << notificationName << "': We did not notify user '" << userName
<< "' (Problem types enabled) for a problem before. Not sending Recovery notification.";
Expand All @@ -440,7 +447,10 @@ void Notification::BeginExecuteNotification(NotificationType type, const CheckRe

/* on acknowledgement, check if user was notified before */
if (type == NotificationAcknowledgement) {
if (!notifiedProblemUsers->Contains(userName) && (NotificationProblem & user->GetTypeFilter())) {
// Do not notify the user about the ACK of a problem state that they have not been notified about, unless
// they are explicitly configured to receive ACK notifications but no problem ones, or this Notification
// instance isn't allowed to send problem notifications (doesn't contain the 'Problem' type filter).
if (!notifiedProblemUsers->Contains(userName) && foundProblemFilter) {
Log(LogNotice, "Notification")
<< "Notification object '" << notificationName << "': We did not notify user '" << userName
<< "' (Problem types enabled) for a problem before. Not sending acknowledgement notification.";
Expand Down
Loading