Blame SOURCES/015-feature-set.patch

c563b9
From 12b30c920dd15287a7b295475ce1cc4a6cb1f43f Mon Sep 17 00:00:00 2001
c563b9
From: Chris Lumens <clumens@redhat.com>
c563b9
Date: Tue, 8 Dec 2020 15:48:38 -0500
c563b9
Subject: [PATCH] Fix: scheduler: Don't output a resource header with no list.
c563b9
c563b9
If there's no resources to print, don't output just the header with
c563b9
nothing under it.  This potentially comes up if there are only inactive
c563b9
resources, but inactive_resources is FALSE.
c563b9
---
c563b9
 lib/pengine/pe_output.c | 48 ++++++++++++++++++++++++++++++++++++------------
c563b9
 1 file changed, 36 insertions(+), 12 deletions(-)
c563b9
c563b9
diff --git a/lib/pengine/pe_output.c b/lib/pengine/pe_output.c
c563b9
index 5562eb6..f1a6b43 100644
c563b9
--- a/lib/pengine/pe_output.c
c563b9
+++ b/lib/pengine/pe_output.c
c563b9
@@ -1761,6 +1761,21 @@ resource_history_xml(pcmk__output_t *out, va_list args) {
c563b9
     return pcmk_rc_ok;
c563b9
 }
c563b9
 
c563b9
+static void
c563b9
+print_resource_header(pcmk__output_t *out, gboolean group_by_node,
c563b9
+                      gboolean inactive_resources)
c563b9
+{
c563b9
+    if (group_by_node) {
c563b9
+        /* Active resources have already been printed by node */
c563b9
+        out->begin_list(out, NULL, NULL, "Inactive Resources");
c563b9
+    } else if (inactive_resources) {
c563b9
+        out->begin_list(out, NULL, NULL, "Full List of Resources");
c563b9
+    } else {
c563b9
+        out->begin_list(out, NULL, NULL, "Active Resources");
c563b9
+    }
c563b9
+}
c563b9
+
c563b9
+
c563b9
 PCMK__OUTPUT_ARGS("resource-list", "pe_working_set_t *", "unsigned int", "gboolean",
c563b9
                   "gboolean", "gboolean", "gboolean", "GList *", "GList *", "gboolean")
c563b9
 static int
c563b9
@@ -1778,6 +1793,7 @@ resource_list(pcmk__output_t *out, va_list args)
c563b9
 
c563b9
     GList *rsc_iter;
c563b9
     int rc = pcmk_rc_no_output;
c563b9
+    bool printed_header = false;
c563b9
 
c563b9
     /* If we already showed active resources by node, and
c563b9
      * we're not showing inactive resources, we have nothing to do
c563b9
@@ -1786,22 +1802,15 @@ resource_list(pcmk__output_t *out, va_list args)
c563b9
         return rc;
c563b9
     }
c563b9
 
c563b9
-    PCMK__OUTPUT_SPACER_IF(out, print_spacer);
c563b9
-
c563b9
-    if (group_by_node) {
c563b9
-        /* Active resources have already been printed by node */
c563b9
-        out->begin_list(out, NULL, NULL, "Inactive Resources");
c563b9
-    } else if (inactive_resources) {
c563b9
-        out->begin_list(out, NULL, NULL, "Full List of Resources");
c563b9
-    } else {
c563b9
-        out->begin_list(out, NULL, NULL, "Active Resources");
c563b9
-    }
c563b9
-
c563b9
     /* If we haven't already printed resources grouped by node,
c563b9
      * and brief output was requested, print resource summary */
c563b9
     if (brief_output && !group_by_node) {
c563b9
         GList *rscs = pe__filter_rsc_list(data_set->resources, only_rsc);
c563b9
 
c563b9
+        PCMK__OUTPUT_SPACER_IF(out, print_spacer);
c563b9
+        print_resource_header(out, group_by_node, inactive_resources);
c563b9
+        printed_header = true;
c563b9
+
c563b9
         pe__rscs_brief_output(out, rscs, print_opts, inactive_resources);
c563b9
         g_list_free(rscs);
c563b9
     }
c563b9
@@ -1839,6 +1848,12 @@ resource_list(pcmk__output_t *out, va_list args)
c563b9
             continue;
c563b9
         }
c563b9
 
c563b9
+        if (!printed_header) {
c563b9
+            PCMK__OUTPUT_SPACER_IF(out, print_spacer);
c563b9
+            print_resource_header(out, group_by_node, inactive_resources);
c563b9
+            printed_header = true;
c563b9
+        }
c563b9
+
c563b9
         /* Print this resource */
c563b9
         x = out->message(out, crm_map_element_name(rsc->xml), print_opts, rsc,
c563b9
                          only_node, only_rsc);
c563b9
@@ -1848,6 +1863,12 @@ resource_list(pcmk__output_t *out, va_list args)
c563b9
     }
c563b9
 
c563b9
     if (print_summary && rc != pcmk_rc_ok) {
c563b9
+        if (!printed_header) {
c563b9
+            PCMK__OUTPUT_SPACER_IF(out, print_spacer);
c563b9
+            print_resource_header(out, group_by_node, inactive_resources);
c563b9
+            printed_header = true;
c563b9
+        }
c563b9
+
c563b9
         if (group_by_node) {
c563b9
             out->list_item(out, NULL, "No inactive resources");
c563b9
         } else if (inactive_resources) {
c563b9
@@ -1857,7 +1878,10 @@ resource_list(pcmk__output_t *out, va_list args)
c563b9
         }
c563b9
     }
c563b9
 
c563b9
-    out->end_list(out);
c563b9
+    if (printed_header) {
c563b9
+        out->end_list(out);
c563b9
+    }
c563b9
+
c563b9
     return rc;
c563b9
 }
c563b9
 
c563b9
-- 
c563b9
1.8.3.1
c563b9