8ba105
From 191c5be52b1633a8642d28868505a9879b5d5622 Mon Sep 17 00:00:00 2001
8ba105
From: Andrew Beekhof <andrew@beekhof.net>
8ba105
Date: Tue, 3 Apr 2018 13:56:22 +1000
8ba105
Subject: [PATCH] Fix: rhbz#1545449 - Do not perform notifications for events
8ba105
 we know wont be executed
8ba105
8ba105
---
8ba105
 pengine/notif.c | 40 +++++++++++++++++++++++++++++++++++++---
8ba105
 1 file changed, 37 insertions(+), 3 deletions(-)
8ba105
8ba105
diff --git a/pengine/notif.c b/pengine/notif.c
8ba105
index 39d8c72..7ce8f57 100644
8ba105
--- a/pengine/notif.c
8ba105
+++ b/pengine/notif.c
8ba105
@@ -498,12 +498,18 @@ collect_notification_data(resource_t * rsc, gboolean state, gboolean activity,
8ba105
             action_t *op = (action_t *) gIter->data;
8ba105
 
8ba105
             if (is_set(op->flags, pe_action_optional) == FALSE && op->node != NULL) {
8ba105
+                task = text2task(op->task);
8ba105
+
8ba105
+                if(task == stop_rsc && op->node->details->unclean) {
8ba105
+                    /* Create one anyway,, some additional noise if op->node cannot be fenced */
8ba105
+                } else if(is_not_set(op->flags, pe_action_runnable)) {
8ba105
+                    continue;
8ba105
+                }
8ba105
 
8ba105
                 entry = calloc(1, sizeof(notify_entry_t));
8ba105
                 entry->node = op->node;
8ba105
                 entry->rsc = rsc;
8ba105
 
8ba105
-                task = text2task(op->task);
8ba105
                 switch (task) {
8ba105
                     case start_rsc:
8ba105
                         n_data->start = g_list_prepend(n_data->start, entry);
8ba105
@@ -656,8 +662,7 @@ create_notifications(resource_t * rsc, notify_data_t * n_data, pe_working_set_t
8ba105
 
8ba105
     /* Copy notification details into standard ops */
8ba105
 
8ba105
-    gIter = rsc->actions;
8ba105
-    for (; gIter != NULL; gIter = gIter->next) {
8ba105
+    for (gIter = rsc->actions; gIter != NULL; gIter = gIter->next) {
8ba105
         action_t *op = (action_t *) gIter->data;
8ba105
 
8ba105
         if (is_set(op->flags, pe_action_optional) == FALSE && op->node != NULL) {
8ba105
@@ -676,6 +681,35 @@ create_notifications(resource_t * rsc, notify_data_t * n_data, pe_working_set_t
8ba105
         }
8ba105
     }
8ba105
 
8ba105
+    switch (task) {
8ba105
+        case start_rsc:
8ba105
+            if(g_list_length(n_data->start) == 0) {
8ba105
+                pe_rsc_trace(rsc, "Skipping empty notification for: %s.%s (%s->%s)",
8ba105
+                             n_data->action, rsc->id, role2text(rsc->role), role2text(rsc->next_role));
8ba105
+                return;
8ba105
+            }
8ba105
+            break;
8ba105
+        case action_promote:
8ba105
+            if(g_list_length(n_data->promote) == 0) {
8ba105
+                pe_rsc_trace(rsc, "Skipping empty notification for: %s.%s (%s->%s)",
8ba105
+                             n_data->action, rsc->id, role2text(rsc->role), role2text(rsc->next_role));
8ba105
+                return;
8ba105
+            }
8ba105
+            break;
8ba105
+        case action_demote:
8ba105
+            if(g_list_length(n_data->demote) == 0) {
8ba105
+                pe_rsc_trace(rsc, "Skipping empty notification for: %s.%s (%s->%s)",
8ba105
+                             n_data->action, rsc->id, role2text(rsc->role), role2text(rsc->next_role));
8ba105
+                return;
8ba105
+            }
8ba105
+            break;
8ba105
+        default:
8ba105
+            /* We cannot do the same for stop_rsc/n_data->stop at it
8ba105
+             * might be implied by fencing
8ba105
+             */
8ba105
+            break;
8ba105
+    }
8ba105
+
8ba105
     pe_rsc_trace(rsc, "Creating notifications for: %s.%s (%s->%s)",
8ba105
                  n_data->action, rsc->id, role2text(rsc->role), role2text(rsc->next_role));
8ba105
 
8ba105
-- 
8ba105
1.8.3.1
8ba105