Blame SOURCES/004-check-level.patch

2a3635
From 3905e7eac11298fc20efd567a773666f948edf61 Mon Sep 17 00:00:00 2001
2a3635
From: Chris Lumens <clumens@redhat.com>
2a3635
Date: Mon, 3 May 2021 11:19:04 -0400
2a3635
Subject: [PATCH 1/2] Feature: tools: Add OCF_CHECK_LEVEL to crm_resource
2a3635
 environment.
2a3635
2a3635
If --validate= or --force-check= are given with a level, pass that along
2a3635
as OCF_CHECK_LEVEL.  This argument is optional, and if no value is given
2a3635
then the environment variable will not be set and whatever's the default
2a3635
on the resource agent will be used.
2a3635
2a3635
See: rhbz#1955792.
2a3635
---
2a3635
 tools/crm_resource.c         | 29 +++++++++++++++++++++--------
2a3635
 tools/crm_resource.h         |  4 ++--
2a3635
 tools/crm_resource_runtime.c | 13 ++++++++++---
2a3635
 3 files changed, 33 insertions(+), 13 deletions(-)
2a3635
2a3635
diff --git a/tools/crm_resource.c b/tools/crm_resource.c
2a3635
index 45db2b2..6ca96f8 100644
2a3635
--- a/tools/crm_resource.c
2a3635
+++ b/tools/crm_resource.c
2a3635
@@ -100,6 +100,7 @@ struct {
2a3635
     int timeout_ms;               // Parsed from --timeout value
2a3635
     char *agent_spec;             // Standard and/or provider and/or agent
2a3635
     gchar *xml_file;              // Value of (deprecated) --xml-file
2a3635
+    int check_level;              // Optional value of --validate or --force-check
2a3635
 
2a3635
     // Resource configuration specified via command-line arguments
2a3635
     gboolean cmdline_config;      // Resource configuration was via arguments
2a3635
@@ -113,6 +114,7 @@ struct {
2a3635
     GHashTable *override_params;  // Resource parameter values that override config
2a3635
 } options = {
2a3635
     .attr_set_type = XML_TAG_ATTR_SETS,
2a3635
+    .check_level = -1,
2a3635
     .cib_options = cib_sync_call,
2a3635
     .require_cib = TRUE,
2a3635
     .require_dataset = TRUE,
2a3635
@@ -402,14 +404,15 @@ static GOptionEntry query_entries[] = {
2a3635
 };
2a3635
 
2a3635
 static GOptionEntry command_entries[] = {
2a3635
-    { "validate", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
2a3635
+    { "validate", 0, G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK,
2a3635
       validate_or_force_cb,
2a3635
       "Validate resource configuration by calling agent's validate-all\n"
2a3635
       INDENT "action. The configuration may be specified either by giving an\n"
2a3635
       INDENT "existing resource name with -r, or by specifying --class,\n"
2a3635
       INDENT "--agent, and --provider arguments, along with any number of\n"
2a3635
-      INDENT "--option arguments.",
2a3635
-      NULL },
2a3635
+      INDENT "--option arguments. An optional LEVEL argument can be given\n"
2a3635
+      INDENT "to control the level of checking performed.",
2a3635
+      "LEVEL" },
2a3635
     { "cleanup", 'C', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, cleanup_refresh_cb,
2a3635
       "If resource has any past failures, clear its history and fail\n"
2a3635
       INDENT "count. Optionally filtered by --resource, --node, --operation\n"
2a3635
@@ -546,11 +549,12 @@ static GOptionEntry advanced_entries[] = {
2a3635
       INDENT "the cluster believes the resource is a clone instance already\n"
2a3635
       INDENT "running on the local node.",
2a3635
       NULL },
2a3635
-    { "force-check", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
2a3635
+    { "force-check", 0, G_OPTION_FLAG_OPTIONAL_ARG, G_OPTION_ARG_CALLBACK,
2a3635
       validate_or_force_cb,
2a3635
       "(Advanced) Bypass the cluster and check the state of a resource on\n"
2a3635
-      INDENT "the local node",
2a3635
-      NULL },
2a3635
+      INDENT "the local node. An optional LEVEL argument can be given\n"
2a3635
+      INDENT "to control the level of checking performed.",
2a3635
+      "LEVEL" },
2a3635
 
2a3635
     { NULL }
2a3635
 };
2a3635
@@ -910,6 +914,15 @@ validate_or_force_cb(const gchar *option_name, const gchar *optarg,
2a3635
     if (options.override_params == NULL) {
2a3635
         options.override_params = pcmk__strkey_table(free, free);
2a3635
     }
2a3635
+
2a3635
+    if (optarg != NULL) {
2a3635
+        if (pcmk__scan_min_int(optarg, &options.check_level, 0) != pcmk_rc_ok) {
2a3635
+            g_set_error(error, G_OPTION_ERROR, CRM_EX_INVALID_PARAM,
2a3635
+                        "Invalid check level setting: %s", optarg);
2a3635
+            return FALSE;
2a3635
+        }
2a3635
+    }
2a3635
+
2a3635
     return TRUE;
2a3635
 }
2a3635
 
2a3635
@@ -1826,12 +1839,12 @@ main(int argc, char **argv)
2a3635
                     options.v_class, options.v_provider, options.v_agent,
2a3635
                     "validate-all", options.cmdline_params,
2a3635
                     options.override_params, options.timeout_ms,
2a3635
-                    args->verbosity, options.force);
2a3635
+                    args->verbosity, options.force, options.check_level);
2a3635
             } else {
2a3635
                 exit_code = cli_resource_execute(rsc, options.rsc_id,
2a3635
                     options.operation, options.override_params,
2a3635
                     options.timeout_ms, cib_conn, data_set,
2a3635
-                    args->verbosity, options.force);
2a3635
+                    args->verbosity, options.force, options.check_level);
2a3635
             }
