File bsc#1196340-0007-Fix-scheduler-do-not-enforce-resource-stop-if-any-ne.patch of Package pacemaker.29727

From 7233657b348fa7a5d186dc116dc6a362cbefc556 Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Mon, 9 May 2022 17:47:23 +0200
Subject: [PATCH 7/9] Fix: scheduler: do not enforce resource stop if any new
 probe/monitor indicates the resource was not running on the target of a
 failed migrate_to

Given a scenario:

- rscA failed to migrate from node1 to node2 with a failed
migrate_to on node1

, if there's any new probe/monitor operation on node2 indicating it was
not running there, the migrate_to failure no longer matters for node2.
---
 lib/pengine/unpack.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/lib/pengine/unpack.c b/lib/pengine/unpack.c
index 88b673413..6c3174472 100644
--- a/lib/pengine/unpack.c
+++ b/lib/pengine/unpack.c
@@ -2628,6 +2628,30 @@ unknown_on_node(const char *rsc_id, const char *node_name,
             || first_named_child(lrm_resource, XML_LRM_TAG_RSC_OP) == NULL);
 }
 
+/*!
+ * \brief Check whether a probe/monitor indicating the resource was not running
+ * on a node happened after some event
+ *
+ * \param[in] rsc_id    Resource being checked
+ * \param[in] node_name Node being checked
+ * \param[in] xml_op    Event that monitor is being compared to
+ * \param[in] data_set  Cluster working set
+ *
+ * \return true if such a monitor happened after event, false otherwise
+ */
+static bool
+monitor_not_running_after(const char *rsc_id, const char *node_name,
+                          xmlNode *xml_op, pe_working_set_t *data_set)
+{
+    /* Any probe/monitor operation on the node indicating it was not running
+     * there
+     */
+    xmlNode *monitor = find_lrm_op(rsc_id, CRMD_ACTION_STATUS, node_name,
+                                   NULL, PCMK_OCF_NOT_RUNNING, data_set);
+
+    return (monitor && pe__is_newer_op(monitor, xml_op) > 0);
+}
+
 static int
 pe__call_id(xmlNode *op_xml)
 {
@@ -2805,6 +2829,11 @@ unpack_migrate_to_failure(pe_resource_t *rsc, pe_node_t *node, xmlNode *xml_op,
          * case the probe detects it's running there.
          */
         !unknown_on_node(rsc->id, target, data_set)
+        /* If there's any probe/monitor operation on the target newer than this
+         * failed migrate_to indicating it was not running there, this migrate_to
+         * failure no longer matters for the target.
+         */
+        && !monitor_not_running_after(rsc->id, target, xml_op, data_set)
         && ((target_stop == NULL) || (target_stop_id < target_migrate_from_id))) {
         /* There was no stop on the target, or a stop that happened before a
          * migrate_from, so assume the resource is still active on the target
-- 
2.35.3

openSUSE Build Service is sponsored by