File bsc#1196340-0004-Refactor-scheduler-is_newer_op-to-be-able-to-compare.patch of Package pacemaker.26925

From b74dab4f34fbdba0ae5da05ccd5f921595ab2029 Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Mon, 9 May 2022 13:38:43 +0200
Subject: [PATCH 4/9] Refactor: scheduler: is_newer_op() to be able to compare
 lrm_rsc_op entries from different nodes

---
 lib/pengine/utils.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

Index: pacemaker-2.0.4+20200616.2deceaa3a/lib/pengine/utils.c
===================================================================
--- pacemaker-2.0.4+20200616.2deceaa3a.orig/lib/pengine/utils.c
+++ pacemaker-2.0.4+20200616.2deceaa3a/lib/pengine/utils.c
@@ -1667,7 +1667,11 @@ pe__is_newer_op(const xmlNode *xml_a, co
     const char *a_xml_id = crm_element_value(xml_a, XML_ATTR_ID);
     const char *b_xml_id = crm_element_value(xml_b, XML_ATTR_ID);
 
-    if (crm_str_eq(a_xml_id, b_xml_id, TRUE)) {
+    const char *a_node = crm_element_value(xml_a, XML_LRM_ATTR_TARGET);
+    const char *b_node = crm_element_value(xml_b, XML_LRM_ATTR_TARGET);
+    bool same_node = safe_str_eq(a_node, b_node);
+
+    if (same_node && crm_str_eq(a_xml_id, b_xml_id, TRUE)) {
         /* We have duplicate lrm_rsc_op entries in the status
          * section which is unlikely to be a good thing
          *    - we can handle it easily enough, but we need to get
@@ -1686,13 +1690,14 @@ pe__is_newer_op(const xmlNode *xml_a, co
          */
         sort_return(0, "pending");
 
-    } else if (a_call_id >= 0 && a_call_id < b_call_id) {
+    } else if (same_node && a_call_id >= 0 && a_call_id < b_call_id) {
         sort_return(-1, "call id");
 
-    } else if (b_call_id >= 0 && a_call_id > b_call_id) {
+    } else if (same_node && b_call_id >= 0 && a_call_id > b_call_id) {
         sort_return(1, "call id");
 
-    } else if (b_call_id >= 0 && a_call_id == b_call_id) {
+    } else if (a_call_id >= 0 && b_call_id >= 0
+               && (!same_node || a_call_id == b_call_id)) {
         /*
          * The op and last_failed_op are the same
          * Order on last-rc-change
openSUSE Build Service is sponsored by