pacemaker/009-crm_resource-messages.patch

230 lines
9.5 KiB
Diff
Raw Normal View History

From 5bcab230ad4c647ca78b18bd4a66e30a4bb4417f Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Wed, 16 Jun 2021 11:19:03 +0200
Subject: [PATCH 1/2] Feature: crm_resource: report not supported for --force-*
w/systemd, upstart, nagios and bundled resources
---
tools/crm_resource.c | 21 ++++----------
tools/crm_resource_runtime.c | 67 +++++++++++++++++++++++++++++---------------
2 files changed, 51 insertions(+), 37 deletions(-)
diff --git a/tools/crm_resource.c b/tools/crm_resource.c
index 4abdd03..fa7902c 100644
--- a/tools/crm_resource.c
+++ b/tools/crm_resource.c
@@ -660,21 +660,12 @@ attr_set_type_cb(const gchar *option_name, const gchar *optarg, gpointer data, G
gboolean
class_cb(const gchar *option_name, const gchar *optarg, gpointer data, GError **error) {
- if (!(pcmk_get_ra_caps(optarg) & pcmk_ra_cap_params)) {
- if (!args->quiet) {
- g_set_error(error, G_OPTION_ERROR, CRM_EX_INVALID_PARAM,
- "Standard %s does not support parameters\n", optarg);
- }
- return FALSE;
-
- } else {
- if (options.v_class != NULL) {
- free(options.v_class);
- }
-
- options.v_class = strdup(optarg);
+ if (options.v_class != NULL) {
+ free(options.v_class);
}
+ options.v_class = strdup(optarg);
+
options.cmdline_config = TRUE;
options.require_resource = FALSE;
return TRUE;
@@ -1422,7 +1413,7 @@ validate_cmdline_config(void)
} else if (options.rsc_cmd != cmd_execute_agent) {
g_set_error(&error, PCMK__EXITC_ERROR, CRM_EX_USAGE,
"--class, --agent, and --provider can only be used with "
- "--validate");
+ "--validate and --force-*");
// Not all of --class, --agent, and --provider need to be given. Not all
// classes support the concept of a provider. Check that what we were given
@@ -1841,7 +1832,7 @@ main(int argc, char **argv)
if (options.cmdline_config) {
exit_code = cli_resource_execute_from_params(out, NULL,
options.v_class, options.v_provider, options.v_agent,
- "validate-all", options.cmdline_params,
+ options.operation, options.cmdline_params,
options.override_params, options.timeout_ms,
args->verbosity, options.force, options.check_level);
} else {
diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c
index fe42e60..59e6df5 100644
--- a/tools/crm_resource_runtime.c
+++ b/tools/crm_resource_runtime.c
@@ -1674,24 +1674,59 @@ wait_till_stable(pcmk__output_t *out, int timeout_ms, cib_t * cib)
return rc;
}
+static const char *
+get_action(const char *rsc_action) {
+ const char *action = NULL;
+
+ if (pcmk__str_eq(rsc_action, "validate", pcmk__str_casei)) {
+ action = "validate-all";
+
+ } else if (pcmk__str_eq(rsc_action, "force-check", pcmk__str_casei)) {
+ action = "monitor";
+
+ } else if (pcmk__strcase_any_of(rsc_action, "force-start", "force-stop",
+ "force-demote", "force-promote", NULL)) {
+ action = rsc_action+6;
+ } else {
+ action = rsc_action;
+ }
+
+ return action;
+}
+
crm_exit_t
cli_resource_execute_from_params(pcmk__output_t *out, const char *rsc_name,
const char *rsc_class, const char *rsc_prov,
- const char *rsc_type, const char *action,
+ const char *rsc_type, const char *rsc_action,
GHashTable *params, GHashTable *override_hash,
int timeout_ms, int resource_verbose, gboolean force,
int check_level)
{
+ const char *action = NULL;
GHashTable *params_copy = NULL;
crm_exit_t exit_code = CRM_EX_OK;
svc_action_t *op = NULL;
if (pcmk__str_eq(rsc_class, PCMK_RESOURCE_CLASS_STONITH, pcmk__str_casei)) {
out->err(out, "Sorry, the %s option doesn't support %s resources yet",
- action, rsc_class);
+ rsc_action, rsc_class);
+ crm_exit(CRM_EX_UNIMPLEMENT_FEATURE);
+ } else if (pcmk__strcase_any_of(rsc_class, PCMK_RESOURCE_CLASS_SYSTEMD,
+ PCMK_RESOURCE_CLASS_UPSTART, PCMK_RESOURCE_CLASS_NAGIOS, NULL)) {
+ out->err(out, "Sorry, the %s option doesn't support %s resources",
+ rsc_action, rsc_class);
+ crm_exit(CRM_EX_UNIMPLEMENT_FEATURE);
+ } else if (pcmk__str_eq(rsc_class, PCMK_RESOURCE_CLASS_SERVICE,
+ pcmk__str_casei) && !pcmk__str_eq(
+ resources_find_service_class(rsc_name), PCMK_RESOURCE_CLASS_LSB,
+ pcmk__str_casei)) {
+ out->err(out, "Sorry, the %s option doesn't support %s resources",
+ rsc_action, resources_find_service_class(rsc_name));
crm_exit(CRM_EX_UNIMPLEMENT_FEATURE);
}
+ action = get_action(rsc_action);
+
/* If no timeout was provided, grab the default. */
if (timeout_ms == 0) {
timeout_ms = crm_get_msec(CRM_DEFAULT_OP_TIMEOUT_S);
@@ -1766,7 +1801,7 @@ cli_resource_execute_from_params(pcmk__output_t *out, const char *rsc_name,
exit_code = op->rc;
out->message(out, "resource-agent-action", resource_verbose, rsc_class,
- rsc_prov, rsc_type, rsc_name, action, override_hash, op->rc,
+ rsc_prov, rsc_type, rsc_name, rsc_action, override_hash, op->rc,
op->status, op->stdout_data, op->stderr_data);
} else {
exit_code = op->rc == 0 ? CRM_EX_ERROR : op->rc;
@@ -1790,27 +1825,15 @@ cli_resource_execute(pe_resource_t *rsc, const char *requested_name,
const char *rtype = NULL;
const char *rprov = NULL;
const char *rclass = NULL;
- const char *action = NULL;
GHashTable *params = NULL;
- if (pcmk__str_eq(rsc_action, "validate", pcmk__str_casei)) {
- action = "validate-all";
-
- } else if (pcmk__str_eq(rsc_action, "force-check", pcmk__str_casei)) {
- action = "monitor";
-
- } else if (pcmk__str_eq(rsc_action, "force-stop", pcmk__str_casei)) {
- action = rsc_action+6;
-
- } else if (pcmk__strcase_any_of(rsc_action, "force-start", "force-demote",
+ if (pcmk__strcase_any_of(rsc_action, "force-start", "force-demote",
"force-promote", NULL)) {
- action = rsc_action+6;
-
if(pe_rsc_is_clone(rsc)) {
GList *nodes = cli_resource_search(rsc, requested_name, data_set);
if(nodes != NULL && force == FALSE) {
out->err(out, "It is not safe to %s %s here: the cluster claims it is already active",
- action, rsc->id);
+ rsc_action, rsc->id);
out->err(out, "Try setting target-role=Stopped first or specifying "
"the force option");
return CRM_EX_UNSAFE;
@@ -1818,9 +1841,6 @@ cli_resource_execute(pe_resource_t *rsc, const char *requested_name,
g_list_free_full(nodes, free);
}
-
- } else {
- action = rsc_action;
}
if(pe_rsc_is_clone(rsc)) {
@@ -1831,6 +1851,9 @@ cli_resource_execute(pe_resource_t *rsc, const char *requested_name,
if(rsc->variant == pe_group) {
out->err(out, "Sorry, the %s option doesn't support group resources", rsc_action);
return CRM_EX_UNIMPLEMENT_FEATURE;
+ } else if (rsc->variant == pe_container || pe_rsc_is_bundled(rsc)) {
+ out->err(out, "Sorry, the %s option doesn't support bundled resources", rsc_action);
+ return CRM_EX_UNIMPLEMENT_FEATURE;
}
rclass = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS);
@@ -1841,12 +1864,12 @@ cli_resource_execute(pe_resource_t *rsc, const char *requested_name,
data_set);
if (timeout_ms == 0) {
- timeout_ms = pe_get_configured_timeout(rsc, action, data_set);
+ timeout_ms = pe_get_configured_timeout(rsc, get_action(rsc_action), data_set);
}
rid = pe_rsc_is_anon_clone(rsc->parent)? requested_name : rsc->id;
- exit_code = cli_resource_execute_from_params(out, rid, rclass, rprov, rtype, action,
+ exit_code = cli_resource_execute_from_params(out, rid, rclass, rprov, rtype, rsc_action,
params, override_hash, timeout_ms,
resource_verbose, force, check_level);
return exit_code;
--
1.8.3.1
From 289cd231186755d99c1262eb9f968dc852409588 Mon Sep 17 00:00:00 2001
From: Oyvind Albrigtsen <oalbrigt@redhat.com>
Date: Fri, 16 Jul 2021 13:20:55 +0200
Subject: [PATCH 2/2] Refactor: crm_resource: remove duplicate Overriding
message that's handled elsewhere
---
tools/crm_resource_runtime.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c
index 59e6df5..ce037c5 100644
--- a/tools/crm_resource_runtime.c
+++ b/tools/crm_resource_runtime.c
@@ -1791,8 +1791,6 @@ cli_resource_execute_from_params(pcmk__output_t *out, const char *rsc_name,
g_hash_table_iter_init(&iter, override_hash);
while (g_hash_table_iter_next(&iter, (gpointer *) & name, (gpointer *) & value)) {
- out->info(out, "Overriding the cluster configuration for '%s' with '%s' = '%s'",
- rsc_name, name, value);
g_hash_table_replace(op->params, strdup(name), strdup(value));
}
}
--
1.8.3.1