Blame SOURCES/009-crm_resource.patch

109fe2
From 30eb9a980db152f6c803a35d3b261a563ad4ee75 Mon Sep 17 00:00:00 2001
109fe2
From: Ken Gaillot <kgaillot@redhat.com>
109fe2
Date: Wed, 24 Jan 2018 10:51:34 -0600
109fe2
Subject: [PATCH 1/2] Low: tools: crm_resource --refresh should ignore
109fe2
 --operation and --interval
109fe2
109fe2
It already did when a resource was not specified.
109fe2
Also update help text to clarify cleanup vs refresh.
109fe2
---
109fe2
 tools/crm_resource.c | 26 ++++++++++++++++-----------
109fe2
 1 file changed, 16 insertions(+), 10 deletions(-)
109fe2
109fe2
diff --git a/tools/crm_resource.c b/tools/crm_resource.c
109fe2
index 3fbc6e1..d007668 100644
109fe2
--- a/tools/crm_resource.c
109fe2
+++ b/tools/crm_resource.c
109fe2
@@ -212,14 +212,16 @@ static struct crm_option long_options[] = {
109fe2
     },
109fe2
     {
109fe2
         "cleanup", no_argument, NULL, 'C',
109fe2
-        "\t\tDelete failed operations from a resource's history allowing its current state to be rechecked.\n"
109fe2
+        "\t\tIf resource has any past failures, clear its history and fail count.\n"
109fe2
         "\t\t\t\tOptionally filtered by --resource, --node, --operation, and --interval (otherwise all).\n"
109fe2
+        "\t\t\t\t--operation and --interval apply to fail counts, but entire history is always cleared,\n"
109fe2
+        "\t\t\t\tto allow current state to be rechecked.\n"
109fe2
     },
109fe2
     {
109fe2
         "refresh", no_argument, NULL, 'R',
109fe2
         "\t\tDelete resource's history (including failures) so its current state is rechecked.\n"
109fe2
-        "\t\t\t\tOptionally filtered by --resource, --node, --operation, and --interval (otherwise all).\n"
109fe2
-        "\t\t\t\tUnless --force is specified, resource's group or clone (if any) will also be cleaned"
109fe2
+        "\t\t\t\tOptionally filtered by --resource and --node (otherwise all).\n"
109fe2
+        "\t\t\t\tUnless --force is specified, resource's group or clone (if any) will also be refreshed."
109fe2
     },
109fe2
     {
109fe2
         "set-parameter", required_argument, NULL, 'p',
109fe2
@@ -438,7 +440,6 @@ main(int argc, char **argv)
109fe2
     bool require_resource = TRUE; /* whether command requires that resource be specified */
109fe2
     bool require_dataset = TRUE;  /* whether command requires populated dataset instance */
109fe2
     bool require_crmd = FALSE;    /* whether command requires connection to CRMd */
109fe2
-    bool just_errors = TRUE;      /* whether cleanup command deletes all history or just errors */
109fe2
 
109fe2
     int rc = pcmk_ok;
109fe2
     int is_ocf_rc = 0;
109fe2
@@ -630,8 +631,7 @@ main(int argc, char **argv)
109fe2
                 if (cib_file == NULL) {
109fe2
                     require_crmd = TRUE;
109fe2
                 }
109fe2
-                just_errors = FALSE;
109fe2
-                rsc_cmd = 'C';
109fe2
+                rsc_cmd = 'R';
109fe2
                 find_flags = pe_find_renamed|pe_find_anon;
109fe2
                 break;
109fe2
 
109fe2
@@ -641,7 +641,6 @@ main(int argc, char **argv)
109fe2
                 if (cib_file == NULL) {
109fe2
                     require_crmd = TRUE;
109fe2
                 }
109fe2
-                just_errors = TRUE;
109fe2
                 rsc_cmd = 'C';
109fe2
                 find_flags = pe_find_renamed|pe_find_anon;
109fe2
                 break;
109fe2
@@ -1092,7 +1091,14 @@ main(int argc, char **argv)
109fe2
         rc = cli_resource_delete_attribute(rsc, rsc_id, prop_set, prop_id,
109fe2
                                            prop_name, cib_conn, &data_set);
109fe2
 
109fe2
-    } else if ((rsc_cmd == 'C') && rsc) {
109fe2
+    } else if (((rsc_cmd == 'C') || (rsc_cmd == 'R')) && rsc) {
109fe2
+        bool just_errors = TRUE;
109fe2
+
109fe2
+        if (rsc_cmd == 'R') {
109fe2
+            just_errors = FALSE;
109fe2
+            operation = NULL;
109fe2
+            interval = 0;
109fe2
+        }
109fe2
         if (do_force == FALSE) {
109fe2
             rsc = uber_parent(rsc);
109fe2
         }
109fe2
@@ -1113,14 +1119,14 @@ main(int argc, char **argv)
109fe2
             start_mainloop();
109fe2
         }
109fe2
 
109fe2
-    } else if (rsc_cmd == 'C' && just_errors) {
109fe2
+    } else if (rsc_cmd == 'C') {
109fe2
         rc = cli_cleanup_all(crmd_channel, host_uname, operation, interval,
109fe2
                              &data_set);
109fe2
         if (rc == pcmk_ok) {
109fe2
             start_mainloop();
109fe2
         }
109fe2
 
109fe2
-    } else if (rsc_cmd == 'C') {
109fe2
+    } else if (rsc_cmd == 'R') {
109fe2
 #if HAVE_ATOMIC_ATTRD
109fe2
         const char *router_node = host_uname;
109fe2
         xmlNode *msg_data = NULL;
109fe2
-- 
109fe2
1.8.3.1