Blame SOURCES/021-failure-messages.patch

33afe3
From 9ee3d6c9b0aba6aae022cc152a3b3472fe388fa3 Mon Sep 17 00:00:00 2001
33afe3
From: Ken Gaillot <kgaillot@redhat.com>
33afe3
Date: Thu, 6 Jan 2022 16:44:32 -0600
33afe3
Subject: [PATCH 01/15] Refactor: fencer: add exit reason to fencing operation
33afe3
 object
33afe3
33afe3
In order to pass a fencing action's exit reason with the action history,
33afe3
we need the exit reason in remote_fencing_op_t. Nothing sets or uses it as of
33afe3
this commit.
33afe3
---
33afe3
 daemons/fenced/fenced_remote.c    | 2 ++
33afe3
 daemons/fenced/pacemaker-fenced.h | 4 +++-
33afe3
 2 files changed, 5 insertions(+), 1 deletion(-)
33afe3
33afe3
diff --git a/daemons/fenced/fenced_remote.c b/daemons/fenced/fenced_remote.c
33afe3
index 6eebb7381e..0fa9706140 100644
33afe3
--- a/daemons/fenced/fenced_remote.c
33afe3
+++ b/daemons/fenced/fenced_remote.c
33afe3
@@ -260,6 +260,8 @@ free_remote_op(gpointer data)
33afe3
     }
33afe3
     g_list_free_full(op->automatic_list, free);
33afe3
     g_list_free(op->duplicates);
33afe3
+
33afe3
+    pcmk__reset_result(&op->result);
33afe3
     free(op);
33afe3
 }
33afe3
 
33afe3
diff --git a/daemons/fenced/pacemaker-fenced.h b/daemons/fenced/pacemaker-fenced.h
33afe3
index 502fcc9a29..1a5c933ea7 100644
33afe3
--- a/daemons/fenced/pacemaker-fenced.h
33afe3
+++ b/daemons/fenced/pacemaker-fenced.h
33afe3
@@ -1,5 +1,5 @@
33afe3
 /*
33afe3
- * Copyright 2009-2021 the Pacemaker project contributors
33afe3
+ * Copyright 2009-2022 the Pacemaker project contributors
33afe3
  *
33afe3
  * This source code is licensed under the GNU General Public License version 2
33afe3
  * or later (GPLv2+) WITHOUT ANY WARRANTY.
33afe3
@@ -151,6 +151,8 @@ typedef struct remote_fencing_op_s {
33afe3
     /*! The point at which the remote operation completed(nsec) */
33afe3
     long long completed_nsec;
33afe3
 
33afe3
+    /*! The (potentially intermediate) result of the operation */
33afe3
+    pcmk__action_result_t result;
33afe3
 } remote_fencing_op_t;
33afe3
 
