File pacemaker-pengine-improve-recurring-operation-messages.patch of Package pacemaker.19778
commit 2780a27c8f7c9098965c350b649ab41d48991818
Author: Ken Gaillot <kgaillot@redhat.com>
Date: Wed Mar 7 15:14:59 2018 -0600
Log: pengine: improve recurring operation messages
with minor refactoring for readability
Index: pacemaker-1.1.18+20180406.19c7be5c7/pengine/native.c
===================================================================
--- pacemaker-1.1.18+20180406.19c7be5c7.orig/pengine/native.c
+++ pacemaker-1.1.18+20180406.19c7be5c7/pengine/native.c
@@ -39,13 +39,14 @@ void native_rsc_colocation_rh_must(resou
void native_rsc_colocation_rh_mustnot(resource_t * rsc_lh, gboolean update_lh,
resource_t * rsc_rh, gboolean update_rh);
-void Recurring(resource_t * rsc, action_t * start, node_t * node, pe_working_set_t * data_set);
-void RecurringOp(resource_t * rsc, action_t * start, node_t * node,
- xmlNode * operation, pe_working_set_t * data_set);
-void Recurring_Stopped(resource_t * rsc, action_t * start, node_t * node,
- pe_working_set_t * data_set);
-void RecurringOp_Stopped(resource_t * rsc, action_t * start, node_t * node,
- xmlNode * operation, pe_working_set_t * data_set);
+static void Recurring(resource_t *rsc, action_t *start, node_t *node,
+ pe_working_set_t *data_set);
+static void RecurringOp(resource_t *rsc, action_t *start, node_t *node,
+ xmlNode *operation, pe_working_set_t *data_set);
+static void Recurring_Stopped(resource_t *rsc, action_t *start, node_t *node,
+ pe_working_set_t *data_set);
+static void RecurringOp_Stopped(resource_t *rsc, action_t *start, node_t *node,
+ xmlNode *operation, pe_working_set_t *data_set);
void ReloadRsc(resource_t * rsc, node_t *node, pe_working_set_t * data_set);
gboolean DeleteRsc(resource_t * rsc, node_t * node, gboolean optional, pe_working_set_t * data_set);
@@ -638,64 +639,67 @@ is_op_dup(resource_t *rsc, const char *n
return dup;
}
-void
+static bool
+op_cannot_recur(const char *name)
+{
+ return safe_str_eq(name, RSC_STOP)
+ || safe_str_eq(name, RSC_START)
+ || safe_str_eq(name, RSC_DEMOTE)
+ || safe_str_eq(name, RSC_PROMOTE);
+}
+
+static void
RecurringOp(resource_t * rsc, action_t * start, node_t * node,
xmlNode * operation, pe_working_set_t * data_set)
{
char *key = NULL;
const char *name = NULL;
- const char *value = NULL;
+ const char *role = NULL;
const char *interval = NULL;
- const char *node_uname = NULL;
+ const char *node_uname = node? node->details->uname : "n/a";
unsigned long long interval_ms = 0;
action_t *mon = NULL;
gboolean is_optional = TRUE;
GListPtr possible_matches = NULL;
- /* Only process for the operations without role="Stopped" */
- value = crm_element_value(operation, "role");
- if (value && text2role(value) == RSC_ROLE_STOPPED) {
- return;
- }
-
CRM_ASSERT(rsc);
- pe_rsc_trace(rsc, "Creating recurring action %s for %s in role %s on %s",
- ID(operation), rsc->id, role2text(rsc->next_role),
- node ? node->details->uname : "n/a");
- if (node != NULL) {
- node_uname = node->details->uname;
+ /* Only process for the operations without role="Stopped" */
+ role = crm_element_value(operation, "role");
+ if (role && text2role(role) == RSC_ROLE_STOPPED) {
+ return;
}
interval = crm_element_value(operation, XML_LRM_ATTR_INTERVAL);
interval_ms = crm_get_interval(interval);
-
if (interval_ms == 0) {
return;
}
name = crm_element_value(operation, "name");
if (is_op_dup(rsc, name, interval_ms)) {
+ crm_trace("Not creating duplicate recurring action %s for %dms %s",
+ ID(operation), interval_ms, name);
return;
}
- if (safe_str_eq(name, RSC_STOP)
- || safe_str_eq(name, RSC_START)
- || safe_str_eq(name, RSC_DEMOTE)
- || safe_str_eq(name, RSC_PROMOTE)
- ) {
+ if (op_cannot_recur(name)) {
crm_config_err("Invalid recurring action %s wth name: '%s'", ID(operation), name);
return;
}
key = generate_op_key(rsc->id, name, interval_ms);
if (find_rsc_op_entry(rsc, key) == NULL) {
- /* disabled */
+ crm_trace("Not creating recurring action %s for disabled resource %s",
+ ID(operation), rsc->id);
free(key);
return;
}
+ pe_rsc_trace(rsc, "Creating recurring action %s for %s in role %s on %s",
+ ID(operation), rsc->id, role2text(rsc->next_role), node_uname);
+
if (start != NULL) {
pe_rsc_trace(rsc, "Marking %s %s due to %s",
key, is_set(start->flags, pe_action_optional) ? "optional" : "mandatory",
@@ -726,8 +730,8 @@ RecurringOp(resource_t * rsc, action_t *
g_list_free(possible_matches);
}
- if ((rsc->next_role == RSC_ROLE_MASTER && value == NULL)
- || (value != NULL && text2role(value) != rsc->next_role)) {
+ if ((rsc->next_role == RSC_ROLE_MASTER && role == NULL)
+ || (role != NULL && text2role(role) != rsc->next_role)) {
int log_level = LOG_DEBUG_2;
const char *result = "Ignoring";
@@ -776,7 +780,7 @@ RecurringOp(resource_t * rsc, action_t *
}
do_crm_log(log_level, "%s action %s (%s vs. %s)",
- result, key, value ? value : role2text(RSC_ROLE_SLAVE),
+ result, key, role ? role : role2text(RSC_ROLE_SLAVE),
role2text(rsc->next_role));
free(key);
@@ -786,22 +790,22 @@ RecurringOp(resource_t * rsc, action_t *
mon = custom_action(rsc, key, name, node, is_optional, TRUE, data_set);
key = mon->uuid;
if (is_optional) {
- pe_rsc_trace(rsc, "%s\t %s (optional)", crm_str(node_uname), mon->uuid);
+ pe_rsc_trace(rsc, "%s\t %s (optional)", node_uname, mon->uuid);
}
if (start == NULL || is_set(start->flags, pe_action_runnable) == FALSE) {
- pe_rsc_debug(rsc, "%s\t %s (cancelled : start un-runnable)", crm_str(node_uname),
- mon->uuid);
+ pe_rsc_debug(rsc, "%s\t %s (cancelled : start un-runnable)",
+ node_uname, mon->uuid);
update_action_flags(mon, pe_action_runnable | pe_action_clear, __FUNCTION__, __LINE__);
} else if (node == NULL || node->details->online == FALSE || node->details->unclean) {
- pe_rsc_debug(rsc, "%s\t %s (cancelled : no node available)", crm_str(node_uname),
- mon->uuid);
+ pe_rsc_debug(rsc, "%s\t %s (cancelled : no node available)",
+ node_uname, mon->uuid);
update_action_flags(mon, pe_action_runnable | pe_action_clear, __FUNCTION__, __LINE__);
} else if (is_set(mon->flags, pe_action_optional) == FALSE) {
- pe_rsc_info(rsc, " Start recurring %s (%llus) for %s on %s", mon->task, interval_ms / 1000,
- rsc->id, crm_str(node_uname));
+ pe_rsc_info(rsc, " Start recurring %s (%llus) for %s on %s",
+ mon->task, interval_ms / 1000, rsc->id, node_uname);
}
if (rsc->next_role == RSC_ROLE_MASTER) {
@@ -833,7 +837,7 @@ RecurringOp(resource_t * rsc, action_t *
}
}
-void
+static void
Recurring(resource_t * rsc, action_t * start, node_t * node, pe_working_set_t * data_set)
{
if (is_not_set(rsc->flags, pe_rsc_maintenance) &&
@@ -849,7 +853,7 @@ Recurring(resource_t * rsc, action_t * s
}
}
-void
+static void
RecurringOp_Stopped(resource_t * rsc, action_t * start, node_t * node,
xmlNode * operation, pe_working_set_t * data_set)
{
@@ -857,59 +861,55 @@ RecurringOp_Stopped(resource_t * rsc, ac
const char *name = NULL;
const char *role = NULL;
const char *interval = NULL;
- const char *node_uname = NULL;
+ const char *node_uname = node? node->details->uname : "n/a";
unsigned long long interval_ms = 0;
GListPtr possible_matches = NULL;
GListPtr gIter = NULL;
- /* TODO: Support of non-unique clone */
- if (is_set(rsc->flags, pe_rsc_unique) == FALSE) {
- return;
- }
-
/* Only process for the operations with role="Stopped" */
role = crm_element_value(operation, "role");
if (role == NULL || text2role(role) != RSC_ROLE_STOPPED) {
return;
}
- pe_rsc_trace(rsc,
- "Creating recurring actions %s for %s in role %s on nodes where it'll not be running",
- ID(operation), rsc->id, role2text(rsc->next_role));
-
- if (node != NULL) {
- node_uname = node->details->uname;
- }
-
interval = crm_element_value(operation, XML_LRM_ATTR_INTERVAL);
interval_ms = crm_get_interval(interval);
-
if (interval_ms == 0) {
return;
}
name = crm_element_value(operation, "name");
if (is_op_dup(rsc, name, interval_ms)) {
+ crm_trace("Not creating duplicate recurring action %s for %dms %s",
+ ID(operation), interval_ms, name);
return;
}
- if (safe_str_eq(name, RSC_STOP)
- || safe_str_eq(name, RSC_START)
- || safe_str_eq(name, RSC_DEMOTE)
- || safe_str_eq(name, RSC_PROMOTE)
- ) {
+ if (op_cannot_recur(name)) {
crm_config_err("Invalid recurring action %s wth name: '%s'", ID(operation), name);
return;
}
key = generate_op_key(rsc->id, name, interval_ms);
if (find_rsc_op_entry(rsc, key) == NULL) {
- /* disabled */
+ crm_trace("Not creating recurring action %s for disabled resource %s",
+ ID(operation), rsc->id);
free(key);
return;
}
+ // @TODO add support
+ if (is_set(rsc->flags, pe_rsc_unique) == FALSE) {
+ crm_notice("Ignoring %s (recurring monitors for role=Stopped are not supported for anonyous clones)",
+ ID(operation));
+ return;
+ }
+
+ pe_rsc_trace(rsc,
+ "Creating recurring action %s for %s in role %s on nodes where it should not be running",
+ ID(operation), rsc->id, role2text(rsc->next_role));
+
/* if the monitor exists on the node where the resource will be running, cancel it */
if (node != NULL) {
possible_matches = find_actions_exact(rsc->actions, key, node);
@@ -938,7 +938,7 @@ RecurringOp_Stopped(resource_t * rsc, ac
}
pe_rsc_info(rsc, "Cancel action %s (%s vs. %s) on %s",
- key, role, role2text(rsc->next_role), crm_str(node_uname));
+ key, role, role2text(rsc->next_role), node_uname);
}
}
@@ -955,7 +955,7 @@ RecurringOp_Stopped(resource_t * rsc, ac
GListPtr local_gIter = NULL;
char *stop_op_key = NULL;
- if (node_uname && safe_str_eq(stop_node_uname, node_uname)) {
+ if (node && safe_str_eq(stop_node_uname, node_uname)) {
continue;
}
@@ -1057,7 +1057,7 @@ RecurringOp_Stopped(resource_t * rsc, ac
free(key);
}
-void
+static void
Recurring_Stopped(resource_t * rsc, action_t * start, node_t * node, pe_working_set_t * data_set)
{
if (is_not_set(rsc->flags, pe_rsc_maintenance) &&