Blame SOURCES/038-feature-set.patch

a216ed
From 98589d8e1ef9b57d806702b9968ff7e5560e9c8f Mon Sep 17 00:00:00 2001
a216ed
From: Chris Lumens <clumens@redhat.com>
a216ed
Date: Fri, 12 Feb 2021 11:51:16 -0500
a216ed
Subject: [PATCH] Low: Fix a problem with crm_resource exit code handling.
a216ed
a216ed
If no output is produced but an error message is printed (like, when an
a216ed
inactive resource is provided on the command line), don't print the
a216ed
error message for the pcmk_rc_no_output error code.  It's weird to see
a216ed
output and a message about no output at the same time.
a216ed
a216ed
Similarly, don't print an "Error: OK" message when usage is printed.
a216ed
---
a216ed
 tools/crm_resource.c | 13 +++++++++----
a216ed
 1 file changed, 9 insertions(+), 4 deletions(-)
a216ed
a216ed
diff --git a/tools/crm_resource.c b/tools/crm_resource.c
a216ed
index 7d2f0f6..29b0a04 100644
a216ed
--- a/tools/crm_resource.c
a216ed
+++ b/tools/crm_resource.c
a216ed
@@ -1534,9 +1534,9 @@ main(int argc, char **argv)
a216ed
 
a216ed
     rc = pcmk__output_new(&out, args->output_ty, args->output_dest, argv);
a216ed
     if (rc != pcmk_rc_ok) {
a216ed
-        fprintf(stderr, "Error creating output format %s: %s\n",
a216ed
-                args->output_ty, pcmk_rc_str(rc));
a216ed
         exit_code = CRM_EX_ERROR;
a216ed
+        g_set_error(&error, PCMK__EXITC_ERROR, exit_code, "Error creating output format %s: %s",
a216ed
+                    args->output_ty, pcmk_rc_str(rc));
a216ed
         goto done;
a216ed
     }
a216ed
 
a216ed
@@ -2039,7 +2039,12 @@ main(int argc, char **argv)
a216ed
      */
a216ed
 
a216ed
 done:
a216ed
-    if (rc != pcmk_rc_ok) {
a216ed
+    /* Don't do any of this for pcmk_rc_no_output (doesn't make sense to show an
a216ed
+     * error message for no output) or for CRM_EX_USAGE (we don't want to show
a216ed
+     * an "error: OK" message from pcmk_rc_str).
a216ed
+     */
a216ed
+    if ((rc != pcmk_rc_ok && rc != pcmk_rc_no_output) ||
a216ed
+        (exit_code != CRM_EX_OK && exit_code != CRM_EX_USAGE)) {
a216ed
         if (rc == pcmk_rc_no_quorum) {
a216ed
             g_prefix_error(&error, "To ignore quorum, use the force option.\n");
a216ed
         }
a216ed
@@ -2054,10 +2059,10 @@ done:
a216ed
             g_set_error(&error, PCMK__RC_ERROR, rc,
a216ed
                         "Error performing operation: %s", pcmk_rc_str(rc));
a216ed
         }
a216ed
+    }
a216ed
 
a216ed
-        if (exit_code == CRM_EX_OK) {
a216ed
-            exit_code = pcmk_rc2exitc(rc);
a216ed
-        }
a216ed
+    if (exit_code == CRM_EX_OK) {
a216ed
+        exit_code = pcmk_rc2exitc(rc);
a216ed
     }
a216ed
 
a216ed
     g_free(options.host_uname);
a216ed
-- 
a216ed
1.8.3.1
a216ed