|
|
951ecb |
From 039b778b07f256dd564171430c5427dfb9489a58 Mon Sep 17 00:00:00 2001
|
|
|
951ecb |
From: "Gao,Yan" <ygao@suse.com>
|
|
|
951ecb |
Date: Fri, 8 Dec 2017 14:47:40 +0100
|
|
|
951ecb |
Subject: [PATCH 1/8] Refactor: tools: crm_resource - Functionize cleaning up
|
|
|
951ecb |
resource failures
|
|
|
951ecb |
|
|
|
951ecb |
---
|
|
|
951ecb |
tools/crm_resource.c | 26 ++------------------------
|
|
|
951ecb |
tools/crm_resource.h | 3 +++
|
|
|
951ecb |
tools/crm_resource_runtime.c | 36 ++++++++++++++++++++++++++++++++++++
|
|
|
951ecb |
3 files changed, 41 insertions(+), 24 deletions(-)
|
|
|
951ecb |
|
|
|
951ecb |
diff --git a/tools/crm_resource.c b/tools/crm_resource.c
|
|
|
951ecb |
index 0557892..331adf6 100644
|
|
|
951ecb |
--- a/tools/crm_resource.c
|
|
|
951ecb |
+++ b/tools/crm_resource.c
|
|
|
951ecb |
@@ -1103,31 +1103,9 @@ main(int argc, char **argv)
|
|
|
951ecb |
|
|
|
951ecb |
} else if (rsc_cmd == 'C' && just_errors) {
|
|
|
951ecb |
crmd_replies_needed = 0;
|
|
|
951ecb |
- for (xmlNode *xml_op = __xml_first_child(data_set.failed); xml_op != NULL;
|
|
|
951ecb |
- xml_op = __xml_next(xml_op)) {
|
|
|
951ecb |
-
|
|
|
951ecb |
- const char *node = crm_element_value(xml_op, XML_ATTR_UNAME);
|
|
|
951ecb |
- const char *task = crm_element_value(xml_op, XML_LRM_ATTR_TASK);
|
|
|
951ecb |
- const char *task_interval = crm_element_value(xml_op, XML_LRM_ATTR_INTERVAL);
|
|
|
951ecb |
- const char *resource_name = crm_element_value(xml_op, XML_LRM_ATTR_RSCID);
|
|
|
951ecb |
-
|
|
|
951ecb |
- if(resource_name == NULL) {
|
|
|
951ecb |
- continue;
|
|
|
951ecb |
- } else if(host_uname && safe_str_neq(host_uname, node)) {
|
|
|
951ecb |
- continue;
|
|
|
951ecb |
- } else if(rsc_id && safe_str_neq(rsc_id, resource_name)) {
|
|
|
951ecb |
- continue;
|
|
|
951ecb |
- } else if(operation && safe_str_neq(operation, task)) {
|
|
|
951ecb |
- continue;
|
|
|
951ecb |
- } else if(interval && safe_str_neq(interval, task_interval)) {
|
|
|
951ecb |
- continue;
|
|
|
951ecb |
- }
|
|
|
951ecb |
|
|
|
951ecb |
- crm_debug("Erasing %s failure for %s (%s detected) on %s",
|
|
|
951ecb |
- task, rsc->id, resource_name, node);
|
|
|
951ecb |
- rc = cli_resource_delete(crmd_channel, node, rsc, task,
|
|
|
951ecb |
- task_interval, &data_set);
|
|
|
951ecb |
- }
|
|
|
951ecb |
+ rc = cli_resource_delete_failures(crmd_channel, host_uname, rsc, operation,
|
|
|
951ecb |
+ interval, &data_set);
|
|
|
951ecb |
|
|
|
951ecb |
if(rsc && (rc == pcmk_ok) && (BE_QUIET == FALSE)) {
|
|
|
951ecb |
/* Now check XML_RSC_ATTR_TARGET_ROLE and XML_RSC_ATTR_MANAGED */
|
|
|
951ecb |
diff --git a/tools/crm_resource.h b/tools/crm_resource.h
|
|
|
951ecb |
index 0b8dd2a..e28c9ef 100644
|
|
|
951ecb |
--- a/tools/crm_resource.h
|
|
|
951ecb |
+++ b/tools/crm_resource.h
|
|
|
951ecb |
@@ -76,6 +76,9 @@ int cli_resource_search(resource_t *rsc, const char *requested_name,
|
|
|
951ecb |
int cli_resource_delete(crm_ipc_t *crmd_channel, const char *host_uname,
|
|
|
951ecb |
resource_t *rsc, const char *operation,
|
|
|
951ecb |
const char *interval, pe_working_set_t *data_set);
|
|
|
951ecb |
+int cli_resource_delete_failures(crm_ipc_t *crmd_channel, const char *host_uname,
|
|
|
951ecb |
+ resource_t *rsc, const char *operation,
|
|
|
951ecb |
+ const char *interval, pe_working_set_t *data_set);
|
|
|
951ecb |
int cli_resource_restart(resource_t * rsc, const char *host, int timeout_ms, cib_t * cib);
|
|
|
951ecb |
int cli_resource_move(resource_t *rsc, const char *rsc_id,
|
|
|
951ecb |
const char *host_name, cib_t *cib,
|
|
|
951ecb |
diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c
|
|
|
951ecb |
index 5004935..9aa7b7e 100644
|
|
|
951ecb |
--- a/tools/crm_resource_runtime.c
|
|
|
951ecb |
+++ b/tools/crm_resource_runtime.c
|
|
|
951ecb |
@@ -681,6 +681,42 @@ cli_resource_delete(crm_ipc_t *crmd_channel, const char *host_uname,
|
|
|
951ecb |
return rc;
|
|
|
951ecb |
}
|
|
|
951ecb |
|
|
|
951ecb |
+int
|
|
|
951ecb |
+cli_resource_delete_failures(crm_ipc_t *crmd_channel, const char *host_uname,
|
|
|
951ecb |
+ resource_t *rsc, const char *operation,
|
|
|
951ecb |
+ const char *interval, pe_working_set_t *data_set)
|
|
|
951ecb |
+{
|
|
|
951ecb |
+ int rc = pcmk_ok;
|
|
|
951ecb |
+
|
|
|
951ecb |
+ for (xmlNode *xml_op = __xml_first_child(data_set->failed); xml_op != NULL;
|
|
|
951ecb |
+ xml_op = __xml_next(xml_op)) {
|
|
|
951ecb |
+
|
|
|
951ecb |
+ const char *node = crm_element_value(xml_op, XML_ATTR_UNAME);
|
|
|
951ecb |
+ const char *task = crm_element_value(xml_op, XML_LRM_ATTR_TASK);
|
|
|
951ecb |
+ const char *task_interval = crm_element_value(xml_op, XML_LRM_ATTR_INTERVAL);
|
|
|
951ecb |
+ const char *resource_name = crm_element_value(xml_op, XML_LRM_ATTR_RSCID);
|
|
|
951ecb |
+
|
|
|
951ecb |
+ if(resource_name == NULL) {
|
|
|
951ecb |
+ continue;
|
|
|
951ecb |
+ } else if(host_uname && safe_str_neq(host_uname, node)) {
|
|
|
951ecb |
+ continue;
|
|
|
951ecb |
+ } else if(rsc->id && safe_str_neq(rsc->id, resource_name)) {
|
|
|
951ecb |
+ continue;
|
|
|
951ecb |
+ } else if(operation && safe_str_neq(operation, task)) {
|
|
|
951ecb |
+ continue;
|
|
|
951ecb |
+ } else if(interval && safe_str_neq(interval, task_interval)) {
|
|
|
951ecb |
+ continue;
|
|
|
951ecb |
+ }
|
|
|
951ecb |
+
|
|
|
951ecb |
+ crm_debug("Erasing %s failure for %s (%s detected) on %s",
|
|
|
951ecb |
+ task, rsc->id, resource_name, node);
|
|
|
951ecb |
+ rc = cli_resource_delete(crmd_channel, node, rsc, task,
|
|
|
951ecb |
+ task_interval, data_set);
|
|
|
951ecb |
+ }
|
|
|
951ecb |
+
|
|
|
951ecb |
+ return rc;
|
|
|
951ecb |
+}
|
|
|
951ecb |
+
|
|
|
951ecb |
void
|
|
|
951ecb |
cli_resource_check(cib_t * cib_conn, resource_t *rsc)
|
|
|
951ecb |
{
|
|
|
951ecb |
--
|
|
|
951ecb |
1.8.3.1
|
|
|
951ecb |
|
|
|
951ecb |
|
|
|
951ecb |
From 4ae40b495305b87f59e439de3298910c243c171d Mon Sep 17 00:00:00 2001
|
|
|
951ecb |
From: "Gao,Yan" <ygao@suse.com>
|
|
|
951ecb |
Date: Fri, 8 Dec 2017 16:22:54 +0100
|
|
|
951ecb |
Subject: [PATCH 2/8] Fix: tools: crm_resource --cleanup for non-primitive
|
|
|
951ecb |
resources
|
|
|
951ecb |
|
|
|
951ecb |
---
|
|
|
951ecb |
tools/crm_resource_runtime.c | 18 ++++++++++++++++++
|
|
|
951ecb |
1 file changed, 18 insertions(+)
|
|
|
951ecb |
|
|
|
951ecb |
diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c
|
|
|
951ecb |
index 9aa7b7e..98cd27f 100644
|
|
|
951ecb |
--- a/tools/crm_resource_runtime.c
|
|
|
951ecb |
+++ b/tools/crm_resource_runtime.c
|
|
|
951ecb |
@@ -688,6 +688,24 @@ cli_resource_delete_failures(crm_ipc_t *crmd_channel, const char *host_uname,
|
|
|
951ecb |
{
|
|
|
951ecb |
int rc = pcmk_ok;
|
|
|
951ecb |
|
|
|
951ecb |
+ if (rsc == NULL) {
|
|
|
951ecb |
+ return -ENXIO;
|
|
|
951ecb |
+
|
|
|
951ecb |
+ } else if (rsc->children) {
|
|
|
951ecb |
+ GListPtr lpc = NULL;
|
|
|
951ecb |
+
|
|
|
951ecb |
+ for (lpc = rsc->children; lpc != NULL; lpc = lpc->next) {
|
|
|
951ecb |
+ resource_t *child = (resource_t *) lpc->data;
|
|
|
951ecb |
+
|
|
|
951ecb |
+ rc = cli_resource_delete_failures(crmd_channel, host_uname, child, operation,
|
|
|
951ecb |
+ interval, data_set);
|
|
|
951ecb |
+ if(rc != pcmk_ok) {
|
|
|
951ecb |
+ return rc;
|
|
|
951ecb |
+ }
|
|
|
951ecb |
+ }
|
|
|
951ecb |
+ return pcmk_ok;
|
|
|
951ecb |
+ }
|
|
|
951ecb |
+
|
|
|
951ecb |
for (xmlNode *xml_op = __xml_first_child(data_set->failed); xml_op != NULL;
|
|
|
951ecb |
xml_op = __xml_next(xml_op)) {
|
|
|
951ecb |
|
|
|
951ecb |
--
|
|
|
951ecb |
1.8.3.1
|
|
|
951ecb |
|
|
|
951ecb |
|
|
|
951ecb |
From 6ce88cdbcbe15b7e81a4234eb92a93663243a7ff Mon Sep 17 00:00:00 2001
|
|
|
109fe2 |
From: Ken Gaillot <kgaillot@redhat.com>
|
|
|
109fe2 |
Date: Mon, 11 Dec 2017 12:23:06 -0600
|
|
|
951ecb |
Subject: [PATCH 3/8] Fix: tools: crm_resource --cleanup
|
|
|
109fe2 |
|
|
|
109fe2 |
The new "failures only" mode of crm_resource --cleanup had multiple issues,
|
|
|
109fe2 |
including not working without --resource specified, comparing a
|
|
|
109fe2 |
user-provided interval string against a milliseconds interval, and
|
|
|
109fe2 |
considering no interval specified as all intervals rather than 0
|
|
|
109fe2 |
but only when clearing LRM history entries.
|
|
|
109fe2 |
---
|
|
|
109fe2 |
tools/crm_resource.c | 35 +++---
|
|
|
109fe2 |
tools/crm_resource.h | 9 +-
|
|
|
109fe2 |
tools/crm_resource_runtime.c | 258 ++++++++++++++++++++++++++++++-------------
|
|
|
109fe2 |
3 files changed, 202 insertions(+), 100 deletions(-)
|
|
|
109fe2 |
|
|
|
109fe2 |
diff --git a/tools/crm_resource.c b/tools/crm_resource.c
|
|
|
951ecb |
index 331adf6..e3f8f86 100644
|
|
|
109fe2 |
--- a/tools/crm_resource.c
|
|
|
109fe2 |
+++ b/tools/crm_resource.c
|
|
|
951ecb |
@@ -1101,14 +1101,20 @@ main(int argc, char **argv)
|
|
|
109fe2 |
rc = cli_resource_delete_attribute(rsc, rsc_id, prop_set, prop_id,
|
|
|
109fe2 |
prop_name, cib_conn, &data_set);
|
|
|
109fe2 |
|
|
|
109fe2 |
- } else if (rsc_cmd == 'C' && just_errors) {
|
|
|
109fe2 |
+ } else if ((rsc_cmd == 'C') && rsc) {
|
|
|
109fe2 |
+ if (do_force == FALSE) {
|
|
|
109fe2 |
+ rsc = uber_parent(rsc);
|
|
|
109fe2 |
+ }
|
|
|
109fe2 |
crmd_replies_needed = 0;
|
|
|
109fe2 |
|
|
|
109fe2 |
- rc = cli_resource_delete_failures(crmd_channel, host_uname, rsc, operation,
|
|
|
109fe2 |
- interval, &data_set);
|
|
|
109fe2 |
+ crm_debug("%s of %s (%s requested) on %s",
|
|
|
109fe2 |
+ (just_errors? "Clearing failures" : "Re-checking the state"),
|
|
|
109fe2 |
+ rsc->id, rsc_id, (host_uname? host_uname : "all hosts"));
|
|
|
109fe2 |
+ rc = cli_resource_delete(crmd_channel, host_uname, rsc, operation,
|
|
|
109fe2 |
+ interval, just_errors, &data_set);
|
|
|
109fe2 |
|
|
|
109fe2 |
- if(rsc && (rc == pcmk_ok) && (BE_QUIET == FALSE)) {
|
|
|
109fe2 |
- /* Now check XML_RSC_ATTR_TARGET_ROLE and XML_RSC_ATTR_MANAGED */
|
|
|
109fe2 |
+ if ((rc == pcmk_ok) && !BE_QUIET) {
|
|
|
109fe2 |
+ // Show any reasons why resource might stay stopped
|
|
|
109fe2 |
cli_resource_check(cib_conn, rsc);
|
|
|
109fe2 |
}
|
|
|
109fe2 |
|
|
|
951ecb |
@@ -1116,22 +1122,9 @@ main(int argc, char **argv)
|
|
|
109fe2 |
start_mainloop();
|
|
|
109fe2 |
}
|
|
|
109fe2 |
|
|
|
109fe2 |
- } else if ((rsc_cmd == 'C') && rsc) {
|
|
|
109fe2 |
- if(do_force == FALSE) {
|
|
|
109fe2 |
- rsc = uber_parent(rsc);
|
|
|
109fe2 |
- }
|
|
|
109fe2 |
-
|
|
|
109fe2 |
- crm_debug("Re-checking the state of %s (%s requested) on %s",
|
|
|
109fe2 |
- rsc->id, rsc_id, host_uname);
|
|
|
109fe2 |
- crmd_replies_needed = 0;
|
|
|
109fe2 |
- rc = cli_resource_delete(crmd_channel, host_uname, rsc, operation,
|
|
|
109fe2 |
- interval, &data_set);
|
|
|
109fe2 |
-
|
|
|
109fe2 |
- if(rc == pcmk_ok && BE_QUIET == FALSE) {
|
|
|
109fe2 |
- /* Now check XML_RSC_ATTR_TARGET_ROLE and XML_RSC_ATTR_MANAGED */
|
|
|
109fe2 |
- cli_resource_check(cib_conn, rsc);
|
|
|
109fe2 |
- }
|
|
|
109fe2 |
-
|
|
|
109fe2 |
+ } else if (rsc_cmd == 'C' && just_errors) {
|
|
|
109fe2 |
+ rc = cli_cleanup_all(crmd_channel, host_uname, operation, interval,
|
|
|
109fe2 |
+ &data_set);
|
|
|
109fe2 |
if (rc == pcmk_ok) {
|
|
|
109fe2 |
start_mainloop();
|
|
|
109fe2 |
}
|
|
|
109fe2 |
diff --git a/tools/crm_resource.h b/tools/crm_resource.h
|
|
|
109fe2 |
index e28c9ef..0ac51f2 100644
|
|
|
109fe2 |
--- a/tools/crm_resource.h
|
|
|
109fe2 |
+++ b/tools/crm_resource.h
|
|
|
109fe2 |
@@ -75,10 +75,11 @@ int cli_resource_search(resource_t *rsc, const char *requested_name,
|
|
|
109fe2 |
pe_working_set_t *data_set);
|
|
|
109fe2 |
int cli_resource_delete(crm_ipc_t *crmd_channel, const char *host_uname,
|
|
|
109fe2 |
resource_t *rsc, const char *operation,
|
|
|
109fe2 |
- const char *interval, pe_working_set_t *data_set);
|
|
|
109fe2 |
-int cli_resource_delete_failures(crm_ipc_t *crmd_channel, const char *host_uname,
|
|
|
109fe2 |
- resource_t *rsc, const char *operation,
|
|
|
109fe2 |
- const char *interval, pe_working_set_t *data_set);
|
|
|
109fe2 |
+ const char *interval, bool just_failures,
|
|
|
109fe2 |
+ pe_working_set_t *data_set);
|
|
|
109fe2 |
+int cli_cleanup_all(crm_ipc_t *crmd_channel, const char *node_name,
|
|
|
109fe2 |
+ const char *operation, const char *interval,
|
|
|
109fe2 |
+ pe_working_set_t *data_set);
|
|
|
109fe2 |
int cli_resource_restart(resource_t * rsc, const char *host, int timeout_ms, cib_t * cib);
|
|
|
109fe2 |
int cli_resource_move(resource_t *rsc, const char *rsc_id,
|
|
|
109fe2 |
const char *host_name, cib_t *cib,
|
|
|
109fe2 |
diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c
|
|
|
951ecb |
index 98cd27f..2cc2bec 100644
|
|
|
109fe2 |
--- a/tools/crm_resource_runtime.c
|
|
|
109fe2 |
+++ b/tools/crm_resource_runtime.c
|
|
|
951ecb |
@@ -558,15 +558,129 @@ rsc_fail_name(resource_t *rsc)
|
|
|
109fe2 |
return is_set(rsc->flags, pe_rsc_unique)? strdup(name) : clone_strip(name);
|
|
|
109fe2 |
}
|
|
|
109fe2 |
|
|
|
109fe2 |
+static int
|
|
|
109fe2 |
+clear_rsc_history(crm_ipc_t *crmd_channel, const char *host_uname,
|
|
|
109fe2 |
+ const char *rsc_id, pe_working_set_t *data_set)
|
|
|
109fe2 |
+{
|
|
|
109fe2 |
+ int rc = pcmk_ok;
|
|
|
109fe2 |
+
|
|
|
109fe2 |
+ /* Erase the resource's entire LRM history in the CIB, even if we're only
|
|
|
109fe2 |
+ * clearing a single operation's fail count. If we erased only entries for a
|
|
|
109fe2 |
+ * single operation, we might wind up with a wrong idea of the current
|
|
|
109fe2 |
+ * resource state, and we might not re-probe the resource.
|
|
|
109fe2 |
+ */
|
|
|
109fe2 |
+ rc = send_lrm_rsc_op(crmd_channel, CRM_OP_LRM_DELETE, host_uname, rsc_id,
|
|
|
109fe2 |
+ TRUE, data_set);
|
|
|
109fe2 |
+ if (rc != pcmk_ok) {
|
|
|
109fe2 |
+ return rc;
|
|
|
109fe2 |
+ }
|
|
|
109fe2 |
+ crmd_replies_needed++;
|
|
|
109fe2 |
+
|
|
|
109fe2 |
+ crm_trace("Processing %d mainloop inputs", crmd_replies_needed);
|
|
|
109fe2 |
+ while (g_main_context_iteration(NULL, FALSE)) {
|
|
|
109fe2 |
+ crm_trace("Processed mainloop input, %d still remaining",
|
|
|
109fe2 |
+ crmd_replies_needed);
|
|
|
109fe2 |
+ }
|
|
|
109fe2 |
+
|
|
|
109fe2 |
+ if (crmd_replies_needed < 0) {
|
|
|
109fe2 |
+ crmd_replies_needed = 0;
|
|
|
109fe2 |
+ }
|
|
|
109fe2 |
+ return rc;
|
|
|
109fe2 |
+}
|
|
|
109fe2 |
+
|
|
|
109fe2 |
+static int
|
|
|
109fe2 |
+clear_rsc_failures(crm_ipc_t *crmd_channel, const char *node_name,
|
|
|
109fe2 |
+ const char *rsc_id, const char *operation,
|
|
|
109fe2 |
+ const char *interval, pe_working_set_t *data_set)
|
|
|
109fe2 |
+{
|
|
|
109fe2 |
+ int rc = pcmk_ok;
|
|
|
109fe2 |
+ const char *failed_value = NULL;
|
|
|
109fe2 |
+ const char *interval_ms_str = NULL;
|
|
|
109fe2 |
+ GHashTable *rscs = NULL;
|
|
|
109fe2 |
+ GHashTableIter iter;
|
|
|
109fe2 |
+
|
|
|
109fe2 |
+ /* Create a hash table to use as a set of resources to clean. This lets us
|
|
|
109fe2 |
+ * clean each resource only once (per node) regardless of how many failed
|
|
|
109fe2 |
+ * operations it has.
|
|
|
109fe2 |
+ */
|
|
|
109fe2 |
+ rscs = g_hash_table_new_full(crm_str_hash, g_str_equal, NULL, NULL);
|
|
|
109fe2 |
+
|
|
|
109fe2 |
+ // Normalize interval to milliseconds for comparison to history entry
|
|
|
109fe2 |
+ if (operation) {
|
|
|
109fe2 |
+ interval_ms_str = crm_strdup_printf("%llu", crm_get_interval(interval));
|
|
|
109fe2 |
+ }
|
|
|
109fe2 |
+
|
|
|
109fe2 |
+ for (xmlNode *xml_op = __xml_first_child(data_set->failed); xml_op != NULL;
|
|
|
109fe2 |
+ xml_op = __xml_next(xml_op)) {
|
|
|
109fe2 |
+
|
|
|
109fe2 |
+ // No resource specified means all resources match
|
|
|
109fe2 |
+ failed_value = crm_element_value(xml_op, XML_LRM_ATTR_RSCID);
|
|
|
109fe2 |
+ if (rsc_id == NULL) {
|
|
|
109fe2 |
+ rsc_id = failed_value;
|
|
|
109fe2 |
+ } else if (safe_str_neq(rsc_id, failed_value)) {
|
|
|
109fe2 |
+ continue;
|
|
|
109fe2 |
+ }
|
|
|
109fe2 |
+
|
|
|
109fe2 |
+ // Host name should always have been provided by this point
|
|
|
109fe2 |
+ failed_value = crm_element_value(xml_op, XML_ATTR_UNAME);
|
|
|
109fe2 |
+ if (safe_str_neq(node_name, failed_value)) {
|
|
|
109fe2 |
+ continue;
|
|
|
109fe2 |
+ }
|
|
|
109fe2 |
+
|
|
|
109fe2 |
+ // No operation specified means all operations match
|
|
|
109fe2 |
+ if (operation) {
|
|
|
109fe2 |
+ failed_value = crm_element_value(xml_op, XML_LRM_ATTR_TASK);
|
|
|
109fe2 |
+ if (safe_str_neq(operation, failed_value)) {
|
|
|
109fe2 |
+ continue;
|
|
|
109fe2 |
+ }
|
|
|
109fe2 |
+
|
|
|
109fe2 |
+ // Interval (if operation was specified) defaults to 0 (not all)
|
|
|
109fe2 |
+ failed_value = crm_element_value(xml_op, XML_LRM_ATTR_INTERVAL);
|
|
|
109fe2 |
+ if (safe_str_neq(interval_ms_str, failed_value)) {
|
|
|
109fe2 |
+ continue;
|
|
|
109fe2 |
+ }
|
|
|
109fe2 |
+ }
|
|
|
109fe2 |
+
|
|
|
109fe2 |
+ g_hash_table_add(rscs, (gpointer) rsc_id);
|
|
|
109fe2 |
+ }
|
|
|
109fe2 |
+
|
|
|
109fe2 |
+ g_hash_table_iter_init(&iter, rscs);
|
|
|
109fe2 |
+ while (g_hash_table_iter_next(&iter, (gpointer *) &rsc_id, NULL)) {
|
|
|
109fe2 |
+ crm_debug("Erasing failures of %s on %s", rsc_id, node_name);
|
|
|
109fe2 |
+ rc = clear_rsc_history(crmd_channel, node_name, rsc_id, data_set);
|
|
|
109fe2 |
+ if (rc != pcmk_ok) {
|
|
|
109fe2 |
+ return rc;
|
|
|
109fe2 |
+ }
|
|
|
109fe2 |
+ }
|
|
|
109fe2 |
+ g_hash_table_destroy(rscs);
|
|
|
109fe2 |
+ return rc;
|
|
|
109fe2 |
+}
|
|
|
109fe2 |
+
|
|
|
109fe2 |
+static int
|
|
|
109fe2 |
+clear_rsc_fail_attrs(resource_t *rsc, const char *operation,
|
|
|
109fe2 |
+ const char *interval, node_t *node)
|
|
|
109fe2 |
+{
|
|
|
109fe2 |
+ int rc = pcmk_ok;
|
|
|
109fe2 |
+ int attr_options = attrd_opt_none;
|
|
|
109fe2 |
+ char *rsc_name = rsc_fail_name(rsc);
|
|
|
109fe2 |
+
|
|
|
109fe2 |
+ if (is_remote_node(node)) {
|
|
|
109fe2 |
+ attr_options |= attrd_opt_remote;
|
|
|
109fe2 |
+ }
|
|
|
109fe2 |
+ rc = attrd_clear_delegate(NULL, node->details->uname, rsc_name, operation,
|
|
|
109fe2 |
+ interval, NULL, attr_options);
|
|
|
109fe2 |
+ free(rsc_name);
|
|
|
109fe2 |
+ return rc;
|
|
|
109fe2 |
+}
|
|
|
109fe2 |
+
|
|
|
109fe2 |
int
|
|
|
109fe2 |
cli_resource_delete(crm_ipc_t *crmd_channel, const char *host_uname,
|
|
|
109fe2 |
resource_t *rsc, const char *operation,
|
|
|
109fe2 |
- const char *interval, pe_working_set_t *data_set)
|
|
|
109fe2 |
+ const char *interval, bool just_failures,
|
|
|
109fe2 |
+ pe_working_set_t *data_set)
|
|
|
109fe2 |
{
|
|
|
109fe2 |
int rc = pcmk_ok;
|
|
|
109fe2 |
node_t *node = NULL;
|
|
|
109fe2 |
- char *rsc_name = NULL;
|
|
|
109fe2 |
- int attr_options = attrd_opt_none;
|
|
|
109fe2 |
|
|
|
109fe2 |
if (rsc == NULL) {
|
|
|
109fe2 |
return -ENXIO;
|
|
|
951ecb |
@@ -578,8 +692,8 @@ cli_resource_delete(crm_ipc_t *crmd_channel, const char *host_uname,
|
|
|
109fe2 |
resource_t *child = (resource_t *) lpc->data;
|
|
|
109fe2 |
|
|
|
109fe2 |
rc = cli_resource_delete(crmd_channel, host_uname, child, operation,
|
|
|
109fe2 |
- interval, data_set);
|
|
|
109fe2 |
- if(rc != pcmk_ok) {
|
|
|
109fe2 |
+ interval, just_failures, data_set);
|
|
|
109fe2 |
+ if (rc != pcmk_ok) {
|
|
|
109fe2 |
return rc;
|
|
|
109fe2 |
}
|
|
|
109fe2 |
}
|
|
|
951ecb |
@@ -611,8 +725,13 @@ cli_resource_delete(crm_ipc_t *crmd_channel, const char *host_uname,
|
|
|
109fe2 |
node = (node_t *) lpc->data;
|
|
|
109fe2 |
|
|
|
109fe2 |
if (node->details->online) {
|
|
|
109fe2 |
- cli_resource_delete(crmd_channel, node->details->uname, rsc,
|
|
|
109fe2 |
- operation, interval, data_set);
|
|
|
109fe2 |
+ rc = cli_resource_delete(crmd_channel, node->details->uname,
|
|
|
109fe2 |
+ rsc, operation, interval,
|
|
|
109fe2 |
+ just_failures, data_set);
|
|
|
109fe2 |
+ }
|
|
|
109fe2 |
+ if (rc != pcmk_ok) {
|
|
|
109fe2 |
+ g_list_free(nodes);
|
|
|
109fe2 |
+ return rc;
|
|
|
109fe2 |
}
|
|
|
109fe2 |
}
|
|
|
109fe2 |
|
|
|
951ecb |
@@ -637,102 +756,91 @@ cli_resource_delete(crm_ipc_t *crmd_channel, const char *host_uname,
|
|
|
109fe2 |
if (crmd_channel == NULL) {
|
|
|
109fe2 |
printf("Dry run: skipping clean-up of %s on %s due to CIB_file\n",
|
|
|
109fe2 |
rsc->id, host_uname);
|
|
|
109fe2 |
- return rc;
|
|
|
109fe2 |
- }
|
|
|
109fe2 |
+ return pcmk_ok;
|
|
|
109fe2 |
+ }
|
|
|
109fe2 |
|
|
|
109fe2 |
- /* Erase the resource's entire LRM history in the CIB, even if we're only
|
|
|
109fe2 |
- * clearing a single operation's fail count. If we erased only entries for a
|
|
|
109fe2 |
- * single operation, we might wind up with a wrong idea of the current
|
|
|
109fe2 |
- * resource state, and we might not re-probe the resource.
|
|
|
109fe2 |
- */
|
|
|
109fe2 |
- rc = send_lrm_rsc_op(crmd_channel, CRM_OP_LRM_DELETE, host_uname, rsc->id,
|
|
|
109fe2 |
- TRUE, data_set);
|
|
|
109fe2 |
+ rc = clear_rsc_fail_attrs(rsc, operation, interval, node);
|
|
|
109fe2 |
if (rc != pcmk_ok) {
|
|
|
109fe2 |
- printf("Unable to clean up %s history on %s: %s\n",
|
|
|
109fe2 |
- rsc->id, host_uname, pcmk_strerror(rc));
|
|
|
109fe2 |
+ printf("Unable to clean up %s failures on %s: %s\n",
|
|
|
109fe2 |
+ rsc->id, host_uname, pcmk_strerror(rc));
|
|
|
109fe2 |
return rc;
|
|
|
109fe2 |
}
|
|
|
109fe2 |
- crmd_replies_needed++;
|
|
|
109fe2 |
|
|
|
109fe2 |
- crm_trace("Processing %d mainloop inputs", crmd_replies_needed);
|
|
|
109fe2 |
- while(g_main_context_iteration(NULL, FALSE)) {
|
|
|
109fe2 |
- crm_trace("Processed mainloop input, %d still remaining",
|
|
|
109fe2 |
- crmd_replies_needed);
|
|
|
109fe2 |
- }
|
|
|
109fe2 |
-
|
|
|
109fe2 |
- if(crmd_replies_needed < 0) {
|
|
|
109fe2 |
- crmd_replies_needed = 0;
|
|
|
109fe2 |
- }
|
|
|
109fe2 |
-
|
|
|
109fe2 |
- rsc_name = rsc_fail_name(rsc);
|
|
|
109fe2 |
- if (is_remote_node(node)) {
|
|
|
109fe2 |
- attr_options |= attrd_opt_remote;
|
|
|
109fe2 |
+ if (just_failures) {
|
|
|
109fe2 |
+ rc = clear_rsc_failures(crmd_channel, host_uname, rsc->id, operation,
|
|
|
109fe2 |
+ interval, data_set);
|
|
|
109fe2 |
+ } else {
|
|
|
109fe2 |
+ rc = clear_rsc_history(crmd_channel, host_uname, rsc->id, data_set);
|
|
|
109fe2 |
}
|
|
|
109fe2 |
- rc = attrd_clear_delegate(NULL, host_uname, rsc_name, operation, interval,
|
|
|
109fe2 |
- NULL, attr_options);
|
|
|
109fe2 |
if (rc != pcmk_ok) {
|
|
|
109fe2 |
- printf("Cleaned %s history on %s, but unable to clear failures: %s\n",
|
|
|
109fe2 |
+ printf("Cleaned %s failures on %s, but unable to clean history: %s\n",
|
|
|
109fe2 |
rsc->id, host_uname, pcmk_strerror(rc));
|
|
|
109fe2 |
} else {
|
|
|
109fe2 |
printf("Cleaned up %s on %s\n", rsc->id, host_uname);
|
|
|
109fe2 |
}
|
|
|
109fe2 |
- free(rsc_name);
|
|
|
109fe2 |
-
|
|
|
109fe2 |
return rc;
|
|
|
109fe2 |
}
|
|
|
109fe2 |
|
|
|
109fe2 |
int
|
|
|
109fe2 |
-cli_resource_delete_failures(crm_ipc_t *crmd_channel, const char *host_uname,
|
|
|
109fe2 |
- resource_t *rsc, const char *operation,
|
|
|
109fe2 |
- const char *interval, pe_working_set_t *data_set)
|
|
|
109fe2 |
+cli_cleanup_all(crm_ipc_t *crmd_channel, const char *node_name,
|
|
|
109fe2 |
+ const char *operation, const char *interval,
|
|
|
109fe2 |
+ pe_working_set_t *data_set)
|
|
|
109fe2 |
{
|
|
|
109fe2 |
+ int attr_options = attrd_opt_none;
|
|
|
109fe2 |
int rc = pcmk_ok;
|
|
|
109fe2 |
+ const char *display_name = node_name? node_name : "all nodes";
|
|
|
109fe2 |
|
|
|
109fe2 |
- if (rsc == NULL) {
|
|
|
109fe2 |
- return -ENXIO;
|
|
|
109fe2 |
-
|
|
|
109fe2 |
- } else if (rsc->children) {
|
|
|
109fe2 |
- GListPtr lpc = NULL;
|
|
|
109fe2 |
+ if (crmd_channel == NULL) {
|
|
|
109fe2 |
+ printf("Dry run: skipping clean-up of %s due to CIB_file\n",
|
|
|
109fe2 |
+ display_name);
|
|
|
109fe2 |
+ return pcmk_ok;
|
|
|
109fe2 |
+ }
|
|
|
109fe2 |
+ crmd_replies_needed = 0;
|
|
|
109fe2 |
|
|
|
109fe2 |
- for (lpc = rsc->children; lpc != NULL; lpc = lpc->next) {
|
|
|
109fe2 |
- resource_t *child = (resource_t *) lpc->data;
|
|
|
109fe2 |
+ if (node_name) {
|
|
|
109fe2 |
+ node_t *node = pe_find_node(data_set->nodes, node_name);
|
|
|
109fe2 |
|
|
|
109fe2 |
- rc = cli_resource_delete_failures(crmd_channel, host_uname, child, operation,
|
|
|
109fe2 |
- interval, data_set);
|
|
|
109fe2 |
- if(rc != pcmk_ok) {
|
|
|
109fe2 |
- return rc;
|
|
|
109fe2 |
- }
|
|
|
109fe2 |
+ if (node == NULL) {
|
|
|
109fe2 |
+ CMD_ERR("Unknown node: %s", node_name);
|
|
|
109fe2 |
+ return -ENXIO;
|
|
|
109fe2 |
+ }
|
|
|
109fe2 |
+ if (is_remote_node(node)) {
|
|
|
109fe2 |
+ attr_options |= attrd_opt_remote;
|
|
|
109fe2 |
}
|
|
|
109fe2 |
- return pcmk_ok;
|
|
|
109fe2 |
}
|
|
|
109fe2 |
|
|
|
109fe2 |
- for (xmlNode *xml_op = __xml_first_child(data_set->failed); xml_op != NULL;
|
|
|
109fe2 |
- xml_op = __xml_next(xml_op)) {
|
|
|
109fe2 |
-
|
|
|
109fe2 |
- const char *node = crm_element_value(xml_op, XML_ATTR_UNAME);
|
|
|
109fe2 |
- const char *task = crm_element_value(xml_op, XML_LRM_ATTR_TASK);
|
|
|
109fe2 |
- const char *task_interval = crm_element_value(xml_op, XML_LRM_ATTR_INTERVAL);
|
|
|
109fe2 |
- const char *resource_name = crm_element_value(xml_op, XML_LRM_ATTR_RSCID);
|
|
|
109fe2 |
+ rc = attrd_clear_delegate(NULL, node_name, NULL, operation, interval,
|
|
|
109fe2 |
+ NULL, attr_options);
|
|
|
109fe2 |
+ if (rc != pcmk_ok) {
|
|
|
109fe2 |
+ printf("Unable to clean up all failures on %s: %s\n",
|
|
|
109fe2 |
+ display_name, pcmk_strerror(rc));
|
|
|
109fe2 |
+ return rc;
|
|
|
109fe2 |
+ }
|
|
|
109fe2 |
|
|
|
109fe2 |
- if(resource_name == NULL) {
|
|
|
109fe2 |
- continue;
|
|
|
109fe2 |
- } else if(host_uname && safe_str_neq(host_uname, node)) {
|
|
|
109fe2 |
- continue;
|
|
|
109fe2 |
- } else if(rsc->id && safe_str_neq(rsc->id, resource_name)) {
|
|
|
109fe2 |
- continue;
|
|
|
109fe2 |
- } else if(operation && safe_str_neq(operation, task)) {
|
|
|
109fe2 |
- continue;
|
|
|
109fe2 |
- } else if(interval && safe_str_neq(interval, task_interval)) {
|
|
|
109fe2 |
- continue;
|
|
|
109fe2 |
+ if (node_name) {
|
|
|
109fe2 |
+ rc = clear_rsc_failures(crmd_channel, node_name, NULL,
|
|
|
109fe2 |
+ operation, interval, data_set);
|
|
|
109fe2 |
+ if (rc != pcmk_ok) {
|
|
|
109fe2 |
+ printf("Cleaned all resource failures on %s, but unable to clean history: %s\n",
|
|
|
109fe2 |
+ node_name, pcmk_strerror(rc));
|
|
|
109fe2 |
+ return rc;
|
|
|
109fe2 |
}
|
|
|
109fe2 |
+ } else {
|
|
|
109fe2 |
+ for (GList *iter = data_set->nodes; iter; iter = iter->next) {
|
|
|
109fe2 |
+ pe_node_t *node = (pe_node_t *) iter->data;
|
|
|
109fe2 |
|
|
|
109fe2 |
- crm_debug("Erasing %s failure for %s (%s detected) on %s",
|
|
|
109fe2 |
- task, rsc->id, resource_name, node);
|
|
|
109fe2 |
- rc = cli_resource_delete(crmd_channel, node, rsc, task,
|
|
|
109fe2 |
- task_interval, data_set);
|
|
|
109fe2 |
+ rc = clear_rsc_failures(crmd_channel, node->details->uname, NULL,
|
|
|
109fe2 |
+ operation, interval, data_set);
|
|
|
109fe2 |
+ if (rc != pcmk_ok) {
|
|
|
109fe2 |
+ printf("Cleaned all resource failures on all nodes, but unable to clean history on %s: %s\n",
|
|
|
109fe2 |
+ node->details->uname, pcmk_strerror(rc));
|
|
|
109fe2 |
+ return rc;
|
|
|
109fe2 |
+ }
|
|
|
109fe2 |
+ }
|
|
|
109fe2 |
}
|
|
|
109fe2 |
|
|
|
109fe2 |
- return rc;
|
|
|
109fe2 |
+ printf("Cleaned up all resources on %s\n", display_name);
|
|
|
109fe2 |
+ return pcmk_ok;
|
|
|
109fe2 |
}
|
|
|
109fe2 |
|
|
|
109fe2 |
void
|
|
|
109fe2 |
--
|
|
|
109fe2 |
1.8.3.1
|
|
|
109fe2 |
|
|
|
951ecb |
|
|
|
951ecb |
From 0b6c3b3064401c8f0ebb48ccfd11f43dc2dc2b1b Mon Sep 17 00:00:00 2001
|
|
|
951ecb |
From: Ken Gaillot <kgaillot@redhat.com>
|
|
|
951ecb |
Date: Tue, 12 Dec 2017 10:02:22 -0600
|
|
|
951ecb |
Subject: [PATCH 4/8] Fix: tools: crm_resource --cleanup with no resource
|
|
|
951ecb |
specified
|
|
|
951ecb |
|
|
|
951ecb |
7a813755 failed to completely fix --cleanup without --resource
|
|
|
951ecb |
---
|
|
|
951ecb |
tools/crm_resource_runtime.c | 20 ++++++++++++--------
|
|
|
951ecb |
1 file changed, 12 insertions(+), 8 deletions(-)
|
|
|
951ecb |
|
|
|
951ecb |
diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c
|
|
|
951ecb |
index 2cc2bec..ce86a49 100644
|
|
|
951ecb |
--- a/tools/crm_resource_runtime.c
|
|
|
951ecb |
+++ b/tools/crm_resource_runtime.c
|
|
|
951ecb |
@@ -595,6 +595,7 @@ clear_rsc_failures(crm_ipc_t *crmd_channel, const char *node_name,
|
|
|
951ecb |
{
|
|
|
951ecb |
int rc = pcmk_ok;
|
|
|
951ecb |
const char *failed_value = NULL;
|
|
|
951ecb |
+ const char *failed_id = NULL;
|
|
|
951ecb |
const char *interval_ms_str = NULL;
|
|
|
951ecb |
GHashTable *rscs = NULL;
|
|
|
951ecb |
GHashTableIter iter;
|
|
|
951ecb |
@@ -613,11 +614,14 @@ clear_rsc_failures(crm_ipc_t *crmd_channel, const char *node_name,
|
|
|
951ecb |
for (xmlNode *xml_op = __xml_first_child(data_set->failed); xml_op != NULL;
|
|
|
951ecb |
xml_op = __xml_next(xml_op)) {
|
|
|
951ecb |
|
|
|
951ecb |
+ failed_id = crm_element_value(xml_op, XML_LRM_ATTR_RSCID);
|
|
|
951ecb |
+ if (failed_id == NULL) {
|
|
|
951ecb |
+ // Malformed history entry, should never happen
|
|
|
951ecb |
+ continue;
|
|
|
951ecb |
+ }
|
|
|
951ecb |
+
|
|
|
951ecb |
// No resource specified means all resources match
|
|
|
951ecb |
- failed_value = crm_element_value(xml_op, XML_LRM_ATTR_RSCID);
|
|
|
951ecb |
- if (rsc_id == NULL) {
|
|
|
951ecb |
- rsc_id = failed_value;
|
|
|
951ecb |
- } else if (safe_str_neq(rsc_id, failed_value)) {
|
|
|
951ecb |
+ if (rsc_id && safe_str_neq(rsc_id, failed_id)) {
|
|
|
951ecb |
continue;
|
|
|
951ecb |
}
|
|
|
951ecb |
|
|
|
951ecb |
@@ -641,13 +645,13 @@ clear_rsc_failures(crm_ipc_t *crmd_channel, const char *node_name,
|
|
|
951ecb |
}
|
|
|
951ecb |
}
|
|
|
951ecb |
|
|
|
951ecb |
- g_hash_table_add(rscs, (gpointer) rsc_id);
|
|
|
951ecb |
+ g_hash_table_add(rscs, (gpointer) failed_id);
|
|
|
951ecb |
}
|
|
|
951ecb |
|
|
|
951ecb |
g_hash_table_iter_init(&iter, rscs);
|
|
|
951ecb |
- while (g_hash_table_iter_next(&iter, (gpointer *) &rsc_id, NULL)) {
|
|
|
951ecb |
- crm_debug("Erasing failures of %s on %s", rsc_id, node_name);
|
|
|
951ecb |
- rc = clear_rsc_history(crmd_channel, node_name, rsc_id, data_set);
|
|
|
951ecb |
+ while (g_hash_table_iter_next(&iter, (gpointer *) &failed_id, NULL)) {
|
|
|
951ecb |
+ crm_debug("Erasing failures of %s on %s", failed_id, node_name);
|
|
|
951ecb |
+ rc = clear_rsc_history(crmd_channel, node_name, failed_id, data_set);
|
|
|
951ecb |
if (rc != pcmk_ok) {
|
|
|
951ecb |
return rc;
|
|
|
951ecb |
}
|
|
|
951ecb |
--
|
|
|
951ecb |
1.8.3.1
|
|
|
951ecb |
|
|
|
951ecb |
|
|
|
951ecb |
From 9d5a1dae23a44db190782560d8dbdf50343b3692 Mon Sep 17 00:00:00 2001
|
|
|
951ecb |
From: Ken Gaillot <kgaillot@redhat.com>
|
|
|
951ecb |
Date: Wed, 24 Jan 2018 10:51:34 -0600
|
|
|
951ecb |
Subject: [PATCH 5/8] Low: tools: crm_resource --refresh should ignore
|
|
|
951ecb |
--operation and --interval
|
|
|
951ecb |
|
|
|
951ecb |
It already did when a resource was not specified.
|
|
|
951ecb |
Also update help text to clarify cleanup vs refresh.
|
|
|
951ecb |
---
|
|
|
951ecb |
tools/crm_resource.c | 23 +++++++++++------------
|
|
|
951ecb |
1 file changed, 11 insertions(+), 12 deletions(-)
|
|
|
951ecb |
|
|
|
951ecb |
diff --git a/tools/crm_resource.c b/tools/crm_resource.c
|
|
|
951ecb |
index e3f8f86..d00c8f2 100644
|
|
|
951ecb |
--- a/tools/crm_resource.c
|
|
|
951ecb |
+++ b/tools/crm_resource.c
|
|
|
951ecb |
@@ -214,15 +214,17 @@ static struct crm_option long_options[] = {
|
|
|
951ecb |
"cleanup", no_argument, NULL, 'C',
|
|
|
951ecb |
#if 0
|
|
|
951ecb |
// new behavior disabled until 2.0.0
|
|
|
951ecb |
- "\t\tDelete failed operations from a resource's history allowing its current state to be rechecked.\n"
|
|
|
951ecb |
+ "\t\tIf resource has any past failures, clear its history and fail count.\n"
|
|
|
951ecb |
"\t\t\t\tOptionally filtered by --resource, --node, --operation, and --interval (otherwise all).\n"
|
|
|
951ecb |
+ "\t\t\t\t--operation and --interval apply to fail counts, but entire history is always cleared,\n"
|
|
|
951ecb |
+ "\t\t\t\tto allow current state to be rechecked.\n"
|
|
|
951ecb |
},
|
|
|
951ecb |
{
|
|
|
951ecb |
"refresh", no_argument, NULL, 'R',
|
|
|
951ecb |
#endif
|
|
|
951ecb |
"\t\tDelete resource's history (including failures) so its current state is rechecked.\n"
|
|
|
951ecb |
- "\t\t\t\tOptionally filtered by --resource, --node, --operation, and --interval (otherwise all).\n"
|
|
|
951ecb |
- "\t\t\t\tUnless --force is specified, resource's group or clone (if any) will also be cleaned"
|
|
|
951ecb |
+ "\t\t\t\tOptionally filtered by --resource and --node (otherwise all).\n"
|
|
|
951ecb |
+ "\t\t\t\tUnless --force is specified, resource's group or clone (if any) will also be refreshed."
|
|
|
951ecb |
},
|
|
|
951ecb |
{
|
|
|
951ecb |
"set-parameter", required_argument, NULL, 'p',
|
|
|
951ecb |
@@ -442,7 +444,6 @@ main(int argc, char **argv)
|
|
|
951ecb |
bool require_resource = TRUE; /* whether command requires that resource be specified */
|
|
|
951ecb |
bool require_dataset = TRUE; /* whether command requires populated dataset instance */
|
|
|
951ecb |
bool require_crmd = FALSE; /* whether command requires connection to CRMd */
|
|
|
951ecb |
- bool just_errors = TRUE; /* whether cleanup command deletes all history or just errors */
|
|
|
951ecb |
|
|
|
951ecb |
int rc = pcmk_ok;
|
|
|
951ecb |
int is_ocf_rc = 0;
|
|
|
951ecb |
@@ -634,8 +635,7 @@ main(int argc, char **argv)
|
|
|
951ecb |
if (cib_file == NULL) {
|
|
|
951ecb |
require_crmd = TRUE;
|
|
|
951ecb |
}
|
|
|
951ecb |
- just_errors = FALSE;
|
|
|
951ecb |
- rsc_cmd = 'C';
|
|
|
951ecb |
+ rsc_cmd = 'R';
|
|
|
951ecb |
find_flags = pe_find_renamed|pe_find_anon;
|
|
|
951ecb |
break;
|
|
|
951ecb |
|
|
|
951ecb |
@@ -645,7 +645,6 @@ main(int argc, char **argv)
|
|
|
951ecb |
if (cib_file == NULL) {
|
|
|
951ecb |
require_crmd = TRUE;
|
|
|
951ecb |
}
|
|
|
951ecb |
- just_errors = FALSE; // disable until 2.0.0
|
|
|
951ecb |
rsc_cmd = 'C';
|
|
|
951ecb |
find_flags = pe_find_renamed|pe_find_anon;
|
|
|
951ecb |
break;
|
|
|
951ecb |
@@ -1101,7 +1100,7 @@ main(int argc, char **argv)
|
|
|
951ecb |
rc = cli_resource_delete_attribute(rsc, rsc_id, prop_set, prop_id,
|
|
|
951ecb |
prop_name, cib_conn, &data_set);
|
|
|
951ecb |
|
|
|
951ecb |
- } else if ((rsc_cmd == 'C') && rsc) {
|
|
|
951ecb |
+ } else if ((rsc_cmd == 'R') && rsc) {
|
|
|
951ecb |
if (do_force == FALSE) {
|
|
|
951ecb |
rsc = uber_parent(rsc);
|
|
|
951ecb |
}
|
|
|
951ecb |
@@ -1110,8 +1109,8 @@ main(int argc, char **argv)
|
|
|
951ecb |
crm_debug("%s of %s (%s requested) on %s",
|
|
|
951ecb |
(just_errors? "Clearing failures" : "Re-checking the state"),
|
|
|
951ecb |
rsc->id, rsc_id, (host_uname? host_uname : "all hosts"));
|
|
|
951ecb |
- rc = cli_resource_delete(crmd_channel, host_uname, rsc, operation,
|
|
|
951ecb |
- interval, just_errors, &data_set);
|
|
|
951ecb |
+ rc = cli_resource_delete(crmd_channel, host_uname, rsc, NULL, 0,
|
|
|
951ecb |
+ &data_set);
|
|
|
951ecb |
|
|
|
951ecb |
if ((rc == pcmk_ok) && !BE_QUIET) {
|
|
|
951ecb |
// Show any reasons why resource might stay stopped
|
|
|
951ecb |
@@ -1122,14 +1121,14 @@ main(int argc, char **argv)
|
|
|
951ecb |
start_mainloop();
|
|
|
951ecb |
}
|
|
|
951ecb |
|
|
|
951ecb |
- } else if (rsc_cmd == 'C' && just_errors) {
|
|
|
951ecb |
+ } else if (rsc_cmd == 'C') {
|
|
|
951ecb |
rc = cli_cleanup_all(crmd_channel, host_uname, operation, interval,
|
|
|
951ecb |
&data_set);
|
|
|
951ecb |
if (rc == pcmk_ok) {
|
|
|
951ecb |
start_mainloop();
|
|
|
951ecb |
}
|
|
|
951ecb |
|
|
|
951ecb |
- } else if (rsc_cmd == 'C') {
|
|
|
951ecb |
+ } else if (rsc_cmd == 'R') {
|
|
|
951ecb |
#if HAVE_ATOMIC_ATTRD
|
|
|
951ecb |
const char *router_node = host_uname;
|
|
|
951ecb |
xmlNode *msg_data = NULL;
|
|
|
951ecb |
--
|
|
|
951ecb |
1.8.3.1
|
|
|
951ecb |
|
|
|
951ecb |
|
|
|
951ecb |
From 035bebd78c1936b0749ae64fe949deb5d77effe9 Mon Sep 17 00:00:00 2001
|
|
|
951ecb |
From: Ken Gaillot <kgaillot@redhat.com>
|
|
|
951ecb |
Date: Tue, 13 Feb 2018 12:43:48 -0600
|
|
|
951ecb |
Subject: [PATCH 6/8] Fix: tools: auto-merge was insufficient
|
|
|
951ecb |
|
|
|
951ecb |
The master and 2.0 branches had taken different approaches to crm_resource
|
|
|
951ecb |
clean-up refactoring in response to different issues. It was necessary to
|
|
|
951ecb |
combine the code more carefully.
|
|
|
951ecb |
---
|
|
|
951ecb |
tools/crm_resource.c | 13 ++-----------
|
|
|
951ecb |
tools/crm_resource_runtime.c | 16 +++++++++++-----
|
|
|
951ecb |
2 files changed, 13 insertions(+), 16 deletions(-)
|
|
|
951ecb |
|
|
|
951ecb |
diff --git a/tools/crm_resource.c b/tools/crm_resource.c
|
|
|
951ecb |
index d00c8f2..fc46cc0 100644
|
|
|
951ecb |
--- a/tools/crm_resource.c
|
|
|
951ecb |
+++ b/tools/crm_resource.c
|
|
|
951ecb |
@@ -628,6 +628,7 @@ main(int argc, char **argv)
|
|
|
951ecb |
timeout_ms = crm_get_msec(optarg);
|
|
|
951ecb |
break;
|
|
|
951ecb |
|
|
|
951ecb |
+ case 'C':
|
|
|
951ecb |
case 'R':
|
|
|
951ecb |
case 'P':
|
|
|
951ecb |
crm_log_args(argc, argv);
|
|
|
951ecb |
@@ -635,17 +636,7 @@ main(int argc, char **argv)
|
|
|
951ecb |
if (cib_file == NULL) {
|
|
|
951ecb |
require_crmd = TRUE;
|
|
|
951ecb |
}
|
|
|
951ecb |
- rsc_cmd = 'R';
|
|
|
951ecb |
- find_flags = pe_find_renamed|pe_find_anon;
|
|
|
951ecb |
- break;
|
|
|
951ecb |
-
|
|
|
951ecb |
- case 'C':
|
|
|
951ecb |
- crm_log_args(argc, argv);
|
|
|
951ecb |
- require_resource = FALSE;
|
|
|
951ecb |
- if (cib_file == NULL) {
|
|
|
951ecb |
- require_crmd = TRUE;
|
|
|
951ecb |
- }
|
|
|
951ecb |
- rsc_cmd = 'C';
|
|
|
951ecb |
+ rsc_cmd = 'R'; // disable new behavior until 2.0
|
|
|
951ecb |
find_flags = pe_find_renamed|pe_find_anon;
|
|
|
951ecb |
break;
|
|
|
951ecb |
|
|
|
951ecb |
diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c
|
|
|
951ecb |
index ce86a49..e02cc44 100644
|
|
|
951ecb |
--- a/tools/crm_resource_runtime.c
|
|
|
951ecb |
+++ b/tools/crm_resource_runtime.c
|
|
|
951ecb |
@@ -621,8 +621,14 @@ clear_rsc_failures(crm_ipc_t *crmd_channel, const char *node_name,
|
|
|
951ecb |
}
|
|
|
951ecb |
|
|
|
951ecb |
// No resource specified means all resources match
|
|
|
951ecb |
- if (rsc_id && safe_str_neq(rsc_id, failed_id)) {
|
|
|
951ecb |
- continue;
|
|
|
951ecb |
+ if (rsc_id) {
|
|
|
951ecb |
+ resource_t *fail_rsc = pe_find_resource_with_flags(data_set->resources,
|
|
|
951ecb |
+ failed_id,
|
|
|
951ecb |
+ pe_find_renamed|pe_find_anon);
|
|
|
951ecb |
+
|
|
|
951ecb |
+ if (!fail_rsc || safe_str_neq(rsc_id, fail_rsc->id)) {
|
|
|
951ecb |
+ continue;
|
|
|
951ecb |
+ }
|
|
|
951ecb |
}
|
|
|
951ecb |
|
|
|
951ecb |
// Host name should always have been provided by this point
|
|
|
951ecb |
@@ -790,8 +796,8 @@ cli_cleanup_all(crm_ipc_t *crmd_channel, const char *node_name,
|
|
|
951ecb |
const char *operation, const char *interval,
|
|
|
951ecb |
pe_working_set_t *data_set)
|
|
|
951ecb |
{
|
|
|
951ecb |
- int attr_options = attrd_opt_none;
|
|
|
951ecb |
int rc = pcmk_ok;
|
|
|
951ecb |
+ int attr_options = attrd_opt_none;
|
|
|
951ecb |
const char *display_name = node_name? node_name : "all nodes";
|
|
|
951ecb |
|
|
|
951ecb |
if (crmd_channel == NULL) {
|
|
|
951ecb |
@@ -836,8 +842,8 @@ cli_cleanup_all(crm_ipc_t *crmd_channel, const char *node_name,
|
|
|
951ecb |
rc = clear_rsc_failures(crmd_channel, node->details->uname, NULL,
|
|
|
951ecb |
operation, interval, data_set);
|
|
|
951ecb |
if (rc != pcmk_ok) {
|
|
|
951ecb |
- printf("Cleaned all resource failures on all nodes, but unable to clean history on %s: %s\n",
|
|
|
951ecb |
- node->details->uname, pcmk_strerror(rc));
|
|
|
951ecb |
+ printf("Cleaned all resource failures on all nodes, but unable to clean history: %s\n",
|
|
|
951ecb |
+ pcmk_strerror(rc));
|
|
|
951ecb |
return rc;
|
|
|
951ecb |
}
|
|
|
951ecb |
}
|
|
|
951ecb |
--
|
|
|
951ecb |
1.8.3.1
|
|
|
951ecb |
|
|
|
951ecb |
|
|
|
951ecb |
From 5fa351ec714de6b67c456fb1a85a8ebdb658f604 Mon Sep 17 00:00:00 2001
|
|
|
951ecb |
From: Ken Gaillot <kgaillot@redhat.com>
|
|
|
951ecb |
Date: Tue, 7 Aug 2018 10:42:59 -0500
|
|
|
951ecb |
Subject: [PATCH 7/8] Low: tools: update crm_resource for 1.1 vs 2.0
|
|
|
951ecb |
differences
|
|
|
951ecb |
|
|
|
951ecb |
---
|
|
|
951ecb |
tools/crm_resource.c | 37 +++++++++++++++++++++++++++----------
|
|
|
951ecb |
1 file changed, 27 insertions(+), 10 deletions(-)
|
|
|
951ecb |
|
|
|
951ecb |
diff --git a/tools/crm_resource.c b/tools/crm_resource.c
|
|
|
951ecb |
index fc46cc0..128d075 100644
|
|
|
951ecb |
--- a/tools/crm_resource.c
|
|
|
951ecb |
+++ b/tools/crm_resource.c
|
|
|
951ecb |
@@ -352,11 +352,13 @@ static struct crm_option long_options[] = {
|
|
|
951ecb |
},
|
|
|
951ecb |
{
|
|
|
951ecb |
"operation", required_argument, NULL, 'n',
|
|
|
951ecb |
- "\tOperation to clear instead of all (with -C -r)"
|
|
|
951ecb |
+ "\tOperation to clear instead of all (with -C -r)",
|
|
|
951ecb |
+ pcmk_option_hidden // only used with 2.0 -C behavior
|
|
|
951ecb |
},
|
|
|
951ecb |
{
|
|
|
951ecb |
"interval", required_argument, NULL, 'I',
|
|
|
951ecb |
- "\tInterval of operation to clear (default 0) (with -C -r -n)"
|
|
|
951ecb |
+ "\tInterval of operation to clear (default 0) (with -C -r -n)",
|
|
|
951ecb |
+ pcmk_option_hidden // only used with 2.0 -C behavior
|
|
|
951ecb |
},
|
|
|
951ecb |
{
|
|
|
951ecb |
"set-name", required_argument, NULL, 's',
|
|
|
951ecb |
@@ -1091,17 +1093,16 @@ main(int argc, char **argv)
|
|
|
951ecb |
rc = cli_resource_delete_attribute(rsc, rsc_id, prop_set, prop_id,
|
|
|
951ecb |
prop_name, cib_conn, &data_set);
|
|
|
951ecb |
|
|
|
951ecb |
- } else if ((rsc_cmd == 'R') && rsc) {
|
|
|
951ecb |
+ } else if ((rsc_cmd == 'C') && rsc) {
|
|
|
951ecb |
if (do_force == FALSE) {
|
|
|
951ecb |
rsc = uber_parent(rsc);
|
|
|
951ecb |
}
|
|
|
951ecb |
crmd_replies_needed = 0;
|
|
|
951ecb |
|
|
|
951ecb |
- crm_debug("%s of %s (%s requested) on %s",
|
|
|
951ecb |
- (just_errors? "Clearing failures" : "Re-checking the state"),
|
|
|
951ecb |
- rsc->id, rsc_id, (host_uname? host_uname : "all hosts"));
|
|
|
951ecb |
- rc = cli_resource_delete(crmd_channel, host_uname, rsc, NULL, 0,
|
|
|
951ecb |
- &data_set);
|
|
|
951ecb |
+ crm_debug("Erasing failures of %s (%s requested) on %s",
|
|
|
951ecb |
+ rsc->id, rsc_id, (host_uname? host_uname: "all nodes"));
|
|
|
951ecb |
+ rc = cli_resource_delete(crmd_channel, host_uname, rsc,
|
|
|
951ecb |
+ operation, interval, TRUE, &data_set);
|
|
|
951ecb |
|
|
|
951ecb |
if ((rc == pcmk_ok) && !BE_QUIET) {
|
|
|
951ecb |
// Show any reasons why resource might stay stopped
|
|
|
951ecb |
@@ -1119,6 +1120,22 @@ main(int argc, char **argv)
|
|
|
951ecb |
start_mainloop();
|
|
|
951ecb |
}
|
|
|
951ecb |
|
|
|
951ecb |
+ } else if ((rsc_cmd == 'R') && rsc) {
|
|
|
951ecb |
+ if (do_force == FALSE) {
|
|
|
951ecb |
+ rsc = uber_parent(rsc);
|
|
|
951ecb |
+ }
|
|
|
951ecb |
+ crmd_replies_needed = 0;
|
|
|
951ecb |
+
|
|
|
951ecb |
+ crm_debug("Re-checking the state of %s (%s requested) on %s",
|
|
|
951ecb |
+ rsc->id, rsc_id, (host_uname? host_uname: "all nodes"));
|
|
|
951ecb |
+ rc = cli_resource_delete(crmd_channel, host_uname, rsc,
|
|
|
951ecb |
+ NULL, 0, FALSE, &data_set);
|
|
|
951ecb |
+
|
|
|
951ecb |
+ if ((rc == pcmk_ok) && !BE_QUIET) {
|
|
|
951ecb |
+ // Show any reasons why resource might stay stopped
|
|
|
951ecb |
+ cli_resource_check(cib_conn, rsc);
|
|
|
951ecb |
+ }
|
|
|
951ecb |
+
|
|
|
951ecb |
} else if (rsc_cmd == 'R') {
|
|
|
951ecb |
#if HAVE_ATOMIC_ATTRD
|
|
|
951ecb |
const char *router_node = host_uname;
|
|
|
951ecb |
@@ -1174,8 +1191,8 @@ main(int argc, char **argv)
|
|
|
951ecb |
crmd_replies_needed = 0;
|
|
|
951ecb |
for (rIter = data_set.resources; rIter; rIter = rIter->next) {
|
|
|
951ecb |
rsc = rIter->data;
|
|
|
951ecb |
- cli_resource_delete(crmd_channel, host_uname, rsc, NULL, NULL,
|
|
|
951ecb |
- &data_set);
|
|
|
951ecb |
+ cli_resource_delete(crmd_channel, host_uname, rsc, NULL, 0,
|
|
|
951ecb |
+ FALSE, &data_set);
|
|
|
951ecb |
}
|
|
|
951ecb |
|
|
|
951ecb |
start_mainloop();
|
|
|
951ecb |
--
|
|
|
951ecb |
1.8.3.1
|
|
|
951ecb |
|
|
|
951ecb |
|
|
|
951ecb |
From 555bdce4ceaf9a406059150c9dee047151fb3d94 Mon Sep 17 00:00:00 2001
|
|
|
951ecb |
From: Ken Gaillot <kgaillot@redhat.com>
|
|
|
951ecb |
Date: Tue, 7 Aug 2018 14:11:50 -0500
|
|
|
951ecb |
Subject: [PATCH 8/8] Low: tools: avoid function not available until glib
|
|
|
951ecb |
2.32.0
|
|
|
951ecb |
|
|
|
951ecb |
---
|
|
|
951ecb |
tools/crm_resource_runtime.c | 3 +++
|
|
|
951ecb |
1 file changed, 3 insertions(+)
|
|
|
951ecb |
|
|
|
951ecb |
diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c
|
|
|
951ecb |
index e02cc44..41cc742 100644
|
|
|
951ecb |
--- a/tools/crm_resource_runtime.c
|
|
|
951ecb |
+++ b/tools/crm_resource_runtime.c
|
|
|
951ecb |
@@ -651,7 +651,10 @@ clear_rsc_failures(crm_ipc_t *crmd_channel, const char *node_name,
|
|
|
951ecb |
}
|
|
|
951ecb |
}
|
|
|
951ecb |
|
|
|
951ecb |
+ /* not available until glib 2.32
|
|
|
951ecb |
g_hash_table_add(rscs, (gpointer) failed_id);
|
|
|
951ecb |
+ */
|
|
|
951ecb |
+ g_hash_table_insert(rscs, (gpointer) failed_id, (gpointer) failed_id);
|
|
|
951ecb |
}
|
|
|
951ecb |
|
|
|
951ecb |
g_hash_table_iter_init(&iter, rscs);
|
|
|
951ecb |
--
|
|
|
951ecb |
1.8.3.1
|
|
|
951ecb |
|