54df86
From 9853f4d05a376062d60f2e4c90938e587992237b Mon Sep 17 00:00:00 2001
54df86
From: Chris Lumens <clumens@redhat.com>
54df86
Date: Mon, 27 Jun 2022 12:06:24 -0400
54df86
Subject: [PATCH 1/2] Fix: tools: Don't output "(null)" in crm_attribute's
54df86
 quiet mode.
54df86
54df86
If the attribute queried for has no value, simply do not output
54df86
anything.
54df86
54df86
Regression in 2.1.3 introduced by 8c03553bbf
54df86
54df86
Fixes T502
54df86
See: rhbz#2099331
54df86
---
54df86
 tools/crm_attribute.c | 4 +++-
54df86
 1 file changed, 3 insertions(+), 1 deletion(-)
54df86
54df86
diff --git a/tools/crm_attribute.c b/tools/crm_attribute.c
54df86
index 0bd9dee81..b1463f906 100644
54df86
--- a/tools/crm_attribute.c
54df86
+++ b/tools/crm_attribute.c
54df86
@@ -56,7 +56,9 @@ attribute_text(pcmk__output_t *out, va_list args)
54df86
     char *host G_GNUC_UNUSED = va_arg(args, char *);
54df86
 
54df86
     if (out->quiet) {
54df86
-        pcmk__formatted_printf(out, "%s\n", value);
54df86
+        if (value != NULL) {
54df86
+            pcmk__formatted_printf(out, "%s\n", value);
54df86
+        }
54df86
     } else {
54df86
         out->info(out, "%s%s %s%s %s%s value=%s",
54df86
                   scope ? "scope=" : "", scope ? scope : "",
54df86
-- 
54df86
2.31.1
54df86
54df86
54df86
From 16d00a9b3ef27afd09f5c046ea1be50fc664ed84 Mon Sep 17 00:00:00 2001
54df86
From: Chris Lumens <clumens@redhat.com>
54df86
Date: Mon, 27 Jun 2022 12:18:06 -0400
54df86
Subject: [PATCH 2/2] Test: cts: Add a test for querying an attribute that does
54df86
 not exist.
54df86
54df86
---
54df86
 cts/cli/regression.tools.exp | 4 ++++
54df86
 cts/cts-cli.in               | 5 +++++
54df86
 2 files changed, 9 insertions(+)
54df86
54df86
diff --git a/cts/cli/regression.tools.exp b/cts/cli/regression.tools.exp
54df86
index 0d1cfa2ab..464472d42 100644
54df86
--- a/cts/cli/regression.tools.exp
54df86
+++ b/cts/cli/regression.tools.exp
54df86
@@ -24,6 +24,10 @@ A new shadow instance was created.  To begin using it paste the following into y
54df86
 </cib>
54df86
 =#=#=#= End test: Validate CIB - OK (0) =#=#=#=
54df86
 * Passed: cibadmin       - Validate CIB
54df86
+=#=#=#= Begin test: Query the value of an attribute that does not exist =#=#=#=
54df86
+crm_attribute: Error performing operation: No such device or address
54df86
+=#=#=#= End test: Query the value of an attribute that does not exist - No such object (105) =#=#=#=
54df86
+* Passed: crm_attribute  - Query the value of an attribute that does not exist
54df86
 =#=#=#= Begin test: Configure something before erasing =#=#=#=
54df86
 =#=#=#= Current cib after: Configure something before erasing =#=#=#=
54df86
 <cib epoch="2" num_updates="0" admin_epoch="0">
54df86
diff --git a/cts/cts-cli.in b/cts/cts-cli.in
54df86
index 8565c485a..b895d36ec 100755
54df86
--- a/cts/cts-cli.in
54df86
+++ b/cts/cts-cli.in
54df86
@@ -511,6 +511,10 @@ function test_tools() {
54df86
     cmd="cibadmin -Q"
54df86
     test_assert $CRM_EX_OK
54df86
 
54df86
+    desc="Query the value of an attribute that does not exist"
54df86
+    cmd="crm_attribute -n ABCD --query --quiet"
54df86
+    test_assert $CRM_EX_NOSUCH 0
54df86
+
54df86
     desc="Configure something before erasing"
54df86
     cmd="crm_attribute -n cluster-delay -v 60s"
54df86
     test_assert $CRM_EX_OK
54df86
@@ -1980,6 +1984,7 @@ for t in $tests; do
54df86
         -e 's/ end=\"[0-9][-+: 0-9]*Z*\"/ end=\"\"/' \
54df86
         -e 's/ start=\"[0-9][-+: 0-9]*Z*\"/ start=\"\"/' \
54df86
         -e 's/^Error checking rule: Device not configured/Error checking rule: No such device or address/' \
54df86
+        -e 's/Error performing operation: Device not configured/Error performing operation: No such device or address/' \
54df86
         -e 's/\(Injecting attribute last-failure-ping#monitor_10000=\)[0-9]*/\1/' \
54df86
         -e 's/^lt-//' \
54df86
         -e 's/ocf::/ocf:/' \
54df86
-- 
54df86
2.31.1
54df86