54df86
From d00a6abde7e6a41f8bc6085c875cb8072aff499b Mon Sep 17 00:00:00 2001
54df86
From: Chris Lumens <clumens@redhat.com>
54df86
Date: Thu, 30 Jun 2022 09:25:05 -0400
54df86
Subject: [PATCH 1/2] Fix: libstonithd: Add the "Agent not found..." message to
54df86
 formatted output.
54df86
54df86
---
54df86
 lib/fencing/st_client.c | 11 ++++++++---
54df86
 1 file changed, 8 insertions(+), 3 deletions(-)
54df86
54df86
diff --git a/lib/fencing/st_client.c b/lib/fencing/st_client.c
54df86
index 137642af7..971bbe9a5 100644
54df86
--- a/lib/fencing/st_client.c
54df86
+++ b/lib/fencing/st_client.c
54df86
@@ -1763,9 +1763,14 @@ stonith_api_validate(stonith_t *st, int call_options, const char *rsc_id,
54df86
         default:
54df86
             rc = -EINVAL;
54df86
             errno = EINVAL;
54df86
-            crm_perror(LOG_ERR,
54df86
-                       "Agent %s not found or does not support validation",
54df86
-                       agent);
54df86
+
54df86
+            if (error_output) {
54df86
+                *error_output = crm_strdup_printf("Agent %s not found or does not support validation",
54df86
+                                                  agent);
54df86
+            } else {
54df86
+                crm_err("Agent %s not found or does not support validation", agent);
54df86
+            }
54df86
+
54df86
             break;
54df86
     }
54df86
     g_hash_table_destroy(params_table);
54df86
-- 
54df86
2.31.1
54df86
54df86
54df86
From f3a5fc961c30556b975011773e4cebf323bec38e Mon Sep 17 00:00:00 2001
54df86
From: Chris Lumens <clumens@redhat.com>
54df86
Date: Fri, 1 Jul 2022 10:38:45 -0400
54df86
Subject: [PATCH 2/2] Refactor: libstonithd: Split apart error conditions when
54df86
 validating.
54df86
54df86
The "not found" and "can't validate" cases were previously jumbled
54df86
together.  Now, return ENOENT if the agent is not found and EOPNOTSUPP
54df86
if it can't validate.  The only caller appears to be handling both cases
54df86
correctly already, so no changes are needed there.
54df86
---
54df86
 lib/fencing/st_client.c | 21 +++++++++++++++++----
54df86
 1 file changed, 17 insertions(+), 4 deletions(-)
54df86
54df86
diff --git a/lib/fencing/st_client.c b/lib/fencing/st_client.c
54df86
index 971bbe9a5..192334812 100644
54df86
--- a/lib/fencing/st_client.c
54df86
+++ b/lib/fencing/st_client.c
54df86
@@ -1760,19 +1760,32 @@ stonith_api_validate(stonith_t *st, int call_options, const char *rsc_id,
54df86
             break;
54df86
 #endif
54df86
 
54df86
+        case st_namespace_invalid:
54df86
+            errno = ENOENT;
54df86
+            rc = -errno;
54df86
+
54df86
+            if (error_output) {
54df86
+                *error_output = crm_strdup_printf("Agent %s not found", agent);
54df86
+            } else {
54df86
+                crm_err("Agent %s not found", agent);
54df86
+            }
54df86
+
54df86
+            break;
54df86
+
54df86
         default:
54df86
-            rc = -EINVAL;
54df86
-            errno = EINVAL;
54df86
+            errno = EOPNOTSUPP;
54df86
+            rc = -errno;
54df86
 
54df86
             if (error_output) {
54df86
-                *error_output = crm_strdup_printf("Agent %s not found or does not support validation",
54df86
+                *error_output = crm_strdup_printf("Agent %s does not support validation",
54df86
                                                   agent);
54df86
             } else {
54df86
-                crm_err("Agent %s not found or does not support validation", agent);
54df86
+                crm_err("Agent %s does not support validation", agent);
54df86
             }
54df86
 
54df86
             break;
54df86
     }
54df86
+
54df86
     g_hash_table_destroy(params_table);
54df86
     return rc;
54df86
 }
54df86
-- 
54df86
2.31.1
54df86