-
Notifications
You must be signed in to change notification settings - Fork 579
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
base: master
Are you sure you want to change the base?
Conversation
16dedc7
to
557a8af
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Also, this is a stricter condition for not sending a notification, so we can't loose notifications this way. 👍
However:
@@ -428,9 +428,14 @@ 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() && NotificationProblem & GetTypeFilter(); | |||
|
|||
/* on recovery, check if user was notified before */ | |||
if (type == NotificationRecovery) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
557a8af
to
ec09f9c
Compare
lib/icinga/notification.cpp
Outdated
// Do not send a recovery notification to the current user if he was not previously notified of the | ||
// problem state, while containing the 'Problem' filter at both the user and notification object levels. | ||
if (!notifiedProblemUsers->Contains(userName) && foundProblemFilter) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That comment mostly repeats the condition but doesn't say why. Something like "Don't notify the user about the recovery for a problem they weren't notified about, unless they are explicitly configured to receive recovery notifications but no problem notifications." would be more helpful in my opinion as it gives a bit more context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unless they are explicitly configured to receive recovery notifications but no problem notifications.
In contrast, this reasoning is not logical to me, as illustrated by the example tests (see PR description), where the user was configured to receive both recovery and problem states.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, maybe it needs a bit more elaboration. What that unless part was supposed to say is that the check only makes sense if it's possible at all for that user to show up in notifiedProblemUsers
(which is only the case if both the involved Notification
and User
object allow problem notifications).
Previously, recovery and ACK notifications were not delivered to users who weren't notified about the problem state while having a configured `Problem` type filter. However, since the type filter can also be configured on the `Notification` object level, this resulted to an incorrect behaviour. This PR changes the existing logic so that the recovery and ACK notifications gets dropped only if the `Problem` filter is configured on both the `User` and `Notification` object levels.
ec09f9c
to
537fbd0
Compare
Previously, recovery and ACK notifications were not delivered to users who weren't notified about the problem state while having a configured
Problem
type filter. However, since the type filter can also be configured on theNotification
object level, this resulted to an incorrect behaviour. This PR changes the existing logic so that the recovery and ACK notifications gets dropped only if theProblem
filter is configured on both theUser
andNotification
object levels.Tests
Icinga 2 Config
Before
After
fixes #10211