File bsc#1188653-0001-Fix-scheduler-don-t-schedule-probes-of-unmanaged-res.patch of Package pacemaker.21299

From b0347f7b8e609420a7055d5fe537cc40ac0d1bb2 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Fri, 16 Jul 2021 11:08:05 -0500
Subject: [PATCH 1/3] Fix: scheduler: don't schedule probes of unmanaged
 resources on pending nodes

Previously, custom_action() would set an action's optional or runnable flag in
the same, exclusive if-else sequence. This means that if an action should be
optional *and* runnable, only one would be set. In particular, this meant that
if a resource is unmanaged *and* its allocated node is pending, any probe would
be set to optional, but not unrunnable, and the controller could wrongly
attempt the probe before the join completed.

Now, optional is checked separately.
---
 lib/pengine/utils.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

Index: pacemaker-1.1.18+20180430.b12c320f5/lib/pengine/utils.c
===================================================================
--- pacemaker-1.1.18+20180430.b12c320f5.orig/lib/pengine/utils.c
+++ pacemaker-1.1.18+20180430.b12c320f5/lib/pengine/utils.c
@@ -509,6 +509,20 @@ custom_action(resource_t * rsc, char *ke
                                        action->extra, NULL, FALSE, data_set->now);
         }
 
+        // Make the action optional if its resource is unmanaged
+        if (!is_set(action->flags, pe_action_pseudo)
+            && (action->node != NULL)
+            && !is_set(action->rsc->flags, pe_rsc_managed)
+            && (g_hash_table_lookup(action->meta,
+                                    XML_LRM_ATTR_INTERVAL_MS) == NULL)) {
+                pe_rsc_debug(rsc, "%s on %s is optional (%s is unmanaged)",
+                             action->uuid, action->node->details->uname,
+                             action->rsc->id);
+                pe_set_action_bit(action, pe_action_optional);
+                // We shouldn't clear runnable here because ... something
+        }
+
+        // Make the action runnable or unrunnable as appropriate
         if (is_set(action->flags, pe_action_pseudo)) {
             /* leave untouched */
 
@@ -516,14 +530,6 @@ custom_action(resource_t * rsc, char *ke
             pe_rsc_trace(rsc, "Unset runnable on %s", action->uuid);
             pe_clear_action_bit(action, pe_action_runnable);
 
-        } else if (is_not_set(rsc->flags, pe_rsc_managed)
-                   && g_hash_table_lookup(action->meta,
-                                          XML_LRM_ATTR_INTERVAL_MS) == NULL) {
-            crm_debug("Action %s (unmanaged)", action->uuid);
-            pe_rsc_trace(rsc, "Set optional on %s", action->uuid);
-            pe_set_action_bit(action, pe_action_optional);
-/*   			action->runnable = FALSE; */
-
         } else if (action->node->details->online == FALSE
                    && (!is_container_remote_node(action->node) || action->node->details->remote_requires_reset)) {
             pe_clear_action_bit(action, pe_action_runnable);
openSUSE Build Service is sponsored by