Blame SOURCES/2.0-cleanup-behavior.patch

951ecb
From 612fcbb399cfaa558504eeaa6ab16064e9013238 Mon Sep 17 00:00:00 2001
951ecb
From: Ken Gaillot <kgaillot@redhat.com>
951ecb
Date: Tue, 7 Aug 2018 11:56:06 -0500
951ecb
Subject: [PATCH] Feature: tools: enable 2.0 behavior of crm_resource clean-up
951ecb
951ecb
---
413fc7
 tools/crm_resource.c | 49 +++++----------
413fc7
 1 file changed, 20 insertions(+), 29 deletions(-)
951ecb
951ecb
diff --git a/tools/crm_resource.c b/tools/crm_resource.c
413fc7
index 128d075..bbdba25 100644
951ecb
--- a/tools/crm_resource.c
951ecb
+++ b/tools/crm_resource.c
951ecb
@@ -212,8 +212,6 @@ static struct crm_option long_options[] = {
951ecb
     },
951ecb
     {
951ecb
         "cleanup", no_argument, NULL, 'C',
951ecb
-#if 0
951ecb
-        // new behavior disabled until 2.0.0
951ecb
         "\t\tIf resource has any past failures, clear its history and fail count.\n"
951ecb
         "\t\t\t\tOptionally filtered by --resource, --node, --operation, and --interval (otherwise all).\n"
951ecb
         "\t\t\t\t--operation and --interval apply to fail counts, but entire history is always cleared,\n"
951ecb
@@ -221,7 +219,6 @@ static struct crm_option long_options[] = {
951ecb
     },
951ecb
     {
951ecb
         "refresh", no_argument, NULL, 'R',
951ecb
-#endif
951ecb
         "\t\tDelete resource's history (including failures) so its current state is rechecked.\n"
951ecb
         "\t\t\t\tOptionally filtered by --resource and --node (otherwise all).\n"
951ecb
         "\t\t\t\tUnless --force is specified, resource's group or clone (if any) will also be refreshed."
951ecb
@@ -352,13 +349,11 @@ static struct crm_option long_options[] = {
951ecb
     },
951ecb
     {
951ecb
         "operation", required_argument, NULL, 'n',
951ecb
-        "\tOperation to clear instead of all (with -C -r)",
951ecb
-        pcmk_option_hidden // only used with 2.0 -C behavior
951ecb
+        "\tOperation to clear instead of all (with -C -r)"
951ecb
     },
951ecb
     {
951ecb
         "interval", required_argument, NULL, 'I',
951ecb
-        "\tInterval of operation to clear (default 0) (with -C -r -n)",
951ecb
-        pcmk_option_hidden // only used with 2.0 -C behavior
951ecb
+        "\tInterval of operation to clear (default 0) (with -C -r -n)"
951ecb
     },
951ecb
     {
951ecb
         "set-name", required_argument, NULL, 's',
951ecb
@@ -388,7 +383,6 @@ static struct crm_option long_options[] = {
951ecb
     {"un-migrate", no_argument, NULL, 'U', NULL, pcmk_option_hidden},
951ecb
     {"un-move", no_argument, NULL, 'U', NULL, pcmk_option_hidden},
951ecb
 
951ecb
-    {"refresh",    0, 0, 'R', NULL, pcmk_option_hidden}, // remove this line for 2.0.0
951ecb
     {"reprobe", no_argument, NULL, 'P', NULL, pcmk_option_hidden},
951ecb
 
951ecb
     {"-spacer-", 1, NULL, '-', "\nExamples:", pcmk_option_paragraph},
951ecb
@@ -630,15 +624,16 @@ main(int argc, char **argv)
951ecb
                 timeout_ms = crm_get_msec(optarg);
951ecb
                 break;
951ecb
 
951ecb
+            case 'P':
951ecb
+                flag = 'R';
951ecb
             case 'C':
951ecb
             case 'R':
951ecb
-            case 'P':
951ecb
                 crm_log_args(argc, argv);
951ecb
                 require_resource = FALSE;
951ecb
                 if (cib_file == NULL) {
951ecb
                     require_crmd = TRUE;
951ecb
                 }
951ecb
-                rsc_cmd = 'R'; // disable new behavior until 2.0
951ecb
+                rsc_cmd = flag;
951ecb
                 find_flags = pe_find_renamed|pe_find_anon;
951ecb
                 break;
951ecb
 
413fc7
@@ -1120,21 +1115,25 @@ main(int argc, char **argv)
413fc7
             start_mainloop();
413fc7
         }
413fc7
 
413fc7
-     } else if ((rsc_cmd == 'R') && rsc) {
413fc7
-         if (do_force == FALSE) {
413fc7
-             rsc = uber_parent(rsc);
413fc7
-         }
413fc7
-         crmd_replies_needed = 0;
413fc7
-
413fc7
-         crm_debug("Re-checking the state of %s (%s requested) on %s",
413fc7
-                   rsc->id, rsc_id, (host_uname? host_uname: "all nodes"));
413fc7
-         rc = cli_resource_delete(crmd_channel, host_uname, rsc,
413fc7
-                                  NULL, 0, FALSE, &data_set);
413fc7
-
413fc7
-         if ((rc == pcmk_ok) && !BE_QUIET) {
413fc7
-             // Show any reasons why resource might stay stopped
413fc7
-             cli_resource_check(cib_conn, rsc);
413fc7
-         }
413fc7
+    } else if ((rsc_cmd == 'R') && rsc) {
413fc7
+        if (do_force == FALSE) {
413fc7
+            rsc = uber_parent(rsc);
413fc7
+        }
413fc7
+        crmd_replies_needed = 0;
413fc7
+
413fc7
+        crm_debug("Re-checking the state of %s (%s requested) on %s",
413fc7
+                  rsc->id, rsc_id, (host_uname? host_uname: "all nodes"));
413fc7
+        rc = cli_resource_delete(crmd_channel, host_uname, rsc,
413fc7
+                                 NULL, 0, FALSE, &data_set);
413fc7
+
413fc7
+        if ((rc == pcmk_ok) && !BE_QUIET) {
413fc7
+            // Show any reasons why resource might stay stopped
413fc7
+            cli_resource_check(cib_conn, rsc);
413fc7
+        }
413fc7
+
413fc7
+        if (rc == pcmk_ok) {
413fc7
+            start_mainloop();
413fc7
+        }
413fc7
 
413fc7
     } else if (rsc_cmd == 'R') {
413fc7
 #if HAVE_ATOMIC_ATTRD
951ecb
-- 
951ecb
1.8.3.1
951ecb