You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

62 lines
2.4 KiB

From a2305469012b5fe3713427412c12459085ed61a1 Mon Sep 17 00:00:00 2001
From: Ken Gaillot <kgaillot@redhat.com>
Date: Tue, 12 Dec 2017 10:02:22 -0600
Subject: [PATCH] Fix: tools: crm_resource --cleanup with no resource specified
7a813755 failed to completely fix --cleanup without --resource
---
tools/crm_resource_runtime.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c
index bdebb0b..79f8b98 100644
--- a/tools/crm_resource_runtime.c
+++ b/tools/crm_resource_runtime.c
@@ -569,6 +569,7 @@ clear_rsc_failures(crm_ipc_t *crmd_channel, const char *node_name,
{
int rc = pcmk_ok;
const char *failed_value = NULL;
+ const char *failed_id = NULL;
const char *interval_ms_str = NULL;
GHashTable *rscs = NULL;
GHashTableIter iter;
@@ -587,11 +588,14 @@ clear_rsc_failures(crm_ipc_t *crmd_channel, const char *node_name,
for (xmlNode *xml_op = __xml_first_child(data_set->failed); xml_op != NULL;
xml_op = __xml_next(xml_op)) {
+ failed_id = crm_element_value(xml_op, XML_LRM_ATTR_RSCID);
+ if (failed_id == NULL) {
+ // Malformed history entry, should never happen
+ continue;
+ }
+
// No resource specified means all resources match
- failed_value = crm_element_value(xml_op, XML_LRM_ATTR_RSCID);
- if (rsc_id == NULL) {
- rsc_id = failed_value;
- } else if (safe_str_neq(rsc_id, failed_value)) {
+ if (rsc_id && safe_str_neq(rsc_id, failed_id)) {
continue;
}
@@ -615,13 +619,13 @@ clear_rsc_failures(crm_ipc_t *crmd_channel, const char *node_name,
}
}
- g_hash_table_add(rscs, (gpointer) rsc_id);
+ g_hash_table_add(rscs, (gpointer) failed_id);
}
g_hash_table_iter_init(&iter, rscs);
- while (g_hash_table_iter_next(&iter, (gpointer *) &rsc_id, NULL)) {
- crm_debug("Erasing failures of %s on %s", rsc_id, node_name);
- rc = clear_rsc_history(crmd_channel, node_name, rsc_id, data_set);
+ while (g_hash_table_iter_next(&iter, (gpointer *) &failed_id, NULL)) {
+ crm_debug("Erasing failures of %s on %s", failed_id, node_name);
+ rc = clear_rsc_history(crmd_channel, node_name, failed_id, data_set);
if (rc != pcmk_ok) {
return rc;
}
--
1.8.3.1