Blame SOURCES/009-crm_resource-messages.patch

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