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