Blame SOURCES/007-stonith_admin.patch

54df86
From d6294dd28b6d95ad3844824996717f9959d97ac6 Mon Sep 17 00:00:00 2001
54df86
From: Reid Wahl <nrwahl@protonmail.com>
54df86
Date: Thu, 30 Jun 2022 11:07:32 -0700
54df86
Subject: [PATCH 1/2] Fix: Use correct boolean in stonith__validate_agent_xml
54df86
54df86
This fixes a regression introduced by 91a2b2e that flips the boolean
54df86
values for "valid" in the XML output.
54df86
54df86
Resolves: RHBZ#2102292 (partial)
54df86
54df86
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
54df86
---
54df86
 lib/fencing/st_output.c | 7 +++----
54df86
 1 file changed, 3 insertions(+), 4 deletions(-)
54df86
54df86
diff --git a/lib/fencing/st_output.c b/lib/fencing/st_output.c
54df86
index e0ff848c2..eb10ad0c5 100644
54df86
--- a/lib/fencing/st_output.c
54df86
+++ b/lib/fencing/st_output.c
54df86
@@ -528,10 +528,9 @@ validate_agent_xml(pcmk__output_t *out, va_list args) {
54df86
     char *error_output = va_arg(args, char *);
54df86
     int rc = va_arg(args, int);
54df86
 
54df86
-    xmlNodePtr node = pcmk__output_create_xml_node(out, "validate",
54df86
-                                                   "agent", agent,
54df86
-                                                   "valid", pcmk__btoa(rc),
54df86
-                                                   NULL);
54df86
+    xmlNodePtr node = pcmk__output_create_xml_node(
54df86
+        out, "validate", "agent", agent, "valid", pcmk__btoa(rc == pcmk_ok),
54df86
+        NULL);
54df86
 
54df86
     if (device != NULL) {
54df86
         crm_xml_add(node, "device", device);
54df86
-- 
54df86
2.31.1
54df86
54df86
54df86
From 81e83683e69b4f147f40f5353f8e68032758a104 Mon Sep 17 00:00:00 2001
54df86
From: Reid Wahl <nrwahl@protonmail.com>
54df86
Date: Wed, 29 Jun 2022 18:15:33 -0700
54df86
Subject: [PATCH 2/2] Fix: Use failed action result in rhcs_validate and
54df86
 _get_metadata
54df86
54df86
If an action failed but has a non-NULL result, get the rc and other
54df86
attributes from that result.
54df86
54df86
This fixes a regression introduced by b441925, in which failure XML
54df86
output now contains a CRM_EX_CONNECTED rc instead of the correct one and
54df86
does not contain stdout/stderr. That commit caused
54df86
services__execute_file() to return a proper rc instead of TRUE. A
54df86
non-pcmk_ok bubbled up the call chain causing
54df86
internal_stonith_action_execute() to return -ECONNABORTED. Then
54df86
rhcs_validate() and _get_metadata() would use this rc instead of the one
54df86
attached to the result.
54df86
54df86
Resolves: RHBZ#2102292
54df86
54df86
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
54df86
---
54df86
 lib/fencing/st_rhcs.c | 10 +++++-----
54df86
 1 file changed, 5 insertions(+), 5 deletions(-)
54df86
54df86
diff --git a/lib/fencing/st_rhcs.c b/lib/fencing/st_rhcs.c
54df86
index 39485013e..029c97eea 100644
54df86
--- a/lib/fencing/st_rhcs.c
54df86
+++ b/lib/fencing/st_rhcs.c
54df86
@@ -130,16 +130,15 @@ stonith__rhcs_get_metadata(const char *agent, int timeout, xmlNode **metadata)
54df86
     stonith_action_t *action = stonith_action_create(agent, "metadata", NULL, 0,
54df86
                                                      5, NULL, NULL, NULL);
54df86
     int rc = stonith__execute(action);
54df86
+    result = stonith__action_result(action);
54df86
 
54df86
-    if (rc < 0) {
54df86
+    if (rc < 0 && result == NULL) {
54df86
         crm_warn("Could not execute metadata action for %s: %s "
54df86
                  CRM_XS " rc=%d", agent, pcmk_strerror(rc), rc);
54df86
         stonith__destroy_action(action);
54df86
         return rc;
54df86
     }
54df86
 
54df86
-    result = stonith__action_result(action);
54df86
-
54df86
     if (result->execution_status != PCMK_EXEC_DONE) {
54df86
         crm_warn("Could not execute metadata action for %s: %s",
54df86
                  agent, pcmk_exec_status_str(result->execution_status));
54df86
@@ -262,6 +261,7 @@ stonith__rhcs_validate(stonith_t *st, int call_options, const char *target,
54df86
     int remaining_timeout = timeout;
54df86
     xmlNode *metadata = NULL;
54df86
     stonith_action_t *action = NULL;
54df86
+    pcmk__action_result_t *result = NULL;
54df86
 
54df86
     if (host_arg == NULL) {
54df86
         time_t start_time = time(NULL);
54df86
@@ -298,9 +298,9 @@ stonith__rhcs_validate(stonith_t *st, int call_options, const char *target,
54df86
                                    NULL, host_arg);
54df86
 
54df86
     rc = stonith__execute(action);
54df86
-    if (rc == pcmk_ok) {
54df86
-        pcmk__action_result_t *result = stonith__action_result(action);
54df86
+    result = stonith__action_result(action);
54df86
 
54df86
+    if (result != NULL) {
54df86
         rc = pcmk_rc2legacy(stonith__result2rc(result));
54df86
 
54df86
         // Take ownership of output so stonith__destroy_action() doesn't free it
54df86
-- 
54df86
2.31.1
54df86