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