33afe3
 void fenced_broadcast_op_result(remote_fencing_op_t *op,
33afe3
-- 
33afe3
2.27.0
33afe3
33afe3
33afe3
From 97a2c318866adc5ef5e426c5c3b753df1fa3ab66 Mon Sep 17 00:00:00 2001
33afe3
From: Ken Gaillot <kgaillot@redhat.com>
33afe3
Date: Thu, 6 Jan 2022 17:08:42 -0600
33afe3
Subject: [PATCH 02/15] Refactor: fencer: track full result in
33afe3
 remote_fencing_op_t
33afe3
33afe3
Now that remote_fencing_op_t has a place for the full result,
33afe3
set it before calling finalize_op(), instead of passing a separate result
33afe3
object to finalize_op().
33afe3
33afe3
As a bonus, this simplifies the memory management, reducing the chance of
33afe3
mistakes.
33afe3
---
33afe3
 daemons/fenced/fenced_remote.c | 161 ++++++++++++++++-----------------
33afe3
 1 file changed, 77 insertions(+), 84 deletions(-)
33afe3
33afe3
diff --git a/daemons/fenced/fenced_remote.c b/daemons/fenced/fenced_remote.c
33afe3
index 0fa9706140..30edbff890 100644
33afe3
--- a/daemons/fenced/fenced_remote.c
33afe3
+++ b/daemons/fenced/fenced_remote.c
33afe3
@@ -82,8 +82,7 @@ extern xmlNode *stonith_create_op(int call_id, const char *token, const char *op
33afe3
 static void request_peer_fencing(remote_fencing_op_t *op,
33afe3
                                 peer_device_info_t *peer,
33afe3
                                 pcmk__action_result_t *result);
33afe3
-static void finalize_op(remote_fencing_op_t *op, xmlNode *data,
33afe3
-                        pcmk__action_result_t *result, bool dup);
33afe3
+static void finalize_op(remote_fencing_op_t *op, xmlNode *data, bool dup);
33afe3
 static void report_timeout_period(remote_fencing_op_t * op, int op_timeout);
33afe3
 static int get_op_total_timeout(const remote_fencing_op_t *op,
33afe3
                                 const peer_device_info_t *chosen_peer);
33afe3
@@ -485,7 +484,9 @@ finalize_op_duplicates(remote_fencing_op_t *op, xmlNode *data,
33afe3
                       other->client_name, other->originator,
33afe3
                       pcmk_exec_status_str(result->execution_status),
33afe3
                       other->id);
33afe3
-            finalize_op(other, data, result, true);
33afe3
+            pcmk__set_result(&other->result, result->exit_status,
33afe3
+                             result->execution_status, result->exit_reason);
33afe3
+            finalize_op(other, data, true);
33afe3
 
33afe3
         } else {
33afe3
             // Possible if (for example) it timed out already
33afe3
@@ -520,20 +521,20 @@ delegate_from_xml(xmlNode *xml)
33afe3
  *
33afe3
  * \param[in] op      Fencer operation that completed
33afe3
  * \param[in] data    If not NULL, XML reply of last delegated fencing operation
33afe3
- * \param[in] result  Full operation result
33afe3
  * \param[in] dup     Whether this operation is a duplicate of another
33afe3
  *                    (in which case, do not broadcast the result)
33afe3
+ *
33afe3
+ *  \note The operation result should be set before calling this function.
33afe3
  */
33afe3
 static void
33afe3
-finalize_op(remote_fencing_op_t *op, xmlNode *data,
33afe3
-            pcmk__action_result_t *result, bool dup)
33afe3
+finalize_op(remote_fencing_op_t *op, xmlNode *data, bool dup)
33afe3
 {
33afe3
     int level = LOG_ERR;
33afe3
     const char *subt = NULL;
33afe3
     xmlNode *local_data = NULL;
33afe3
     gboolean op_merged = FALSE;
33afe3
 
33afe3
-    CRM_CHECK((op != NULL) && (result != NULL), return);
33afe3
+    CRM_CHECK((op != NULL), return);
33afe3
 
33afe3
     if (op->notify_sent) {
33afe3
         // Most likely, this is a timed-out action that eventually completed
33afe3
@@ -557,11 +558,11 @@ finalize_op(remote_fencing_op_t *op, xmlNode *data,
33afe3
         local_data = data;
33afe3
 
33afe3
     } else if (op->delegate == NULL) {
33afe3
-        switch (result->execution_status) {
33afe3
+        switch (op->result.execution_status) {
33afe3
             case PCMK_EXEC_NO_FENCE_DEVICE:
33afe3
                 break;
33afe3
             case PCMK_EXEC_INVALID:
33afe3
-                if (result->exit_status == CRM_EX_EXPIRED) {
33afe3
+                if (op->result.exit_status == CRM_EX_EXPIRED) {
33afe3
                     break;
33afe3
                 }
33afe3
                 // else fall through
33afe3
@@ -581,12 +582,12 @@ finalize_op(remote_fencing_op_t *op, xmlNode *data,
33afe3
     subt = crm_element_value(data, F_SUBTYPE);
33afe3
     if (!dup && !pcmk__str_eq(subt, "broadcast", pcmk__str_casei)) {
33afe3
         /* Defer notification until the bcast message arrives */
33afe3
-        fenced_broadcast_op_result(op, result, op_merged);
33afe3
+        fenced_broadcast_op_result(op, &op->result, op_merged);
33afe3
         free_xml(local_data);
33afe3
         return;
33afe3
     }
33afe3
 
33afe3
-    if (pcmk__result_ok(result) || dup
33afe3
+    if (pcmk__result_ok(&op->result) || dup
33afe3
         || !pcmk__str_eq(op->originator, stonith_our_uname, pcmk__str_casei)) {
33afe3
         level = LOG_NOTICE;
33afe3
     }
33afe3
@@ -595,16 +596,17 @@ finalize_op(remote_fencing_op_t *op, xmlNode *data,
33afe3
                (op->target? op->target : ""),
33afe3
                (op->delegate? op->delegate : "unknown node"),
33afe3
                op->client_name, op->originator,
33afe3
-               (op_merged? " (merged)" : ""), crm_exit_str(result->exit_status),
33afe3
-               pcmk_exec_status_str(result->execution_status),
33afe3
-               ((result->exit_reason == NULL)? "" : ": "),
33afe3
-               ((result->exit_reason == NULL)? "" : result->exit_reason),
33afe3
+               (op_merged? " (merged)" : ""),
33afe3
+               crm_exit_str(op->result.exit_status),
33afe3
+               pcmk_exec_status_str(op->result.execution_status),
33afe3
+               ((op->result.exit_reason == NULL)? "" : ": "),
33afe3
+               ((op->result.exit_reason == NULL)? "" : op->result.exit_reason),
33afe3
                op->id);
33afe3
 
33afe3
-    handle_local_reply_and_notify(op, data, result);
33afe3
+    handle_local_reply_and_notify(op, data, &op->result);
33afe3
 
33afe3
     if (!dup) {
33afe3
-        finalize_op_duplicates(op, data, result);
33afe3
+        finalize_op_duplicates(op, data, &op->result);
33afe3
     }
33afe3
 
33afe3
     /* Free non-essential parts of the record
33afe3
@@ -634,7 +636,6 @@ static gboolean
33afe3
 remote_op_watchdog_done(gpointer userdata)
33afe3
 {
33afe3
     remote_fencing_op_t *op = userdata;
33afe3
-    pcmk__action_result_t result = PCMK__UNKNOWN_RESULT;
33afe3
 
33afe3
     op->op_timer_one = 0;
33afe3
 
33afe3
@@ -642,8 +643,8 @@ remote_op_watchdog_done(gpointer userdata)
33afe3
                CRM_XS " id=%.8s",
33afe3
                op->action, op->target, op->client_name, op->id);
33afe3
     op->state = st_done;
33afe3
-    pcmk__set_result(&result, CRM_EX_OK, PCMK_EXEC_DONE, NULL);
33afe3
-    finalize_op(op, NULL, &result, false);
33afe3
+    pcmk__set_result(&op->result, CRM_EX_OK, PCMK_EXEC_DONE, NULL);
33afe3
+    finalize_op(op, NULL, false);
33afe3
     return G_SOURCE_REMOVE;
33afe3
 }
33afe3
 
33afe3
@@ -676,8 +677,6 @@ remote_op_timeout_one(gpointer userdata)
33afe3
 static void
33afe3
 finalize_timed_out_op(remote_fencing_op_t *op, const char *reason)
33afe3
 {
33afe3
-    pcmk__action_result_t result = PCMK__UNKNOWN_RESULT;
33afe3
-
33afe3
     op->op_timer_total = 0;
33afe3
 
33afe3
     crm_debug("Action '%s' targeting %s for client %s timed out "
33afe3
@@ -690,13 +689,12 @@ finalize_timed_out_op(remote_fencing_op_t *op, const char *reason)
33afe3
          * devices, and return success.
33afe3
          */
33afe3
         op->state = st_done;
33afe3
-        pcmk__set_result(&result, CRM_EX_OK, PCMK_EXEC_DONE, NULL);
33afe3
+        pcmk__set_result(&op->result, CRM_EX_OK, PCMK_EXEC_DONE, NULL);
33afe3
     } else {
33afe3
         op->state = st_failed;
33afe3
-        pcmk__set_result(&result, CRM_EX_ERROR, PCMK_EXEC_TIMEOUT, reason);
33afe3
+        pcmk__set_result(&op->result, CRM_EX_ERROR, PCMK_EXEC_TIMEOUT, reason);
33afe3
     }
33afe3
-    finalize_op(op, NULL, &result, false);
33afe3
-    pcmk__reset_result(&result);
33afe3
+    finalize_op(op, NULL, false);
33afe3
 }
33afe3
 
33afe3
 /*!
33afe3
@@ -1094,13 +1092,9 @@ fenced_handle_manual_confirmation(pcmk__client_t *client, xmlNode *msg)
33afe3
     set_fencing_completed(op);
33afe3
     op->delegate = strdup("a human");
33afe3
 
33afe3
-    {
33afe3
-        // For the fencer's purposes, the fencing operation is done
33afe3
-        pcmk__action_result_t result = PCMK__UNKNOWN_RESULT;
33afe3
-
33afe3
-        pcmk__set_result(&result, CRM_EX_OK, PCMK_EXEC_DONE, NULL);
33afe3
-        finalize_op(op, msg, &result, false);
33afe3
-    }
33afe3
+    // For the fencer's purposes, the fencing operation is done
33afe3
+    pcmk__set_result(&op->result, CRM_EX_OK, PCMK_EXEC_DONE, NULL);
33afe3
+    finalize_op(op, msg, false);
33afe3
 
33afe3
     /* For the requester's purposes, the operation is still pending. The
33afe3
      * actual result will be sent asynchronously via the operation's done_cb().
33afe3
@@ -1279,16 +1273,11 @@ initiate_remote_stonith_op(pcmk__client_t *client, xmlNode *request,
33afe3
     switch (op->state) {
33afe3
         case st_failed:
33afe3
             // advance_topology_level() exhausted levels
33afe3
-            {
33afe3
-                pcmk__action_result_t result = PCMK__UNKNOWN_RESULT;
33afe3
-
33afe3
-                pcmk__set_result(&result, CRM_EX_ERROR, PCMK_EXEC_ERROR,
33afe3
-                                 "All topology levels failed");
33afe3
-                crm_warn("Could not request peer fencing (%s) targeting %s "
33afe3
-                         CRM_XS " id=%.8s", op->action, op->target, op->id);
33afe3
-                finalize_op(op, NULL, &result, false);
33afe3
-                pcmk__reset_result(&result);
33afe3
-            }
33afe3
+            pcmk__set_result(&op->result, CRM_EX_ERROR, PCMK_EXEC_ERROR,
33afe3
+                             "All topology levels failed");
33afe3
+            crm_warn("Could not request peer fencing (%s) targeting %s "
33afe3
+                     CRM_XS " id=%.8s", op->action, op->target, op->id);
33afe3
+            finalize_op(op, NULL, false);
33afe3
             return op;
33afe3
 
33afe3
         case st_duplicate:
33afe3
@@ -1613,10 +1602,6 @@ static void
33afe3
 advance_topology_device_in_level(remote_fencing_op_t *op, const char *device,
33afe3
                                  xmlNode *msg)
33afe3
 {
33afe3
-    pcmk__action_result_t result = PCMK__UNKNOWN_RESULT;
33afe3
-
33afe3
-    pcmk__set_result(&result, CRM_EX_OK, PCMK_EXEC_DONE, NULL);
33afe3
-
33afe3
     /* Advance to the next device at this topology level, if any */
33afe3
     if (op->devices) {
33afe3
         op->devices = op->devices->next;
33afe3
@@ -1644,6 +1629,10 @@ advance_topology_device_in_level(remote_fencing_op_t *op, const char *device,
33afe3
     }
33afe3
 
33afe3
     if (op->devices) {
33afe3
+        pcmk__action_result_t result = PCMK__UNKNOWN_RESULT;
33afe3
+
33afe3
+        pcmk__set_result(&result, CRM_EX_OK, PCMK_EXEC_DONE, NULL);
33afe3
+
33afe3
         /* Necessary devices remain, so execute the next one */
33afe3
         crm_trace("Next targeting %s on behalf of %s@%s",
33afe3
                   op->target, op->client_name, op->originator);
33afe3
@@ -1659,7 +1648,8 @@ advance_topology_device_in_level(remote_fencing_op_t *op, const char *device,
33afe3
         crm_trace("Marking complex fencing op targeting %s as complete",
33afe3
                   op->target);
33afe3
         op->state = st_done;
33afe3
-        finalize_op(op, msg, &result, false);
33afe3
+        pcmk__set_result(&op->result, CRM_EX_OK, PCMK_EXEC_DONE, NULL);
33afe3
+        finalize_op(op, msg, false);
33afe3
     }
33afe3
 }
33afe3
 
33afe3
@@ -1868,7 +1858,9 @@ request_peer_fencing(remote_fencing_op_t *op, peer_device_info_t *peer,
33afe3
         }
33afe3
 
33afe3
         op->state = st_failed;
33afe3
-        finalize_op(op, NULL, result, false);
33afe3
+        pcmk__set_result(&op->result, result->exit_status,
33afe3
+                         result->execution_status, result->exit_reason);
33afe3
+        finalize_op(op, NULL, false);
33afe3
 
33afe3
     } else {
33afe3
         crm_info("Waiting for additional peers capable of fencing (%s) %s%s%s "
33afe3
@@ -2245,31 +2237,34 @@ fenced_process_fencing_reply(xmlNode *msg)
33afe3
         /* Could be for an event that began before we started */
33afe3
         /* TODO: Record the op for later querying */
33afe3
         crm_info("Received peer result of unknown or expired operation %s", id);
33afe3
-        goto done;
33afe3
+        pcmk__reset_result(&result);
33afe3
+        return;
33afe3
     }
33afe3
 
33afe3
+    op->result = result; // The operation takes ownership of the result
33afe3
+
33afe3
     if (op->devices && device && !pcmk__str_eq(op->devices->data, device, pcmk__str_casei)) {
33afe3
         crm_err("Received outdated reply for device %s (instead of %s) to "
33afe3
                 "fence (%s) %s. Operation already timed out at peer level.",
33afe3
                 device, (const char *) op->devices->data, op->action, op->target);
33afe3
-        goto done;
33afe3
+        return;
33afe3
     }
33afe3
 
33afe3
     if (pcmk__str_eq(crm_element_value(msg, F_SUBTYPE), "broadcast", pcmk__str_casei)) {
33afe3
         crm_debug("Finalizing action '%s' targeting %s on behalf of %s@%s: %s%s%s%s "
33afe3
                   CRM_XS " id=%.8s",
33afe3
                   op->action, op->target, op->client_name, op->originator,
33afe3
-                  pcmk_exec_status_str(result.execution_status),
33afe3
-                  (result.exit_reason == NULL)? "" : " (",
33afe3
-                  (result.exit_reason == NULL)? "" : result.exit_reason,
33afe3
-                  (result.exit_reason == NULL)? "" : ")", op->id);
33afe3
-        if (pcmk__result_ok(&result)) {
33afe3
+                  pcmk_exec_status_str(op->result.execution_status),
33afe3
+                  (op->result.exit_reason == NULL)? "" : " (",
33afe3
+                  (op->result.exit_reason == NULL)? "" : op->result.exit_reason,
33afe3
+                  (op->result.exit_reason == NULL)? "" : ")", op->id);
33afe3
+        if (pcmk__result_ok(&op->result)) {
33afe3
             op->state = st_done;
33afe3
         } else {
33afe3
             op->state = st_failed;
33afe3
         }
33afe3
-        finalize_op(op, msg, &result, false);
33afe3
-        goto done;
33afe3
+        finalize_op(op, msg, false);
33afe3
+        return;
33afe3
 
33afe3
     } else if (!pcmk__str_eq(op->originator, stonith_our_uname, pcmk__str_casei)) {
33afe3
         /* If this isn't a remote level broadcast, and we are not the
33afe3
@@ -2277,7 +2272,7 @@ fenced_process_fencing_reply(xmlNode *msg)
33afe3
         crm_err("Received non-broadcast fencing result for operation %.8s "
33afe3
                 "we do not own (device %s targeting %s)",
33afe3
                 op->id, device, op->target);
33afe3
-        goto done;
33afe3
+        return;
33afe3
     }
33afe3
 
33afe3
     if (pcmk_is_set(op->call_options, st_opt_topology)) {
33afe3
@@ -2286,58 +2281,58 @@ fenced_process_fencing_reply(xmlNode *msg)
33afe3
         crm_notice("Action '%s' targeting %s using %s on behalf of %s@%s: %s%s%s%s",
33afe3
                    op->action, op->target, device, op->client_name,
33afe3
                    op->originator,
33afe3
-                   pcmk_exec_status_str(result.execution_status),
33afe3
-                  (result.exit_reason == NULL)? "" : " (",
33afe3
-                  (result.exit_reason == NULL)? "" : result.exit_reason,
33afe3
-                  (result.exit_reason == NULL)? "" : ")");
33afe3
+                   pcmk_exec_status_str(op->result.execution_status),
33afe3
+                  (op->result.exit_reason == NULL)? "" : " (",
33afe3
+                  (op->result.exit_reason == NULL)? "" : op->result.exit_reason,
33afe3
+                  (op->result.exit_reason == NULL)? "" : ")");
33afe3
 
33afe3
         /* We own the op, and it is complete. broadcast the result to all nodes
33afe3
          * and notify our local clients. */
33afe3
         if (op->state == st_done) {
33afe3
-            finalize_op(op, msg, &result, false);
33afe3
-            goto done;
33afe3
+            finalize_op(op, msg, false);
33afe3
+            return;
33afe3
         }
33afe3
 
33afe3
-        if ((op->phase == 2) && !pcmk__result_ok(&result)) {
33afe3
+        if ((op->phase == 2) && !pcmk__result_ok(&op->result)) {
33afe3
             /* A remapped "on" failed, but the node was already turned off
33afe3
              * successfully, so ignore the error and continue.
33afe3
              */
33afe3
             crm_warn("Ignoring %s 'on' failure (%s%s%s) targeting %s "
33afe3
                      "after successful 'off'",
33afe3
-                     device, pcmk_exec_status_str(result.execution_status),
33afe3
-                     (result.exit_reason == NULL)? "" : ": ",
33afe3
-                     (result.exit_reason == NULL)? "" : result.exit_reason,
33afe3
+                     device, pcmk_exec_status_str(op->result.execution_status),
33afe3
+                     (op->result.exit_reason == NULL)? "" : ": ",
33afe3
+                     (op->result.exit_reason == NULL)? "" : op->result.exit_reason,
33afe3
                      op->target);
33afe3
-            pcmk__set_result(&result, CRM_EX_OK, PCMK_EXEC_DONE, NULL);
33afe3
+            pcmk__set_result(&op->result, CRM_EX_OK, PCMK_EXEC_DONE, NULL);
33afe3
         }
33afe3
 
33afe3
-        if (pcmk__result_ok(&result)) {
33afe3
+        if (pcmk__result_ok(&op->result)) {
33afe3
             /* An operation completed successfully. Try another device if
33afe3
              * necessary, otherwise mark the operation as done. */
33afe3
             advance_topology_device_in_level(op, device, msg);
33afe3
-            goto done;
33afe3
+            return;
33afe3
         } else {
33afe3
             /* This device failed, time to try another topology level. If no other
33afe3
              * levels are available, mark this operation as failed and report results. */
33afe3
             if (advance_topology_level(op, false) != pcmk_rc_ok) {
33afe3
                 op->state = st_failed;
33afe3
-                finalize_op(op, msg, &result, false);
33afe3
-                goto done;
33afe3
+                finalize_op(op, msg, false);
33afe3
+                return;
33afe3
             }
33afe3
         }
33afe3
 
33afe3
-    } else if (pcmk__result_ok(&result) && (op->devices == NULL)) {
33afe3
+    } else if (pcmk__result_ok(&op->result) && (op->devices == NULL)) {
33afe3
         crm_trace("All done for %s", op->target);
33afe3
         op->state = st_done;
33afe3
-        finalize_op(op, msg, &result, false);
33afe3
-        goto done;
33afe3
+        finalize_op(op, msg, false);
33afe3
+        return;
33afe3
 
33afe3
-    } else if ((result.execution_status == PCMK_EXEC_TIMEOUT)
33afe3
+    } else if ((op->result.execution_status == PCMK_EXEC_TIMEOUT)
33afe3
                && (op->devices == NULL)) {
33afe3
         /* If the operation timed out don't bother retrying other peers. */
33afe3
         op->state = st_failed;
33afe3
-        finalize_op(op, msg, &result, false);
33afe3
-        goto done;
33afe3
+        finalize_op(op, msg, false);
33afe3
+        return;
33afe3
 
33afe3
     } else {
33afe3
         /* fall-through and attempt other fencing action using another peer */
33afe3
@@ -2346,10 +2341,8 @@ fenced_process_fencing_reply(xmlNode *msg)
33afe3
     /* Retry on failure */
33afe3
     crm_trace("Next for %s on behalf of %s@%s (result was: %s)",
33afe3
               op->target, op->originator, op->client_name,
33afe3
-              pcmk_exec_status_str(result.execution_status));
33afe3
-    request_peer_fencing(op, NULL, &result);
33afe3
-done:
33afe3
-    pcmk__reset_result(&result);
33afe3
+              pcmk_exec_status_str(op->result.execution_status));
33afe3
+    request_peer_fencing(op, NULL, &op->result);
33afe3
 }
33afe3
 
33afe3
 gboolean
33afe3
-- 
33afe3
2.27.0
33afe3
33afe3
33afe3
From c59d062154f7c9e15e90929a20ea244d7efd7247 Mon Sep 17 00:00:00 2001
33afe3
From: Ken Gaillot <kgaillot@redhat.com>
33afe3
Date: Thu, 6 Jan 2022 17:11:12 -0600
33afe3
Subject: [PATCH 03/15] Refactor: fencer: drop redundant argument from
33afe3
 finalize_op_duplicates()
33afe3
33afe3
... now that the result is in the op
33afe3
---
33afe3
 daemons/fenced/fenced_remote.c | 13 ++++++-------
33afe3
 1 file changed, 6 insertions(+), 7 deletions(-)
33afe3
33afe3
diff --git a/daemons/fenced/fenced_remote.c b/daemons/fenced/fenced_remote.c
33afe3
index 30edbff890..8b496e1042 100644
33afe3
--- a/daemons/fenced/fenced_remote.c
33afe3
+++ b/daemons/fenced/fenced_remote.c
33afe3
@@ -468,11 +468,9 @@ handle_local_reply_and_notify(remote_fencing_op_t *op, xmlNode *data,
33afe3
  *
33afe3
  * \param[in] op         Fencer operation that completed
33afe3
  * \param[in] data       Top-level XML to add notification to
33afe3
- * \param[in] result     Full operation result
33afe3
  */
33afe3
 static void
33afe3
-finalize_op_duplicates(remote_fencing_op_t *op, xmlNode *data,
33afe3
-                       pcmk__action_result_t *result)
33afe3
+finalize_op_duplicates(remote_fencing_op_t *op, xmlNode *data)
33afe3
 {
33afe3
     for (GList *iter = op->duplicates; iter != NULL; iter = iter->next) {
33afe3
         remote_fencing_op_t *other = iter->data;
33afe3
@@ -482,10 +480,11 @@ finalize_op_duplicates(remote_fencing_op_t *op, xmlNode *data,
33afe3
             crm_debug("Performing duplicate notification for %s@%s: %s "
33afe3
                       CRM_XS " id=%.8s",
33afe3
                       other->client_name, other->originator,
33afe3
-                      pcmk_exec_status_str(result->execution_status),
33afe3
+                      pcmk_exec_status_str(op->result.execution_status),
33afe3
                       other->id);
33afe3
-            pcmk__set_result(&other->result, result->exit_status,
33afe3
-                             result->execution_status, result->exit_reason);
33afe3
+            pcmk__set_result(&other->result, op->result.exit_status,
33afe3
+                             op->result.execution_status,
33afe3
+                             op->result.exit_reason);
33afe3
             finalize_op(other, data, true);
33afe3
 
33afe3
         } else {
33afe3
@@ -606,7 +605,7 @@ finalize_op(remote_fencing_op_t *op, xmlNode *data, bool dup)
33afe3
     handle_local_reply_and_notify(op, data, &op->result);
33afe3
 
33afe3
     if (!dup) {
33afe3
-        finalize_op_duplicates(op, data, &op->result);
33afe3
+        finalize_op_duplicates(op, data);
33afe3
     }
33afe3
 
33afe3
     /* Free non-essential parts of the record
33afe3
-- 
33afe3
2.27.0
33afe3
33afe3
33afe3
From 6c49675855323a52a534afa112a0861ba2e3b1ad Mon Sep 17 00:00:00 2001
33afe3
From: Ken Gaillot <kgaillot@redhat.com>
33afe3
Date: Thu, 6 Jan 2022 17:15:17 -0600
33afe3
Subject: [PATCH 04/15] Refactor: fencer: drop redundant argument from
33afe3
 fenced_broadcast_op_result()
33afe3
33afe3
... now that the op includes the result
33afe3
---
33afe3
 daemons/fenced/fenced_history.c   | 9 +++------
33afe3
 daemons/fenced/fenced_remote.c    | 8 +++-----
33afe3
 daemons/fenced/pacemaker-fenced.h | 3 +--
33afe3
 3 files changed, 7 insertions(+), 13 deletions(-)
33afe3
33afe3
diff --git a/daemons/fenced/fenced_history.c b/daemons/fenced/fenced_history.c
33afe3
index 0157deadb3..5cacf36ca8 100644
33afe3
--- a/daemons/fenced/fenced_history.c
33afe3
+++ b/daemons/fenced/fenced_history.c
33afe3
@@ -1,5 +1,5 @@
33afe3
 /*
33afe3
- * Copyright 2009-2021 the Pacemaker project contributors
33afe3
+ * Copyright 2009-2022 the Pacemaker project contributors
33afe3
  *
33afe3
  * The version control history for this file may have further details.
33afe3
  *
33afe3
@@ -359,8 +359,6 @@ stonith_local_history_diff_and_merge(GHashTable *remote_history,
33afe3
     }
33afe3
 
33afe3
     if (remote_history) {
33afe3
-        pcmk__action_result_t result = PCMK__UNKNOWN_RESULT;
33afe3
-
33afe3
         init_stonith_remote_op_hash_table(&stonith_remote_op_list);
33afe3
 
33afe3
         updated |= g_hash_table_size(remote_history);
33afe3
@@ -378,10 +376,10 @@ stonith_local_history_diff_and_merge(GHashTable *remote_history,
33afe3
                 /* CRM_EX_EXPIRED + PCMK_EXEC_INVALID prevents finalize_op()
33afe3
                  * from setting a delegate
33afe3
                  */
33afe3
-                pcmk__set_result(&result, CRM_EX_EXPIRED, PCMK_EXEC_INVALID,
33afe3
+                pcmk__set_result(&op->result, CRM_EX_EXPIRED, PCMK_EXEC_INVALID,
33afe3
                                  "Initiated by earlier fencer "
33afe3
                                  "process and presumed failed");
33afe3
-                fenced_broadcast_op_result(op, &result, false);
33afe3
+                fenced_broadcast_op_result(op, false);
33afe3
             }
33afe3
 
33afe3
             g_hash_table_iter_steal(&iter);
33afe3
@@ -396,7 +394,6 @@ stonith_local_history_diff_and_merge(GHashTable *remote_history,
33afe3
              */
33afe3
         }
33afe3
 
33afe3
-        pcmk__reset_result(&result);
33afe3
         g_hash_table_destroy(remote_history); /* remove what is left */
33afe3
     }
33afe3
 
33afe3
diff --git a/daemons/fenced/fenced_remote.c b/daemons/fenced/fenced_remote.c
33afe3
index 8b496e1042..fb5a5e980e 100644
33afe3
--- a/daemons/fenced/fenced_remote.c
33afe3
+++ b/daemons/fenced/fenced_remote.c
33afe3
@@ -390,16 +390,14 @@ fencing_result2xml(remote_fencing_op_t *op, pcmk__action_result_t *result)
33afe3
  * \brief Broadcast a fence result notification to all CPG peers
33afe3
  *
33afe3
  * \param[in] op         Fencer operation that completed
33afe3
- * \param[in] result     Full operation result
33afe3
  * \param[in] op_merged  Whether this operation is a duplicate of another
33afe3
  */
33afe3
 void
33afe3
-fenced_broadcast_op_result(remote_fencing_op_t *op,
33afe3
-                           pcmk__action_result_t *result, bool op_merged)
33afe3
+fenced_broadcast_op_result(remote_fencing_op_t *op, bool op_merged)
33afe3
 {
33afe3
     static int count = 0;
33afe3
     xmlNode *bcast = create_xml_node(NULL, T_STONITH_REPLY);
33afe3
-    xmlNode *notify_data = fencing_result2xml(op, result);
33afe3
+    xmlNode *notify_data = fencing_result2xml(op, &op->result);
33afe3
 
33afe3
     count++;
33afe3
     crm_trace("Broadcasting result to peers");
33afe3
@@ -581,7 +579,7 @@ finalize_op(remote_fencing_op_t *op, xmlNode *data, bool dup)
33afe3
     subt = crm_element_value(data, F_SUBTYPE);
33afe3
     if (!dup && !pcmk__str_eq(subt, "broadcast", pcmk__str_casei)) {
33afe3
         /* Defer notification until the bcast message arrives */
33afe3
-        fenced_broadcast_op_result(op, &op->result, op_merged);
33afe3
+        fenced_broadcast_op_result(op, op_merged);
33afe3
         free_xml(local_data);
33afe3
         return;
33afe3
     }
33afe3
diff --git a/daemons/fenced/pacemaker-fenced.h b/daemons/fenced/pacemaker-fenced.h
33afe3
index 1a5c933ea7..6213407da3 100644
33afe3
--- a/daemons/fenced/pacemaker-fenced.h
33afe3
+++ b/daemons/fenced/pacemaker-fenced.h
33afe3
@@ -155,8 +155,7 @@ typedef struct remote_fencing_op_s {
33afe3
     pcmk__action_result_t result;
33afe3
 } remote_fencing_op_t;
33afe3
 
33afe3
-void fenced_broadcast_op_result(remote_fencing_op_t *op,
33afe3
-                                pcmk__action_result_t *result, bool op_merged);
33afe3
+void fenced_broadcast_op_result(remote_fencing_op_t *op, bool op_merged);
33afe3
 
33afe3
 // Fencer-specific client flags
33afe3
 enum st_client_flags {
33afe3
-- 
33afe3
2.27.0
33afe3
33afe3
33afe3
From 73994fc740b8833457b130368db479502d49f285 Mon Sep 17 00:00:00 2001
33afe3
From: Ken Gaillot <kgaillot@redhat.com>
33afe3
Date: Thu, 6 Jan 2022 17:17:33 -0600
33afe3
Subject: [PATCH 05/15] Refactor: fencer: drop redundant argument from
33afe3
 handle_local_reply_and_notify()
33afe3
33afe3
... now that the op includes the result
33afe3
---
33afe3
 daemons/fenced/fenced_remote.c | 12 +++++-------
33afe3
 1 file changed, 5 insertions(+), 7 deletions(-)
33afe3
33afe3
diff --git a/daemons/fenced/fenced_remote.c b/daemons/fenced/fenced_remote.c
33afe3
index fb5a5e980e..2621cb2f19 100644
33afe3
--- a/daemons/fenced/fenced_remote.c
33afe3
+++ b/daemons/fenced/fenced_remote.c
33afe3
@@ -424,11 +424,9 @@ fenced_broadcast_op_result(remote_fencing_op_t *op, bool op_merged)
33afe3
  *
33afe3
  * \param[in] op         Fencer operation that completed
33afe3
  * \param[in] data       Top-level XML to add notification to
33afe3
- * \param[in] result     Full operation result
33afe3
  */
33afe3
 static void
33afe3
-handle_local_reply_and_notify(remote_fencing_op_t *op, xmlNode *data,
33afe3
-                              pcmk__action_result_t *result)
33afe3
+handle_local_reply_and_notify(remote_fencing_op_t *op, xmlNode *data)
33afe3
 {
33afe3
     xmlNode *notify_data = NULL;
33afe3
     xmlNode *reply = NULL;
33afe3
@@ -443,15 +441,15 @@ handle_local_reply_and_notify(remote_fencing_op_t *op, xmlNode *data,
33afe3
     crm_xml_add(data, F_STONITH_TARGET, op->target);
33afe3
     crm_xml_add(data, F_STONITH_OPERATION, op->action);
33afe3
 
33afe3
-    reply = fenced_construct_reply(op->request, data, result);
33afe3
+    reply = fenced_construct_reply(op->request, data, &op->result);
33afe3
     crm_xml_add(reply, F_STONITH_DELEGATE, op->delegate);
33afe3
 
33afe3
     /* Send fencing OP reply to local client that initiated fencing */
33afe3
     do_local_reply(reply, op->client_id, op->call_options & st_opt_sync_call, FALSE);
33afe3
 
33afe3
     /* bcast to all local clients that the fencing operation happend */
33afe3
-    notify_data = fencing_result2xml(op, result);
33afe3
-    fenced_send_notification(T_STONITH_NOTIFY_FENCE, result, notify_data);
33afe3
+    notify_data = fencing_result2xml(op, &op->result);
33afe3
+    fenced_send_notification(T_STONITH_NOTIFY_FENCE, &op->result, notify_data);
33afe3
     free_xml(notify_data);
33afe3
     fenced_send_notification(T_STONITH_NOTIFY_HISTORY, NULL, NULL);
33afe3
 
33afe3
@@ -600,7 +598,7 @@ finalize_op(remote_fencing_op_t *op, xmlNode *data, bool dup)
33afe3
                ((op->result.exit_reason == NULL)? "" : op->result.exit_reason),
33afe3
                op->id);
33afe3
 
33afe3
-    handle_local_reply_and_notify(op, data, &op->result);
33afe3
+    handle_local_reply_and_notify(op, data);
33afe3
 
33afe3
     if (!dup) {
33afe3
         finalize_op_duplicates(op, data);
33afe3
-- 
33afe3
2.27.0
33afe3
33afe3
33afe3
From 194056d18d3b550d3a53b94d558ceed03b5e5442 Mon Sep 17 00:00:00 2001
33afe3
From: Ken Gaillot <kgaillot@redhat.com>
33afe3
Date: Thu, 6 Jan 2022 17:18:27 -0600
33afe3
Subject: [PATCH 06/15] Refactor: fencer: drop redundant argument from
33afe3
 fencing_result2xml()
33afe3
33afe3
... now that the op includes the result
33afe3
---
33afe3
 daemons/fenced/fenced_remote.c | 9 ++++-----
33afe3
 1 file changed, 4 insertions(+), 5 deletions(-)
33afe3
33afe3
diff --git a/daemons/fenced/fenced_remote.c b/daemons/fenced/fenced_remote.c
33afe3
index 2621cb2f19..8d4f53eef6 100644
33afe3
--- a/daemons/fenced/fenced_remote.c
33afe3
+++ b/daemons/fenced/fenced_remote.c
33afe3
@@ -362,13 +362,12 @@ undo_op_remap(remote_fencing_op_t *op)
33afe3
  * \brief Create notification data XML for a fencing operation result
33afe3
  *
33afe3
  * \param[in] op      Fencer operation that completed
33afe3
- * \param[in] result  Full operation result
33afe3
  *
33afe3
  * \return Newly created XML to add as notification data
33afe3
  * \note The caller is responsible for freeing the result.
33afe3
  */
33afe3
 static xmlNode *
33afe3
-fencing_result2xml(remote_fencing_op_t *op, pcmk__action_result_t *result)
33afe3
+fencing_result2xml(remote_fencing_op_t *op)
33afe3
 {
33afe3
     xmlNode *notify_data = create_xml_node(NULL, T_STONITH_NOTIFY_FENCE);
33afe3
 
33afe3
@@ -381,7 +380,7 @@ fencing_result2xml(remote_fencing_op_t *op, pcmk__action_result_t *result)
33afe3
     crm_xml_add(notify_data, F_STONITH_CLIENTID, op->client_id);
33afe3
     crm_xml_add(notify_data, F_STONITH_CLIENTNAME, op->client_name);
33afe3
 
33afe3
-    stonith__xe_set_result(notify_data, result);
33afe3
+    stonith__xe_set_result(notify_data, &op->result);
33afe3
     return notify_data;
33afe3
 }
33afe3
 
33afe3
@@ -397,7 +396,7 @@ fenced_broadcast_op_result(remote_fencing_op_t *op, bool op_merged)
33afe3
 {
33afe3
     static int count = 0;
33afe3
     xmlNode *bcast = create_xml_node(NULL, T_STONITH_REPLY);
33afe3
-    xmlNode *notify_data = fencing_result2xml(op, &op->result);
33afe3
+    xmlNode *notify_data = fencing_result2xml(op);
33afe3
 
33afe3
     count++;
33afe3
     crm_trace("Broadcasting result to peers");
33afe3
@@ -448,7 +447,7 @@ handle_local_reply_and_notify(remote_fencing_op_t *op, xmlNode *data)
33afe3
     do_local_reply(reply, op->client_id, op->call_options & st_opt_sync_call, FALSE);
33afe3
 
33afe3
     /* bcast to all local clients that the fencing operation happend */
33afe3
-    notify_data = fencing_result2xml(op, &op->result);
33afe3
+    notify_data = fencing_result2xml(op);
33afe3
     fenced_send_notification(T_STONITH_NOTIFY_FENCE, &op->result, notify_data);
33afe3
     free_xml(notify_data);
33afe3
     fenced_send_notification(T_STONITH_NOTIFY_HISTORY, NULL, NULL);
33afe3
-- 
33afe3
2.27.0
33afe3
33afe3
33afe3
From c5d38cb201a1219ca95127cba9c3a778e31966a2 Mon Sep 17 00:00:00 2001
33afe3
From: Ken Gaillot <kgaillot@redhat.com>
33afe3
Date: Thu, 6 Jan 2022 17:35:43 -0600
33afe3
Subject: [PATCH 07/15] Refactor: fencer: drop redundant argument from
33afe3
 request_peer_fencing()
33afe3
33afe3
... now that the op includes the result
33afe3
---
33afe3
 daemons/fenced/fenced_remote.c | 66 +++++++++++++---------------------
33afe3
 1 file changed, 25 insertions(+), 41 deletions(-)
33afe3
33afe3
diff --git a/daemons/fenced/fenced_remote.c b/daemons/fenced/fenced_remote.c
33afe3
index 8d4f53eef6..7fb7695fba 100644
33afe3
--- a/daemons/fenced/fenced_remote.c
33afe3
+++ b/daemons/fenced/fenced_remote.c
33afe3
@@ -80,8 +80,7 @@ extern xmlNode *stonith_create_op(int call_id, const char *token, const char *op
33afe3
                                   int call_options);
33afe3
 
33afe3
 static void request_peer_fencing(remote_fencing_op_t *op,
33afe3
-                                peer_device_info_t *peer,
33afe3
-                                pcmk__action_result_t *result);
33afe3
+                                 peer_device_info_t *peer);
33afe3
 static void finalize_op(remote_fencing_op_t *op, xmlNode *data, bool dup);
33afe3
 static void report_timeout_period(remote_fencing_op_t * op, int op_timeout);
33afe3
 static int get_op_total_timeout(const remote_fencing_op_t *op,
33afe3
@@ -646,18 +645,16 @@ static gboolean
33afe3
 remote_op_timeout_one(gpointer userdata)
33afe3
 {
33afe3
     remote_fencing_op_t *op = userdata;
33afe3
-    pcmk__action_result_t result = PCMK__UNKNOWN_RESULT;
33afe3
 
33afe3
     op->op_timer_one = 0;
33afe3
 
33afe3
     crm_notice("Peer's '%s' action targeting %s for client %s timed out " CRM_XS
33afe3
                " id=%.8s", op->action, op->target, op->client_name, op->id);
33afe3
-    pcmk__set_result(&result, CRM_EX_ERROR, PCMK_EXEC_TIMEOUT,
33afe3
+    pcmk__set_result(&op->result, CRM_EX_ERROR, PCMK_EXEC_TIMEOUT,
33afe3
                      "Peer did not return fence result within timeout");
33afe3
 
33afe3
-
33afe3
     // Try another device, if appropriate
33afe3
-    request_peer_fencing(op, NULL, &result);
33afe3
+    request_peer_fencing(op, NULL);
33afe3
     return FALSE;
33afe3
 }
33afe3
 
33afe3
@@ -730,13 +727,10 @@ remote_op_query_timeout(gpointer data)
33afe3
         crm_debug("Operation %.8s targeting %s already in progress",
33afe3
                   op->id, op->target);
33afe3
     } else if (op->query_results) {
33afe3
-        // Result won't be used in this case, but we need to pass something
33afe3
-        pcmk__action_result_t result = PCMK__UNKNOWN_RESULT;
33afe3
-
33afe3
         // Query succeeded, so attempt the actual fencing
33afe3
         crm_debug("Query %.8s targeting %s complete (state=%s)",
33afe3
                   op->id, op->target, stonith_op_state_str(op->state));
33afe3
-        request_peer_fencing(op, NULL, &result);
33afe3
+        request_peer_fencing(op, NULL);
33afe3
     } else {
33afe3
         crm_debug("Query %.8s targeting %s timed out (state=%s)",
33afe3
                   op->id, op->target, stonith_op_state_str(op->state));
33afe3
@@ -1622,11 +1616,10 @@ advance_topology_device_in_level(remote_fencing_op_t *op, const char *device,
33afe3
         op_phase_on(op);
33afe3
     }
33afe3
 
33afe3
-    if (op->devices) {
33afe3
-        pcmk__action_result_t result = PCMK__UNKNOWN_RESULT;
33afe3
-
33afe3
-        pcmk__set_result(&result, CRM_EX_OK, PCMK_EXEC_DONE, NULL);
33afe3
+    // This function is only called if the previous device succeeded
33afe3
+    pcmk__set_result(&op->result, CRM_EX_OK, PCMK_EXEC_DONE, NULL);
33afe3
 
33afe3
+    if (op->devices) {
33afe3
         /* Necessary devices remain, so execute the next one */
33afe3
         crm_trace("Next targeting %s on behalf of %s@%s",
33afe3
                   op->target, op->client_name, op->originator);
33afe3
@@ -1636,13 +1629,12 @@ advance_topology_device_in_level(remote_fencing_op_t *op, const char *device,
33afe3
             op->delay = 0;
33afe3
         }
33afe3
 
33afe3
-        request_peer_fencing(op, NULL, &result);
33afe3
+        request_peer_fencing(op, NULL);
33afe3
     } else {
33afe3
         /* We're done with all devices and phases, so finalize operation */
33afe3
         crm_trace("Marking complex fencing op targeting %s as complete",
33afe3
                   op->target);
33afe3
         op->state = st_done;
33afe3
-        pcmk__set_result(&op->result, CRM_EX_OK, PCMK_EXEC_DONE, NULL);
33afe3
         finalize_op(op, msg, false);
33afe3
     }
33afe3
 }
33afe3
@@ -1673,13 +1665,9 @@ check_watchdog_fencing_and_wait(remote_fencing_op_t * op)
33afe3
  * \param[in] op      Fencing operation to be executed
33afe3
  * \param[in] peer    If NULL or topology is in use, choose best peer to execute
33afe3
  *                    the fencing, otherwise use this peer
33afe3
- * \param[in] result  Full result of previous failed attempt, if any (used as
33afe3
- *                    final result only if a previous attempt failed, topology
33afe3
- *                    is not in use, and no devices remain to be attempted)
33afe3
  */
33afe3
 static void
33afe3
-request_peer_fencing(remote_fencing_op_t *op, peer_device_info_t *peer,
33afe3
-                    pcmk__action_result_t *result)
33afe3
+request_peer_fencing(remote_fencing_op_t *op, peer_device_info_t *peer)
33afe3
 {
33afe3
     const char *device = NULL;
33afe3
     int timeout;
33afe3
@@ -1822,27 +1810,26 @@ request_peer_fencing(remote_fencing_op_t *op, peer_device_info_t *peer,
33afe3
             }
33afe3
         }
33afe3
 
33afe3
-        // This is the only case in which result will be used
33afe3
-        CRM_CHECK(result != NULL, return);
33afe3
-
33afe3
         if (op->state == st_query) {
33afe3
             crm_info("No peers (out of %d) have devices capable of fencing "
33afe3
                      "(%s) %s for client %s " CRM_XS " state=%s",
33afe3
                      op->replies, op->action, op->target, op->client_name,
33afe3
                      stonith_op_state_str(op->state));
33afe3
 
33afe3
-            pcmk__reset_result(result);
33afe3
-            pcmk__set_result(result, CRM_EX_ERROR, PCMK_EXEC_NO_FENCE_DEVICE,
33afe3
-                             NULL);
33afe3
+            pcmk__reset_result(&op->result);
33afe3
+            pcmk__set_result(&op->result, CRM_EX_ERROR,
33afe3
+                             PCMK_EXEC_NO_FENCE_DEVICE, NULL);
33afe3
         } else {
33afe3
             if (pcmk_is_set(op->call_options, st_opt_topology)) {
33afe3
-                pcmk__reset_result(result);
33afe3
-                pcmk__set_result(result, CRM_EX_ERROR,
33afe3
+                pcmk__reset_result(&op->result);
33afe3
+                pcmk__set_result(&op->result, CRM_EX_ERROR,
33afe3
                                  PCMK_EXEC_NO_FENCE_DEVICE, NULL);
33afe3
             }
33afe3
-            /* ... else use result provided by caller -- overwriting it with
33afe3
-               PCMK_EXEC_NO_FENCE_DEVICE would prevent finalize_op() from
33afe3
-               setting the correct delegate if needed.
33afe3
+            /* ... else use existing result from previous failed attempt
33afe3
+             * (topology is not in use, and no devices remain to be attempted).
33afe3
+             * Overwriting the result with PCMK_EXEC_NO_FENCE_DEVICE would
33afe3
+             * prevent finalize_op() from setting the correct delegate if
33afe3
+             * needed.
33afe3
              */
33afe3
 
33afe3
             crm_info("No peers (out of %d) are capable of fencing (%s) %s "
33afe3
@@ -1852,8 +1839,6 @@ request_peer_fencing(remote_fencing_op_t *op, peer_device_info_t *peer,
33afe3
         }
33afe3
 
33afe3
         op->state = st_failed;
33afe3
-        pcmk__set_result(&op->result, result->exit_status,
33afe3
-                         result->execution_status, result->exit_reason);
33afe3
         finalize_op(op, NULL, false);
33afe3
 
33afe3
     } else {
33afe3
@@ -2104,7 +2089,6 @@ process_remote_stonith_query(xmlNode * msg)
33afe3
     peer_device_info_t *peer = NULL;
33afe3
     uint32_t replies_expected;
33afe3
     xmlNode *dev = get_xpath_object("//@" F_STONITH_REMOTE_OP_ID, msg, LOG_ERR);
33afe3
-    pcmk__action_result_t result = PCMK__UNKNOWN_RESULT;
33afe3
 
33afe3
     CRM_CHECK(dev != NULL, return -EPROTO);
33afe3
 
33afe3
@@ -2139,7 +2123,7 @@ process_remote_stonith_query(xmlNode * msg)
33afe3
         peer = add_result(op, host, ndevices, dev);
33afe3
     }
33afe3
 
33afe3
-    pcmk__set_result(&result, CRM_EX_OK, PCMK_EXEC_DONE, NULL);
33afe3
+    pcmk__set_result(&op->result, CRM_EX_OK, PCMK_EXEC_DONE, NULL);
33afe3
 
33afe3
     if (pcmk_is_set(op->call_options, st_opt_topology)) {
33afe3
         /* If we start the fencing before all the topology results are in,
33afe3
@@ -2148,12 +2132,12 @@ process_remote_stonith_query(xmlNode * msg)
33afe3
         if (op->state == st_query && all_topology_devices_found(op)) {
33afe3
             /* All the query results are in for the topology, start the fencing ops. */
33afe3
             crm_trace("All topology devices found");
33afe3
-            request_peer_fencing(op, peer, &result);
33afe3
+            request_peer_fencing(op, peer);
33afe3
 
33afe3
         } else if (have_all_replies) {
33afe3
             crm_info("All topology query replies have arrived, continuing (%d expected/%d received) ",
33afe3
                      replies_expected, op->replies);
33afe3
-            request_peer_fencing(op, NULL, &result);
33afe3
+            request_peer_fencing(op, NULL);
33afe3
         }
33afe3
 
33afe3
     } else if (op->state == st_query) {
33afe3
@@ -2165,12 +2149,12 @@ process_remote_stonith_query(xmlNode * msg)
33afe3
             /* we have a verified device living on a peer that is not the target */
33afe3
             crm_trace("Found %d verified device%s",
33afe3
                       nverified, pcmk__plural_s(nverified));
33afe3
-            request_peer_fencing(op, peer, &result);
33afe3
+            request_peer_fencing(op, peer);
33afe3
 
33afe3
         } else if (have_all_replies) {
33afe3
             crm_info("All query replies have arrived, continuing (%d expected/%d received) ",
33afe3
                      replies_expected, op->replies);
33afe3
-            request_peer_fencing(op, NULL, &result);
33afe3
+            request_peer_fencing(op, NULL);
33afe3
 
33afe3
         } else {
33afe3
             crm_trace("Waiting for more peer results before launching fencing operation");
33afe3
@@ -2336,7 +2320,7 @@ fenced_process_fencing_reply(xmlNode *msg)
33afe3
     crm_trace("Next for %s on behalf of %s@%s (result was: %s)",
33afe3
               op->target, op->originator, op->client_name,
33afe3
               pcmk_exec_status_str(op->result.execution_status));
33afe3
-    request_peer_fencing(op, NULL, &op->result);
33afe3
+    request_peer_fencing(op, NULL);
33afe3
 }
33afe3
 
33afe3
 gboolean
33afe3
-- 
33afe3
2.27.0
33afe3
33afe3
33afe3
From be0a0b652c13161a82b05d3104449b7bfc06e8ac Mon Sep 17 00:00:00 2001
33afe3
From: Ken Gaillot <kgaillot@redhat.com>
33afe3
Date: Thu, 6 Jan 2022 17:56:24 -0600
33afe3
Subject: [PATCH 08/15] Feature: fencer: track full result in fencing history
33afe3
33afe3
Add fencing operation results when creating XML in
33afe3
stonith_local_history_diff_and_merge(), and parse the results from the received
33afe3
XML in stonith_xml_history_to_list().
33afe3
33afe3
With this, the fencer now always has full results in its op list, and returns
33afe3
them in the reply for STONITH_OP_FENCE_HISTORY requests (though nothing uses
33afe3
that as of this commit).
33afe3
---
33afe3
 daemons/fenced/fenced_history.c | 2 ++
33afe3
 1 file changed, 2 insertions(+)
33afe3
33afe3
diff --git a/daemons/fenced/fenced_history.c b/daemons/fenced/fenced_history.c
33afe3
index 5cacf36ca8..3ebf016e67 100644
33afe3
--- a/daemons/fenced/fenced_history.c
33afe3
+++ b/daemons/fenced/fenced_history.c
33afe3
@@ -257,6 +257,7 @@ stonith_xml_history_to_list(xmlNode *history)
33afe3
         op->completed_nsec = completed_nsec;
33afe3
         crm_element_value_int(xml_op, F_STONITH_STATE, &state);
33afe3
         op->state = (enum op_state) state;
33afe3
+        stonith__xe_get_result(xml_op, &op->result);
33afe3
 
33afe3
         g_hash_table_replace(rv, id, op);
33afe3
         CRM_LOG_ASSERT(g_hash_table_lookup(rv, id) != NULL);
33afe3
@@ -355,6 +356,7 @@ stonith_local_history_diff_and_merge(GHashTable *remote_history,
33afe3
                 crm_xml_add_ll(entry, F_STONITH_DATE, op->completed);
33afe3
                 crm_xml_add_ll(entry, F_STONITH_DATE_NSEC, op->completed_nsec);
33afe3
                 crm_xml_add_int(entry, F_STONITH_STATE, op->state);
33afe3
+                stonith__xe_set_result(entry, &op->result);
33afe3
             }
33afe3
     }
33afe3
 
33afe3
-- 
33afe3
2.27.0
33afe3
33afe3
33afe3
From afc5292036e212bcfc7475893e0b326b2a69ac58 Mon Sep 17 00:00:00 2001
33afe3
From: Ken Gaillot <kgaillot@redhat.com>
33afe3
Date: Wed, 22 Dec 2021 17:17:21 -0600
33afe3
Subject: [PATCH 09/15] API: libstonithd: add exit_reason member to
33afe3
 stonith_history_t
33afe3
33afe3
not yet used, but will be
33afe3
---
33afe3
 include/crm/stonith-ng.h | 3 ++-
33afe3
 lib/fencing/st_client.c  | 3 ++-
33afe3
 2 files changed, 4 insertions(+), 2 deletions(-)
33afe3
33afe3
diff --git a/include/crm/stonith-ng.h b/include/crm/stonith-ng.h
33afe3
index 3fe9cf54f8..2c79bfa579 100644
33afe3
--- a/include/crm/stonith-ng.h
33afe3
+++ b/include/crm/stonith-ng.h
33afe3
@@ -1,5 +1,5 @@
33afe3
 /*
33afe3
- * Copyright 2004-2021 the Pacemaker project contributors
33afe3
+ * Copyright 2004-2022 the Pacemaker project contributors
33afe3
  *
33afe3
  * The version control history for this file may have further details.
33afe3
  *
33afe3
@@ -111,6 +111,7 @@ typedef struct stonith_history_s {
33afe3
     time_t completed;
33afe3
     struct stonith_history_s *next;
33afe3
     long completed_nsec;
33afe3
+    char *exit_reason;
33afe3
 } stonith_history_t;
33afe3
 
33afe3
 typedef struct stonith_s stonith_t;
33afe3
diff --git a/lib/fencing/st_client.c b/lib/fencing/st_client.c
33afe3
index 718739b321..57a2e03361 100644
33afe3
--- a/lib/fencing/st_client.c
33afe3
+++ b/lib/fencing/st_client.c
33afe3
@@ -1,5 +1,5 @@
33afe3
 /*
33afe3
- * Copyright 2004-2021 the Pacemaker project contributors
33afe3
+ * Copyright 2004-2022 the Pacemaker project contributors
33afe3
  *
33afe3
  * The version control history for this file may have further details.
33afe3
  *
33afe3
@@ -735,6 +735,7 @@ void stonith_history_free(stonith_history_t *history)
33afe3
         free(hp->origin);
33afe3
         free(hp->delegate);
33afe3
         free(hp->client);
33afe3
+        free(hp->exit_reason);
33afe3
     }
33afe3
 }
33afe3
 
33afe3
-- 
33afe3
2.27.0
33afe3
33afe3
33afe3
From 1b9e2896322849002a5c0a3a34c9375ea32571d6 Mon Sep 17 00:00:00 2001
33afe3
From: Ken Gaillot <kgaillot@redhat.com>
33afe3
Date: Thu, 6 Jan 2022 18:04:15 -0600
33afe3
Subject: [PATCH 10/15] Feature: fencing: return exit reason with fencing
33afe3
 history
33afe3
33afe3
libstonithd's stonith_t:cmds->history() method now parses exit reasons from the
33afe3
fencer reply, and returns them in the stonith_history_t results.
33afe3
---
33afe3
 lib/fencing/st_client.c | 6 ++++++
33afe3
 1 file changed, 6 insertions(+)
33afe3
33afe3
diff --git a/lib/fencing/st_client.c b/lib/fencing/st_client.c
33afe3
index 57a2e03361..d229b34805 100644
33afe3
--- a/lib/fencing/st_client.c
33afe3
+++ b/lib/fencing/st_client.c
33afe3
@@ -698,6 +698,7 @@ stonith_api_history(stonith_t * stonith, int call_options, const char *node,
33afe3
             stonith_history_t *kvp;
33afe3
             long long completed;
33afe3
             long long completed_nsec = 0L;
33afe3
+            pcmk__action_result_t result = PCMK__UNKNOWN_RESULT;
33afe3
 
33afe3
             kvp = calloc(1, sizeof(stonith_history_t));
33afe3
             kvp->target = crm_element_value_copy(op, F_STONITH_TARGET);
33afe3
@@ -711,6 +712,11 @@ stonith_api_history(stonith_t * stonith, int call_options, const char *node,
33afe3
             kvp->completed_nsec = completed_nsec;
33afe3
             crm_element_value_int(op, F_STONITH_STATE, &kvp->state);
33afe3
 
33afe3
+            stonith__xe_get_result(op, &result);
33afe3
+            kvp->exit_reason = result.exit_reason;
33afe3
+            result.exit_reason = NULL;
33afe3
+            pcmk__reset_result(&result);
33afe3
+
33afe3
             if (last) {
33afe3
                 last->next = kvp;
33afe3
             } else {
33afe3
-- 
33afe3
2.27.0
33afe3
33afe3
33afe3
From ba4e77242e9be4ebeb2843b444ee4afad43c29f3 Mon Sep 17 00:00:00 2001
33afe3
From: Ken Gaillot <kgaillot@redhat.com>
33afe3
Date: Fri, 7 Jan 2022 09:44:39 -0600
33afe3
Subject: [PATCH 11/15] Feature: fencing: display exit reasons with failed
33afe3
 fencing events
33afe3
33afe3
... when available
33afe3
---
33afe3
 lib/fencing/st_output.c | 20 ++++++++++++++++----
33afe3
 tools/crm_mon_curses.c  |  9 +++++++--
33afe3
 2 files changed, 23 insertions(+), 6 deletions(-)
33afe3
33afe3
diff --git a/lib/fencing/st_output.c b/lib/fencing/st_output.c
33afe3
index e484278867..18924d795d 100644
33afe3
--- a/lib/fencing/st_output.c
33afe3
+++ b/lib/fencing/st_output.c
33afe3
@@ -1,5 +1,5 @@
33afe3
 /*
33afe3
- * Copyright 2019-2021 the Pacemaker project contributors
33afe3
+ * Copyright 2019-2022 the Pacemaker project contributors
33afe3
  *
33afe3
  * The version control history for this file may have further details.
33afe3
  *
33afe3
@@ -11,6 +11,7 @@
33afe3
 #include <stdarg.h>
33afe3
 
33afe3
 #include <crm/stonith-ng.h>
33afe3
+#include <crm/msg_xml.h>
33afe3
 #include <crm/common/iso8601.h>
33afe3
 #include <crm/common/util.h>
33afe3
 #include <crm/common/xml.h>
33afe3
@@ -263,8 +264,12 @@ stonith_event_html(pcmk__output_t *out, va_list args) {
33afe3
             char *failed_s = time_t_string(event->completed);
33afe3
 
33afe3
             out->list_item(out, "failed-stonith-event",
33afe3
-                           "%s of %s failed : delegate=%s, client=%s, origin=%s, %s='%s' %s",
33afe3
+                           "%s of %s failed%s%s%s: "
33afe3
+                           "delegate=%s, client=%s, origin=%s, %s='%s' %s",
33afe3
                            stonith_action_str(event->action), event->target,
33afe3
+                           (event->exit_reason == NULL)? "" : " (",
33afe3
+                           (event->exit_reason == NULL)? "" : event->exit_reason,
33afe3
+                           (event->exit_reason == NULL)? "" : ")",
33afe3
                            event->delegate ? event->delegate : "",
33afe3
                            event->client, event->origin,
33afe3
                            full_history ? "completed" : "last-failed",
33afe3
@@ -296,8 +301,13 @@ stonith_event_text(pcmk__output_t *out, va_list args) {
33afe3
 
33afe3
     switch (event->state) {
33afe3
         case st_failed:
33afe3
-            pcmk__indented_printf(out, "%s of %s failed: delegate=%s, client=%s, origin=%s, %s='%s' %s\n",
33afe3
+            pcmk__indented_printf(out,
33afe3
+                                  "%s of %s failed%s%s%s: "
33afe3
+                                  "delegate=%s, client=%s, origin=%s, %s='%s' %s\n",
33afe3
                                   stonith_action_str(event->action), event->target,
33afe3
+                                  (event->exit_reason == NULL)? "" : " (",
33afe3
+                                  (event->exit_reason == NULL)? "" : event->exit_reason,
33afe3
+                                  (event->exit_reason == NULL)? "" : ")",
33afe3
                                   event->delegate ? event->delegate : "",
33afe3
                                   event->client, event->origin,
33afe3
                                   full_history ? "completed" : "last-failed", buf,
33afe3
@@ -341,7 +351,9 @@ stonith_event_xml(pcmk__output_t *out, va_list args) {
33afe3
 
33afe3
     switch (event->state) {
33afe3
         case st_failed:
33afe3
-            crm_xml_add(node, "status", "failed");
33afe3
+            pcmk__xe_set_props(node, "status", "failed",
33afe3
+                               XML_LRM_ATTR_EXIT_REASON, event->exit_reason,
33afe3
+                               NULL);
33afe3
             break;
33afe3
 
33afe3
         case st_done:
33afe3
diff --git a/tools/crm_mon_curses.c b/tools/crm_mon_curses.c
33afe3
index bae3710c44..73c8516a8c 100644
33afe3
--- a/tools/crm_mon_curses.c
33afe3
+++ b/tools/crm_mon_curses.c
33afe3
@@ -1,5 +1,5 @@
33afe3
 /*
33afe3
- * Copyright 2019-2021 the Pacemaker project contributors
33afe3
+ * Copyright 2019-2022 the Pacemaker project contributors
33afe3
  *
33afe3
  * The version control history for this file may have further details.
33afe3
  *
33afe3
@@ -463,8 +463,13 @@ stonith_event_console(pcmk__output_t *out, va_list args) {
33afe3
 
33afe3
     switch (event->state) {
33afe3
         case st_failed:
33afe3
-            curses_indented_printf(out, "%s of %s failed: delegate=%s, client=%s, origin=%s, %s='%s'%s\n",
33afe3
+            curses_indented_printf(out,
33afe3
+                                   "%s of %s failed%s%s%s: "
33afe3
+                                   "delegate=%s, client=%s, origin=%s, %s='%s' %s\n",
33afe3
                                    stonith_action_str(event->action), event->target,
33afe3
+                                   (event->exit_reason == NULL)? "" : " (",
33afe3
+                                   (event->exit_reason == NULL)? "" : event->exit_reason,
33afe3
+                                   (event->exit_reason == NULL)? "" : ")",
33afe3
                                    event->delegate ? event->delegate : "",
33afe3
                                    event->client, event->origin,
33afe3
                                    full_history ? "completed" : "last-failed", buf,
33afe3
-- 
33afe3
2.27.0
33afe3
33afe3
33afe3
From 8105fb4a3a786780fdf85b3d0308eaf6df1ea434 Mon Sep 17 00:00:00 2001
33afe3
From: Ken Gaillot <kgaillot@redhat.com>
33afe3
Date: Fri, 7 Jan 2022 09:45:22 -0600
33afe3
Subject: [PATCH 12/15] Low: schemas: copy fence-event API schema in
33afe3
 preparation for changes
33afe3
33afe3
---
33afe3
 include/crm/common/output_internal.h |  2 +-
33afe3
 xml/api/fence-event-2.15.rng         | 33 ++++++++++++++++++++++++++++
33afe3
 2 files changed, 34 insertions(+), 1 deletion(-)
33afe3
 create mode 100644 xml/api/fence-event-2.15.rng
33afe3
33afe3
diff --git a/include/crm/common/output_internal.h b/include/crm/common/output_internal.h
33afe3
index 479f0e4b43..8c5dcee17c 100644
33afe3
--- a/include/crm/common/output_internal.h
33afe3
+++ b/include/crm/common/output_internal.h
33afe3
@@ -27,7 +27,7 @@ extern "C" {
33afe3
 #  include <glib.h>
33afe3
 #  include <crm/common/results.h>
33afe3
 
33afe3
-#  define PCMK__API_VERSION "2.14"
33afe3
+#  define PCMK__API_VERSION "2.15"
33afe3
 
33afe3
 #if defined(PCMK__WITH_ATTRIBUTE_OUTPUT_ARGS)
33afe3
 #  define PCMK__OUTPUT_ARGS(ARGS...) __attribute__((output_args(ARGS)))
33afe3
diff --git a/xml/api/fence-event-2.15.rng b/xml/api/fence-event-2.15.rng
33afe3
new file mode 100644
33afe3
index 0000000000..e54687cd25
33afe3
--- /dev/null
33afe3
+++ b/xml/api/fence-event-2.15.rng
33afe3
@@ -0,0 +1,33 @@
33afe3
+
33afe3
+
33afe3
+         datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
33afe3
+
33afe3
+    <start>
33afe3
+        <ref name="fencing-history-event"/>
33afe3
+    </start>
33afe3
+
33afe3
+    <define name="fencing-history-event">
33afe3
+        <element name="fence_event">
33afe3
+            <attribute name="status">
33afe3
+                <choice>
33afe3
+                    <value>failed</value>
33afe3
+                    <value>success</value>
33afe3
+                    <value>pending</value>
33afe3
+                </choice>
33afe3
+            </attribute>
33afe3
+            <optional>
33afe3
+                <attribute name="extended-status"> <text /> </attribute>
33afe3
+            </optional>
33afe3
+            <optional>
33afe3
+                <attribute name="delegate"> <text /> </attribute>
33afe3
+            </optional>
33afe3
+            <attribute name="action"> <text /> </attribute>
33afe3
+            <attribute name="target"> <text /> </attribute>
33afe3
+            <attribute name="client"> <text /> </attribute>
33afe3
+            <attribute name="origin"> <text /> </attribute>
33afe3
+            <optional>
33afe3
+                <attribute name="completed"> <text /> </attribute>
33afe3
+            </optional>
33afe3
+        </element>
33afe3
+    </define>
33afe3
+</grammar>
33afe3
-- 
33afe3
2.27.0
33afe3
33afe3
33afe3
From 46dd9b74d2ee8f7ab70a0c7fe3a998954d4029e8 Mon Sep 17 00:00:00 2001
33afe3
From: Ken Gaillot <kgaillot@redhat.com>
33afe3
Date: Fri, 7 Jan 2022 09:47:16 -0600
33afe3
Subject: [PATCH 13/15] Low: schemas: update fence-event API schema for recent
33afe3
 change
33afe3
33afe3
---
33afe3
 xml/api/fence-event-2.15.rng | 3 +++
33afe3
 1 file changed, 3 insertions(+)
33afe3
33afe3
diff --git a/xml/api/fence-event-2.15.rng b/xml/api/fence-event-2.15.rng
33afe3
index e54687cd25..8e000cafa5 100644
33afe3
--- a/xml/api/fence-event-2.15.rng
33afe3
+++ b/xml/api/fence-event-2.15.rng
33afe3
@@ -18,6 +18,9 @@
33afe3
             <optional>
33afe3
                 <attribute name="extended-status"> <text /> </attribute>
33afe3
             </optional>
33afe3
+            <optional>
33afe3
+                <attribute name="exit-reason"> <text /> </attribute>
33afe3
+            </optional>
33afe3
             <optional>
33afe3
                 <attribute name="delegate"> <text /> </attribute>
33afe3
             </optional>
33afe3
-- 
33afe3
2.27.0
33afe3
33afe3
33afe3
From 350e71772f67f28af6b67f864cbabc481730035c Mon Sep 17 00:00:00 2001
33afe3
From: Ken Gaillot <kgaillot@redhat.com>
33afe3
Date: Fri, 7 Jan 2022 11:32:09 -0600
33afe3
Subject: [PATCH 14/15] Build: libstonithd: bump shared library version
33afe3
33afe3
... for stonith_history_t change since 2.1.2.
33afe3
33afe3
The struct should only ever be returned by the library as a pointer, so the
33afe3
changes can be considered backward-compatible. Normally we wouldn't bump shared
33afe3
library versions mid-cycle, but this will simplify expected backports of this
33afe3
change.
33afe3
---
33afe3
 lib/fencing/Makefile.am | 4 ++--
33afe3
 1 file changed, 2 insertions(+), 2 deletions(-)
33afe3
33afe3
diff --git a/lib/fencing/Makefile.am b/lib/fencing/Makefile.am
33afe3
index 1ffa3e051b..a10ddb88ec 100644
33afe3
--- a/lib/fencing/Makefile.am
33afe3
+++ b/lib/fencing/Makefile.am
33afe3
@@ -2,7 +2,7 @@
33afe3
 # Original Author: Sun Jiang Dong <sunjd@cn.ibm.com>
33afe3
 # Copyright 2004 International Business Machines
33afe3
 #
33afe3
-# with later changes copyright 2004-2021 the Pacemaker project contributors.
33afe3
+# with later changes copyright 2004-2022 the Pacemaker project contributors.
33afe3
 # The version control history for this file may have further details.
33afe3
 #
33afe3
 # This source code is licensed under the GNU General Public License version 2
33afe3
@@ -14,7 +14,7 @@ noinst_HEADERS		= fencing_private.h
33afe3
 
33afe3
 lib_LTLIBRARIES		= libstonithd.la
33afe3
 
33afe3
-libstonithd_la_LDFLAGS	= -version-info 33:0:7
33afe3
+libstonithd_la_LDFLAGS	= -version-info 34:0:8
33afe3
 
33afe3
 libstonithd_la_CFLAGS	= $(CFLAGS_HARDENED_LIB)
33afe3
 libstonithd_la_LDFLAGS	+= $(LDFLAGS_HARDENED_LIB)
33afe3
-- 
33afe3
2.27.0
33afe3
33afe3
33afe3
From 63ea88620a62ff0759560a02bb5e284ebdd03eb6 Mon Sep 17 00:00:00 2001
33afe3
From: Ken Gaillot <kgaillot@redhat.com>
33afe3
Date: Wed, 19 Jan 2022 16:53:45 -0600
33afe3
Subject: [PATCH 15/15] Low: fencer: reset op result before grabbing new one
33afe3
33afe3
just in case
33afe3
---
33afe3
 daemons/fenced/fenced_remote.c | 1 +
33afe3
 1 file changed, 1 insertion(+)
33afe3
33afe3
diff --git a/daemons/fenced/fenced_remote.c b/daemons/fenced/fenced_remote.c
33afe3
index 7fb7695fba..dc4649e0fc 100644
33afe3
--- a/daemons/fenced/fenced_remote.c
33afe3
+++ b/daemons/fenced/fenced_remote.c
33afe3
@@ -2219,6 +2219,7 @@ fenced_process_fencing_reply(xmlNode *msg)
33afe3
         return;
33afe3
     }
33afe3
 
33afe3
+    pcmk__reset_result(&op->result);
33afe3
     op->result = result; // The operation takes ownership of the result
33afe3
 
33afe3
     if (op->devices && device && !pcmk__str_eq(op->devices->data, device, pcmk__str_casei)) {
33afe3
-- 
33afe3
2.27.0
33afe3