]> granicus.if.org Git - icinga2/commitdiff
Fix notification skip for local non-API enabled setups 7077/head
authorMichael Friedrich <michael.friedrich@icinga.com>
Wed, 3 Apr 2019 11:50:21 +0000 (13:50 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Wed, 3 Apr 2019 11:50:21 +0000 (13:50 +0200)
W/o local endpoint, these reminder notifications would
have been skipped otherwise.

PR #6935 improved the logging and made this problem visible.

Thanks @nilmerg :)

lib/notification/notificationcomponent.cpp

index 57ef3011d1f354388802314ca065d4e173031df4..36fe8ecaa68996c2d0f469698cdc12f6a08a605c 100644 (file)
@@ -64,13 +64,17 @@ void NotificationComponent::NotificationTimerHandler()
 {
        double now = Utility::GetTime();
 
+       /* Function already checks whether 'api' feature is enabled. */
+       Endpoint::Ptr myEndpoint = Endpoint::GetLocalEndpoint();
+
        for (const Notification::Ptr& notification : ConfigType::GetObjectsByType<Notification>()) {
                if (!notification->IsActive())
                        continue;
 
                String notificationName = notification->GetName();
 
-               if (notification->IsPaused() && GetEnableHA()) {
+               /* Skip notification if paused, in a cluster setup & HA feature is enabled. */
+               if (notification->IsPaused() && myEndpoint && GetEnableHA()) {
                        Log(LogNotice, "NotificationComponent")
                                << "Reminder notification '" << notificationName << "': HA cluster active, this endpoint does not have the authority (paused=true). Skipping.";
                        continue;