From aa584a7cf34a0e740f6d8249a7adabf358d66e41 Mon Sep 17 00:00:00 2001 From: Jehan-Guillaume de Rorthais Date: Fri, 10 Mar 2017 14:31:33 +0100 Subject: [PATCH 1/2] Low: tools: crm_resource should set OCF_RESKEY_crm_feature_set Some resource agent relies on this environment variable during their validate-all action to check the CRM feature set compatibility. Without this environment variable, most of the --force-ACTION are failing. At least the Linbit/drbd and PAF (pgsqlms) agents are using it. --- tools/crm_resource_runtime.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c index ee7523f..e6a186a 100644 --- a/tools/crm_resource_runtime.c +++ b/tools/crm_resource_runtime.c @@ -1508,6 +1508,10 @@ cli_resource_execute(const char *rsc_id, const char *rsc_action, GHashTable *ove } params = generate_resource_params(rsc, data_set); + + /* add crm_feature_set env needed by some resource agents */ + g_hash_table_insert(params, strdup(XML_ATTR_CRM_VERSION), strdup(CRM_FEATURE_SET)); + op = resources_action_create(rsc->id, rclass, rprov, rtype, action, 0, -1, params, 0); if(do_trace) { -- 1.8.3.1 From 02a737976d34d41da65fa25a64e5708a1269cef7 Mon Sep 17 00:00:00 2001 From: Jehan-Guillaume de Rorthais Date: Fri, 10 Mar 2017 14:50:43 +0100 Subject: [PATCH 2/2] Feature: tools: Add "--validate" command to crm_resource This command calls the validate-all action from the resource agent. It allows admins to check their resource is setup correctly in a shadow environment before pushing their setup to the cluster. --- tools/crm_resource.c | 6 ++++-- tools/crm_resource_runtime.c | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/crm_resource.c b/tools/crm_resource.c index 45dfd4a..e8cd80e 100644 --- a/tools/crm_resource.c +++ b/tools/crm_resource.c @@ -128,6 +128,7 @@ static struct crm_option long_options[] = { {"constraints",0, 0, 'a', "\tDisplay the (co)location constraints that apply to a resource"}, {"-spacer-", 1, 0, '-', "\nCommands:"}, + {"validate", 0, 0, 0, "\t\tCall the validate-all action of the local given resource"}, {"cleanup", 0, 0, 'C', "\t\tDelete resource's history and re-check its current state. " "Optional: --resource (if not specified, all resources), " @@ -303,7 +304,8 @@ main(int argc, char **argv) require_dataset = FALSE; } else if ( - safe_str_eq("restart", longname) + safe_str_eq("validate", longname) + || safe_str_eq("restart", longname) || safe_str_eq("force-demote", longname) || safe_str_eq("force-stop", longname) || safe_str_eq("force-start", longname) @@ -687,7 +689,7 @@ main(int argc, char **argv) } else if (rsc_cmd == 0 && rsc_long_cmd && safe_str_eq(rsc_long_cmd, "wait")) { rc = wait_till_stable(timeout_ms, cib_conn); - } else if (rsc_cmd == 0 && rsc_long_cmd) { /* force-(stop|start|check) */ + } else if (rsc_cmd == 0 && rsc_long_cmd) { /* validate or force-(stop|start|check) */ rc = cli_resource_execute(rsc_id, rsc_long_cmd, override_params, cib_conn, &data_set); } else if (rsc_cmd == 'A' || rsc_cmd == 'a') { diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c index e6a186a..ca38aea 100644 --- a/tools/crm_resource_runtime.c +++ b/tools/crm_resource_runtime.c @@ -1467,7 +1467,10 @@ cli_resource_execute(const char *rsc_id, const char *rsc_action, GHashTable *ove return -ENXIO; } - if (safe_str_eq(rsc_action, "force-check")) { + if (safe_str_eq(rsc_action, "validate")) { + action = "validate-all"; + + } else if (safe_str_eq(rsc_action, "force-check")) { action = "monitor"; } else if (safe_str_eq(rsc_action, "force-stop")) { -- 1.8.3.1