File bsc#1177212-0001-Low-libpe_status-check-for-stops-correctly-when-unpa.patch of Package pacemaker.19404

From cba5dc6627a4cbc4f687e013844c7b1f947b12c1 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Wed, 3 Jul 2019 23:04:41 -0500
Subject: [PATCH 1/8] Low: libpe_status: check for stops correctly when
 unpacking migration

When unpacking resource migration history, e89ac6d added a check for whether a
stop happened after the migration, skipping the rest of the unpacking if so.

However, it mistakenly searched by node ID instead of uname, so it was
completely ineffective for most cluster nodes. It would have accidentally
worked for Pacemaker Remote nodes and for cluster nodes whose ID was explicitly
configured the same as their unames (as so happened in some of our scheduler
regression tests).

Since we no longer store more than one successful history event for a resource
on a node, we really could update the tests and remove this check altogether,
but it may serve some useful purpose as a fail-safe and future-proofing.
---
 lib/pengine/unpack.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/lib/pengine/unpack.c b/lib/pengine/unpack.c
index 9d13a57b0..adbf481e6 100644
--- a/lib/pengine/unpack.c
+++ b/lib/pengine/unpack.c
@@ -2380,12 +2380,28 @@ find_lrm_op(const char *resource, const char *op, const char *node, const char *
     return get_xpath_object(xpath, data_set->input, LOG_DEBUG);
 }
 
+/*!
+ * \brief Check whether a stop happened on the same node after some event
+ *
+ * \param[in] rsc       Resource being checked
+ * \param[in] node      Node being checked
+ * \param[in] xml_op    Event that stop is being compared to
+ * \param[in] data_set  Cluster working set
+ *
+ * \return TRUE if stop happened after event, FALSE otherwise
+ *
+ * \note This is really unnecessary, but kept as a safety mechanism. We
+ *       currently don't save more than one successful event in history, so this
+ *       only matters when processing really old CIB files that we don't
+ *       technically support anymore, or as preparation for logging an extended
+ *       history in the future.
+ */
 static bool
 stop_happened_after(pe_resource_t *rsc, pe_node_t *node, xmlNode *xml_op,
                     pe_working_set_t *data_set)
 {
-    xmlNode *stop_op = find_lrm_op(rsc->id, CRMD_ACTION_STOP, node->details->id,
-                                   NULL, data_set);
+    xmlNode *stop_op = find_lrm_op(rsc->id, CRMD_ACTION_STOP,
+                                   node->details->uname, NULL, data_set);
 
     if (stop_op) {
         int stop_id = 0;
-- 
2.26.2

openSUSE Build Service is sponsored by