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.
157 lines
6.1 KiB
157 lines
6.1 KiB
From c2d5c19a863f407a034a63f2877eb5faf7036d59 Mon Sep 17 00:00:00 2001 |
|
From: "Gao,Yan" <ygao@suse.com> |
|
Date: Fri, 8 Dec 2017 14:47:40 +0100 |
|
Subject: [PATCH 1/2] Refactor: tools: crm_resource - Functionize cleaning up |
|
resource failures |
|
|
|
--- |
|
tools/crm_resource.c | 26 ++------------------------ |
|
tools/crm_resource.h | 3 +++ |
|
tools/crm_resource_runtime.c | 36 ++++++++++++++++++++++++++++++++++++ |
|
3 files changed, 41 insertions(+), 24 deletions(-) |
|
|
|
diff --git a/tools/crm_resource.c b/tools/crm_resource.c |
|
index f93f688..4ddcef4 100644 |
|
--- a/tools/crm_resource.c |
|
+++ b/tools/crm_resource.c |
|
@@ -1094,31 +1094,9 @@ main(int argc, char **argv) |
|
|
|
} else if (rsc_cmd == 'C' && just_errors) { |
|
crmd_replies_needed = 0; |
|
- for (xmlNode *xml_op = __xml_first_child(data_set.failed); xml_op != NULL; |
|
- xml_op = __xml_next(xml_op)) { |
|
- |
|
- const char *node = crm_element_value(xml_op, XML_ATTR_UNAME); |
|
- const char *task = crm_element_value(xml_op, XML_LRM_ATTR_TASK); |
|
- const char *task_interval = crm_element_value(xml_op, XML_LRM_ATTR_INTERVAL); |
|
- const char *resource_name = crm_element_value(xml_op, XML_LRM_ATTR_RSCID); |
|
- |
|
- if(resource_name == NULL) { |
|
- continue; |
|
- } else if(host_uname && safe_str_neq(host_uname, node)) { |
|
- continue; |
|
- } else if(rsc_id && safe_str_neq(rsc_id, resource_name)) { |
|
- continue; |
|
- } else if(operation && safe_str_neq(operation, task)) { |
|
- continue; |
|
- } else if(interval && safe_str_neq(interval, task_interval)) { |
|
- continue; |
|
- } |
|
|
|
- crm_debug("Erasing %s failure for %s (%s detected) on %s", |
|
- task, rsc->id, resource_name, node); |
|
- rc = cli_resource_delete(crmd_channel, node, rsc, task, |
|
- task_interval, &data_set); |
|
- } |
|
+ rc = cli_resource_delete_failures(crmd_channel, host_uname, rsc, operation, |
|
+ interval, &data_set); |
|
|
|
if(rsc && (rc == pcmk_ok) && (BE_QUIET == FALSE)) { |
|
/* Now check XML_RSC_ATTR_TARGET_ROLE and XML_RSC_ATTR_MANAGED */ |
|
diff --git a/tools/crm_resource.h b/tools/crm_resource.h |
|
index 0b8dd2a..e28c9ef 100644 |
|
--- a/tools/crm_resource.h |
|
+++ b/tools/crm_resource.h |
|
@@ -76,6 +76,9 @@ int cli_resource_search(resource_t *rsc, const char *requested_name, |
|
int cli_resource_delete(crm_ipc_t *crmd_channel, const char *host_uname, |
|
resource_t *rsc, const char *operation, |
|
const char *interval, pe_working_set_t *data_set); |
|
+int cli_resource_delete_failures(crm_ipc_t *crmd_channel, const char *host_uname, |
|
+ resource_t *rsc, const char *operation, |
|
+ const char *interval, pe_working_set_t *data_set); |
|
int cli_resource_restart(resource_t * rsc, const char *host, int timeout_ms, cib_t * cib); |
|
int cli_resource_move(resource_t *rsc, const char *rsc_id, |
|
const char *host_name, cib_t *cib, |
|
diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c |
|
index ffe4e5d..d250a07 100644 |
|
--- a/tools/crm_resource_runtime.c |
|
+++ b/tools/crm_resource_runtime.c |
|
@@ -655,6 +655,42 @@ cli_resource_delete(crm_ipc_t *crmd_channel, const char *host_uname, |
|
return rc; |
|
} |
|
|
|
+int |
|
+cli_resource_delete_failures(crm_ipc_t *crmd_channel, const char *host_uname, |
|
+ resource_t *rsc, const char *operation, |
|
+ const char *interval, pe_working_set_t *data_set) |
|
+{ |
|
+ int rc = pcmk_ok; |
|
+ |
|
+ for (xmlNode *xml_op = __xml_first_child(data_set->failed); xml_op != NULL; |
|
+ xml_op = __xml_next(xml_op)) { |
|
+ |
|
+ const char *node = crm_element_value(xml_op, XML_ATTR_UNAME); |
|
+ const char *task = crm_element_value(xml_op, XML_LRM_ATTR_TASK); |
|
+ const char *task_interval = crm_element_value(xml_op, XML_LRM_ATTR_INTERVAL); |
|
+ const char *resource_name = crm_element_value(xml_op, XML_LRM_ATTR_RSCID); |
|
+ |
|
+ if(resource_name == NULL) { |
|
+ continue; |
|
+ } else if(host_uname && safe_str_neq(host_uname, node)) { |
|
+ continue; |
|
+ } else if(rsc->id && safe_str_neq(rsc->id, resource_name)) { |
|
+ continue; |
|
+ } else if(operation && safe_str_neq(operation, task)) { |
|
+ continue; |
|
+ } else if(interval && safe_str_neq(interval, task_interval)) { |
|
+ continue; |
|
+ } |
|
+ |
|
+ crm_debug("Erasing %s failure for %s (%s detected) on %s", |
|
+ task, rsc->id, resource_name, node); |
|
+ rc = cli_resource_delete(crmd_channel, node, rsc, task, |
|
+ task_interval, data_set); |
|
+ } |
|
+ |
|
+ return rc; |
|
+} |
|
+ |
|
void |
|
cli_resource_check(cib_t * cib_conn, resource_t *rsc) |
|
{ |
|
-- |
|
1.8.3.1 |
|
|
|
|
|
From 170ec0afcddb01fcfb8c2e8c86bc0e53594a42f9 Mon Sep 17 00:00:00 2001 |
|
From: "Gao,Yan" <ygao@suse.com> |
|
Date: Fri, 8 Dec 2017 16:22:54 +0100 |
|
Subject: [PATCH 2/2] Fix: tools: crm_resource --cleanup for non-primitive |
|
resources |
|
|
|
--- |
|
tools/crm_resource_runtime.c | 18 ++++++++++++++++++ |
|
1 file changed, 18 insertions(+) |
|
|
|
diff --git a/tools/crm_resource_runtime.c b/tools/crm_resource_runtime.c |
|
index d250a07..1048636 100644 |
|
--- a/tools/crm_resource_runtime.c |
|
+++ b/tools/crm_resource_runtime.c |
|
@@ -662,6 +662,24 @@ cli_resource_delete_failures(crm_ipc_t *crmd_channel, const char *host_uname, |
|
{ |
|
int rc = pcmk_ok; |
|
|
|
+ if (rsc == NULL) { |
|
+ return -ENXIO; |
|
+ |
|
+ } else if (rsc->children) { |
|
+ GListPtr lpc = NULL; |
|
+ |
|
+ for (lpc = rsc->children; lpc != NULL; lpc = lpc->next) { |
|
+ resource_t *child = (resource_t *) lpc->data; |
|
+ |
|
+ rc = cli_resource_delete_failures(crmd_channel, host_uname, child, operation, |
|
+ interval, data_set); |
|
+ if(rc != pcmk_ok) { |
|
+ return rc; |
|
+ } |
|
+ } |
|
+ return pcmk_ok; |
|
+ } |
|
+ |
|
for (xmlNode *xml_op = __xml_first_child(data_set->failed); xml_op != NULL; |
|
xml_op = __xml_next(xml_op)) { |
|
|
|
-- |
|
1.8.3.1 |
|
|
|
|