2a3635
             goto done;
2a3635
 
2a3635
diff --git a/tools/crm_resource.h b/tools/crm_resource.h
2a3635
index 3560377..5ab10d6 100644
2a3635
--- a/tools/crm_resource.h
2a3635
+++ b/tools/crm_resource.h
2a3635
@@ -88,11 +88,11 @@ crm_exit_t cli_resource_execute_from_params(pcmk__output_t *out, const char *rsc
2a3635
                                             const char *rsc_type, const char *rsc_action,
2a3635
                                             GHashTable *params, GHashTable *override_hash,
2a3635
                                             int timeout_ms, int resource_verbose,
2a3635
-                                            gboolean force);
2a3635
+                                            gboolean force, int check_level);
2a3635
 crm_exit_t cli_resource_execute(pe_resource_t *rsc, const char *requested_name,
2a3635
                                 const char *rsc_action, GHashTable *override_hash,
2a3635
                                 int timeout_ms, cib_t *cib, pe_working_set_t *data_set,
2a3635
-                                int resource_verbose, gboolean force);
2a3635
+                                int resource_verbose, gboolean force, int check_level);
2a3635
 
2a3635
 int cli_resource_update_attribute(pe_resource_t *rsc, const char *requested_name,
2a3635
                                   const char *attr_set, const char *attr_set_type,
2a3635
diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c
2a3635
index fe0ec98..bde83b6 100644
2a3635
--- a/tools/crm_resource_runtime.c
2a3635
+++ b/tools/crm_resource_runtime.c
2a3635
@@ -1679,7 +1679,8 @@ cli_resource_execute_from_params(pcmk__output_t *out, const char *rsc_name,
2a3635
                                  const char *rsc_class, const char *rsc_prov,
2a3635
                                  const char *rsc_type, const char *action,
2a3635
                                  GHashTable *params, GHashTable *override_hash,
2a3635
-                                 int timeout_ms, int resource_verbose, gboolean force)
2a3635
+                                 int timeout_ms, int resource_verbose, gboolean force,
2a3635
+                                 int check_level)
2a3635
 {
2a3635
     GHashTable *params_copy = NULL;
2a3635
     crm_exit_t exit_code = CRM_EX_OK;
2a3635
@@ -1703,6 +1704,12 @@ cli_resource_execute_from_params(pcmk__output_t *out, const char *rsc_name,
2a3635
     /* add crm_feature_set env needed by some resource agents */
2a3635
     g_hash_table_insert(params, strdup(XML_ATTR_CRM_VERSION), strdup(CRM_FEATURE_SET));
2a3635
 
2a3635
+    if (check_level >= 0) {
2a3635
+        char *level = crm_strdup_printf("%d", check_level);
2a3635
+        setenv("OCF_CHECK_LEVEL", level, 1);
2a3635
+        free(level);
2a3635
+    }
2a3635
+
2a3635
     /* resources_action_create frees the params hash table it's passed, but we
2a3635
      * may need to reuse it in a second call to resources_action_create.  Thus
2a3635
      * we'll make a copy here so that gets freed and the original remains for
2a3635
@@ -1790,7 +1797,7 @@ crm_exit_t
2a3635
 cli_resource_execute(pe_resource_t *rsc, const char *requested_name,
2a3635
                      const char *rsc_action, GHashTable *override_hash,
2a3635
                      int timeout_ms, cib_t * cib, pe_working_set_t *data_set,
2a3635
-                     int resource_verbose, gboolean force)
2a3635
+                     int resource_verbose, gboolean force, int check_level)
2a3635
 {
2a3635
     pcmk__output_t *out = data_set->priv;
2a3635
     crm_exit_t exit_code = CRM_EX_OK;
2a3635
@@ -1856,7 +1863,7 @@ cli_resource_execute(pe_resource_t *rsc, const char *requested_name,
2a3635
 
2a3635
     exit_code = cli_resource_execute_from_params(out, rid, rclass, rprov, rtype, action,
2a3635
                                                  params, override_hash, timeout_ms,
2a3635
-                                                 resource_verbose, force);
2a3635
+                                                 resource_verbose, force, check_level);
2a3635
     return exit_code;
2a3635
 }
2a3635
 
2a3635
-- 
2a3635
1.8.3.1
2a3635
2a3635
2a3635
From d13ba4bd6defe0dd81fdf8ab39ae5b889513c0c0 Mon Sep 17 00:00:00 2001
2a3635
From: Chris Lumens <clumens@redhat.com>
2a3635
Date: Thu, 20 May 2021 10:59:23 -0400
2a3635
Subject: [PATCH 2/2] Fix: include: Bump feature set to 3.10.2.
2a3635
2a3635
This is for the OCF_CHECK_LEVEL environment variable.
2a3635
2a3635
See: rhbz#1955792.
2a3635
---
2a3635
 include/crm/crm.h | 2 +-
2a3635
 1 file changed, 1 insertion(+), 1 deletion(-)
2a3635
2a3635
diff --git a/include/crm/crm.h b/include/crm/crm.h
2a3635
index 92a98fa..ee52c36 100644
2a3635
--- a/include/crm/crm.h
2a3635
+++ b/include/crm/crm.h
2a3635
@@ -66,7 +66,7 @@ extern "C" {
2a3635
  * >=3.0.13: Fail counts include operation name and interval
2a3635
  * >=3.2.0:  DC supports PCMK_LRM_OP_INVALID and PCMK_LRM_OP_NOT_CONNECTED
2a3635
  */
2a3635
-#  define CRM_FEATURE_SET		"3.10.1"
2a3635
+#  define CRM_FEATURE_SET		"3.10.2"
2a3635
 
2a3635
 /* Pacemaker's CPG protocols use fixed-width binary fields for the sender and
2a3635
  * recipient of a CPG message. This imposes an arbitrary limit on cluster node
2a3635
-- 
2a3635
1.8.3.1
2a3635