File bsc#1196340-0006-Refactor-scheduler-find_lrm_op-to-be-able-to-check-a.patch of Package pacemaker.32051

From 2fa93ee58127f2bbd63a056617d7179fe9470923 Mon Sep 17 00:00:00 2001
From: "Gao,Yan" <ygao@suse.com>
Date: Mon, 9 May 2022 14:23:07 +0200
Subject: [PATCH 6/9] Refactor: scheduler: find_lrm_op() to be able to check
 against a specified target_rc

---
 lib/pengine/unpack.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/pengine/unpack.c b/lib/pengine/unpack.c
index a8d8f3708..88b673413 100644
--- a/lib/pengine/unpack.c
+++ b/lib/pengine/unpack.c
@@ -2549,7 +2549,7 @@ set_node_score(gpointer key, gpointer value, gpointer user_data)
 #define STATUS_PATH_MAX 1024
 static xmlNode *
 find_lrm_op(const char *resource, const char *op, const char *node, const char *source,
-            bool success_only, pe_working_set_t *data_set)
+            int target_rc, pe_working_set_t *data_set)
 {
     int offset = 0;
     char xpath[STATUS_PATH_MAX];
@@ -2580,13 +2580,13 @@ find_lrm_op(const char *resource, const char *op, const char *node, const char *
     CRM_LOG_ASSERT(offset > 0);
     xml = get_xpath_object(xpath, data_set->input, LOG_DEBUG);
 
-    if (xml && success_only) {
+    if (xml && target_rc >= 0) {
         int rc = PCMK_OCF_UNKNOWN_ERROR;
         int status = PCMK_EXEC_ERROR;
 
         crm_element_value_int(xml, XML_LRM_ATTR_RC, &rc);
         crm_element_value_int(xml, XML_LRM_ATTR_OPSTATUS, &status);
-        if ((rc != PCMK_OCF_OK) || (status != PCMK_EXEC_DONE)) {
+        if ((rc != target_rc) || (status != PCMK_EXEC_DONE)) {
             return NULL;
         }
     }
@@ -2660,7 +2660,7 @@ 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->uname, NULL, TRUE, data_set);
+                                   node->details->uname, NULL, PCMK_OCF_OK, data_set);
 
     return (stop_op && (pe__call_id(stop_op) > pe__call_id(xml_op)));
 }
@@ -2709,7 +2709,7 @@ unpack_migrate_to_success(pe_resource_t *rsc, pe_node_t *node, xmlNode *xml_op,
 
     // Check whether there was a migrate_from action on the target
     migrate_from = find_lrm_op(rsc->id, CRMD_ACTION_MIGRATED, target,
-                               source, FALSE, data_set);
+                               source, -1, data_set);
     if (migrate_from) {
         crm_element_value_int(migrate_from, XML_LRM_ATTR_RC, &from_rc);
         crm_element_value_int(migrate_from, XML_LRM_ATTR_OPSTATUS, &from_status);
@@ -2764,7 +2764,7 @@ static bool
 newer_op(pe_resource_t *rsc, const char *action_name, const char *node_name,
          int call_id, pe_working_set_t *data_set)
 {
-    xmlNode *action = find_lrm_op(rsc->id, action_name, node_name, NULL, TRUE,
+    xmlNode *action = find_lrm_op(rsc->id, action_name, node_name, NULL, PCMK_OCF_OK,
                                   data_set);
 
     return pe__call_id(action) > call_id;
@@ -2791,12 +2791,12 @@ unpack_migrate_to_failure(pe_resource_t *rsc, pe_node_t *node, xmlNode *xml_op,
 
     // Check for stop on the target
     target_stop = find_lrm_op(rsc->id, CRMD_ACTION_STOP, target, NULL,
-                              TRUE, data_set);
+                              PCMK_OCF_OK, data_set);
     target_stop_id = pe__call_id(target_stop);
 
     // Check for migrate_from on the target
     target_migrate_from = find_lrm_op(rsc->id, CRMD_ACTION_MIGRATED, target,
-                                      source, TRUE, data_set);
+                                      source, PCMK_OCF_OK, data_set);
     target_migrate_from_id = pe__call_id(target_migrate_from);
 
     if (/* If the resource state is unknown on the target, it will likely be
@@ -2864,11 +2864,11 @@ unpack_migrate_from_failure(pe_resource_t *rsc, pe_node_t *node,
 
     // Check for a stop on the source
     source_stop = find_lrm_op(rsc->id, CRMD_ACTION_STOP, source, NULL,
-                              TRUE, data_set);
+                              PCMK_OCF_OK, data_set);
 
     // Check for a migrate_to on the source
     source_migrate_to = find_lrm_op(rsc->id, CRMD_ACTION_MIGRATE,
-                                    source, target, TRUE, data_set);
+                                    source, target, PCMK_OCF_OK, data_set);
 
     if ((source_stop == NULL)
         || (pe__call_id(source_stop) < pe__call_id(source_migrate_to))) {
-- 
2.35.3

openSUSE Build Service is sponsored by