summaryrefslogtreecommitdiffstats
path: root/lib/pengine/pe_actions.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pengine/pe_actions.c')
-rw-r--r--lib/pengine/pe_actions.c607
1 files changed, 285 insertions, 322 deletions
diff --git a/lib/pengine/pe_actions.c b/lib/pengine/pe_actions.c
index aaa6598..b866db6 100644
--- a/lib/pengine/pe_actions.c
+++ b/lib/pengine/pe_actions.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2023 the Pacemaker project contributors
+ * Copyright 2004-2024 the Pacemaker project contributors
*
* The version control history for this file may have further details.
*
@@ -13,7 +13,7 @@
#include <stdbool.h>
#include <crm/crm.h>
-#include <crm/msg_xml.h>
+#include <crm/common/xml.h>
#include <crm/common/scheduler_internal.h>
#include <crm/pengine/internal.h>
#include <crm/common/xml_internal.h>
@@ -87,26 +87,29 @@ static xmlNode *
find_exact_action_config(const pcmk_resource_t *rsc, const char *action_name,
guint interval_ms, bool include_disabled)
{
- for (xmlNode *operation = first_named_child(rsc->ops_xml, XML_ATTR_OP);
- operation != NULL; operation = crm_next_same_xml(operation)) {
+ for (xmlNode *operation = pcmk__xe_first_child(rsc->ops_xml, PCMK_XE_OP,
+ NULL, NULL);
+ operation != NULL; operation = pcmk__xe_next_same(operation)) {
bool enabled = false;
const char *config_name = NULL;
const char *interval_spec = NULL;
+ guint tmp_ms = 0U;
- // @TODO This does not consider rules, defaults, etc.
+ // @TODO This does not consider meta-attributes, rules, defaults, etc.
if (!include_disabled
- && (pcmk__xe_get_bool_attr(operation, "enabled",
+ && (pcmk__xe_get_bool_attr(operation, PCMK_META_ENABLED,
&enabled) == pcmk_rc_ok) && !enabled) {
continue;
}
- interval_spec = crm_element_value(operation, XML_LRM_ATTR_INTERVAL);
- if (crm_parse_interval_spec(interval_spec) != interval_ms) {
+ interval_spec = crm_element_value(operation, PCMK_META_INTERVAL);
+ pcmk_parse_interval_spec(interval_spec, &tmp_ms);
+ if (tmp_ms != interval_ms) {
continue;
}
- config_name = crm_element_value(operation, "name");
+ config_name = crm_element_value(operation, PCMK_XA_NAME);
if (pcmk__str_eq(action_name, config_name, pcmk__str_none)) {
return operation;
}
@@ -166,12 +169,10 @@ static pcmk_action_t *
new_action(char *key, const char *task, pcmk_resource_t *rsc,
const pcmk_node_t *node, bool optional, pcmk_scheduler_t *scheduler)
{
- pcmk_action_t *action = calloc(1, sizeof(pcmk_action_t));
-
- CRM_ASSERT(action != NULL);
+ pcmk_action_t *action = pcmk__assert_alloc(1, sizeof(pcmk_action_t));
action->rsc = rsc;
- action->task = strdup(task); CRM_ASSERT(action->task != NULL);
+ action->task = pcmk__str_copy(task);
action->uuid = key;
if (node) {
@@ -180,14 +181,14 @@ new_action(char *key, const char *task, pcmk_resource_t *rsc,
if (pcmk__str_eq(task, PCMK_ACTION_LRM_DELETE, pcmk__str_casei)) {
// Resource history deletion for a node can be done on the DC
- pe__set_action_flags(action, pcmk_action_on_dc);
+ pcmk__set_action_flags(action, pcmk_action_on_dc);
}
- pe__set_action_flags(action, pcmk_action_runnable);
+ pcmk__set_action_flags(action, pcmk_action_runnable);
if (optional) {
- pe__set_action_flags(action, pcmk_action_optional);
+ pcmk__set_action_flags(action, pcmk_action_optional);
} else {
- pe__clear_action_flags(action, pcmk_action_optional);
+ pcmk__clear_action_flags(action, pcmk_action_optional);
}
if (rsc == NULL) {
@@ -210,11 +211,11 @@ new_action(char *key, const char *task, pcmk_resource_t *rsc,
unpack_operation(action, action->op_entry, interval_ms);
}
- pe_rsc_trace(rsc, "Created %s action %d (%s): %s for %s on %s",
- (optional? "optional" : "required"),
- scheduler->action_id, key, task,
- ((rsc == NULL)? "no resource" : rsc->id),
- pe__node_name(node));
+ pcmk__rsc_trace(rsc, "Created %s action %d (%s): %s for %s on %s",
+ (optional? "optional" : "required"),
+ scheduler->action_id, key, task,
+ ((rsc == NULL)? "no resource" : rsc->id),
+ pcmk__node_name(node));
action->id = scheduler->action_id++;
scheduler->actions = g_list_prepend(scheduler->actions, action);
@@ -245,14 +246,13 @@ pcmk__unpack_action_rsc_params(const xmlNode *action_xml,
pe_rule_eval_data_t rule_data = {
.node_hash = node_attrs,
- .role = pcmk_role_unknown,
.now = scheduler->now,
.match_data = NULL,
.rsc_data = NULL,
.op_data = NULL
};
- pe__unpack_dataset_nvpairs(action_xml, XML_TAG_ATTR_SETS,
+ pe__unpack_dataset_nvpairs(action_xml, PCMK_XE_INSTANCE_ATTRIBUTES,
&rule_data, params, NULL,
FALSE, scheduler);
return params;
@@ -272,17 +272,17 @@ update_action_optional(pcmk_action_t *action, gboolean optional)
if ((action->rsc != NULL) && (action->node != NULL)
&& !pcmk_is_set(action->flags, pcmk_action_pseudo)
&& !pcmk_is_set(action->rsc->flags, pcmk_rsc_managed)
- && (g_hash_table_lookup(action->meta,
- XML_LRM_ATTR_INTERVAL_MS) == NULL)) {
- pe_rsc_debug(action->rsc, "%s on %s is optional (%s is unmanaged)",
- action->uuid, pe__node_name(action->node),
- action->rsc->id);
- pe__set_action_flags(action, pcmk_action_optional);
+ && (g_hash_table_lookup(action->meta, PCMK_META_INTERVAL) == NULL)) {
+ pcmk__rsc_debug(action->rsc,
+ "%s on %s is optional (%s is unmanaged)",
+ action->uuid, pcmk__node_name(action->node),
+ action->rsc->id);
+ pcmk__set_action_flags(action, pcmk_action_optional);
// We shouldn't clear runnable here because ... something
// Otherwise require the action if requested
} else if (!optional) {
- pe__clear_action_flags(action, pcmk_action_optional);
+ pcmk__clear_action_flags(action, pcmk_action_optional);
}
}
@@ -300,7 +300,7 @@ effective_quorum_policy(pcmk_resource_t *rsc, pcmk_scheduler_t *scheduler)
case pcmk_role_unpromoted:
if (rsc->next_role > pcmk_role_unpromoted) {
pe__set_next_role(rsc, pcmk_role_unpromoted,
- "no-quorum-policy=demote");
+ PCMK_OPT_NO_QUORUM_POLICY "=demote");
}
policy = pcmk_no_quorum_ignore;
break;
@@ -330,17 +330,17 @@ update_resource_action_runnable(pcmk_action_t *action,
}
if (action->node == NULL) {
- pe_rsc_trace(action->rsc, "%s is unrunnable (unallocated)",
- action->uuid);
- pe__clear_action_flags(action, pcmk_action_runnable);
+ pcmk__rsc_trace(action->rsc, "%s is unrunnable (unallocated)",
+ action->uuid);
+ pcmk__clear_action_flags(action, pcmk_action_runnable);
} else if (!pcmk_is_set(action->flags, pcmk_action_on_dc)
&& !(action->node->details->online)
- && (!pe__is_guest_node(action->node)
+ && (!pcmk__is_guest_or_bundle_node(action->node)
|| action->node->details->remote_requires_reset)) {
- pe__clear_action_flags(action, pcmk_action_runnable);
+ pcmk__clear_action_flags(action, pcmk_action_runnable);
do_crm_log(LOG_WARNING, "%s on %s is unrunnable (node is offline)",
- action->uuid, pe__node_name(action->node));
+ action->uuid, pcmk__node_name(action->node));
if (pcmk_is_set(action->rsc->flags, pcmk_rsc_managed)
&& pcmk__str_eq(action->task, PCMK_ACTION_STOP, pcmk__str_casei)
&& !(action->node->details->unclean)) {
@@ -349,54 +349,57 @@ update_resource_action_runnable(pcmk_action_t *action,
} else if (!pcmk_is_set(action->flags, pcmk_action_on_dc)
&& action->node->details->pending) {
- pe__clear_action_flags(action, pcmk_action_runnable);
+ pcmk__clear_action_flags(action, pcmk_action_runnable);
do_crm_log(LOG_WARNING,
"Action %s on %s is unrunnable (node is pending)",
- action->uuid, pe__node_name(action->node));
+ action->uuid, pcmk__node_name(action->node));
} else if (action->needs == pcmk_requires_nothing) {
pe_action_set_reason(action, NULL, TRUE);
- if (pe__is_guest_node(action->node)
+ if (pcmk__is_guest_or_bundle_node(action->node)
&& !pe_can_fence(scheduler, action->node)) {
/* An action that requires nothing usually does not require any
* fencing in order to be runnable. However, there is an exception:
* such an action cannot be completed if it is on a guest node whose
* host is unclean and cannot be fenced.
*/
- pe_rsc_debug(action->rsc, "%s on %s is unrunnable "
- "(node's host cannot be fenced)",
- action->uuid, pe__node_name(action->node));
- pe__clear_action_flags(action, pcmk_action_runnable);
+ pcmk__rsc_debug(action->rsc,
+ "%s on %s is unrunnable "
+ "(node's host cannot be fenced)",
+ action->uuid, pcmk__node_name(action->node));
+ pcmk__clear_action_flags(action, pcmk_action_runnable);
} else {
- pe_rsc_trace(action->rsc,
- "%s on %s does not require fencing or quorum",
- action->uuid, pe__node_name(action->node));
- pe__set_action_flags(action, pcmk_action_runnable);
+ pcmk__rsc_trace(action->rsc,
+ "%s on %s does not require fencing or quorum",
+ action->uuid, pcmk__node_name(action->node));
+ pcmk__set_action_flags(action, pcmk_action_runnable);
}
} else {
switch (effective_quorum_policy(action->rsc, scheduler)) {
case pcmk_no_quorum_stop:
- pe_rsc_debug(action->rsc, "%s on %s is unrunnable (no quorum)",
- action->uuid, pe__node_name(action->node));
- pe__clear_action_flags(action, pcmk_action_runnable);
+ pcmk__rsc_debug(action->rsc,
+ "%s on %s is unrunnable (no quorum)",
+ action->uuid, pcmk__node_name(action->node));
+ pcmk__clear_action_flags(action, pcmk_action_runnable);
pe_action_set_reason(action, "no quorum", true);
break;
case pcmk_no_quorum_freeze:
if (!action->rsc->fns->active(action->rsc, TRUE)
|| (action->rsc->next_role > action->rsc->role)) {
- pe_rsc_debug(action->rsc,
- "%s on %s is unrunnable (no quorum)",
- action->uuid, pe__node_name(action->node));
- pe__clear_action_flags(action, pcmk_action_runnable);
+ pcmk__rsc_debug(action->rsc,
+ "%s on %s is unrunnable (no quorum)",
+ action->uuid,
+ pcmk__node_name(action->node));
+ pcmk__clear_action_flags(action, pcmk_action_runnable);
pe_action_set_reason(action, "quorum freeze", true);
}
break;
default:
//pe_action_set_reason(action, NULL, TRUE);
- pe__set_action_flags(action, pcmk_action_runnable);
+ pcmk__set_action_flags(action, pcmk_action_runnable);
break;
}
}
@@ -417,13 +420,13 @@ update_resource_flags_for_action(pcmk_resource_t *rsc,
* within Pacemaker, and will eventually be removed
*/
if (pcmk__str_eq(action->task, PCMK_ACTION_STOP, pcmk__str_casei)) {
- pe__set_resource_flags(rsc, pcmk_rsc_stopping);
+ pcmk__set_rsc_flags(rsc, pcmk_rsc_stopping);
} else if (pcmk__str_eq(action->task, PCMK_ACTION_START, pcmk__str_casei)) {
if (pcmk_is_set(action->flags, pcmk_action_runnable)) {
- pe__set_resource_flags(rsc, pcmk_rsc_starting);
+ pcmk__set_rsc_flags(rsc, pcmk_rsc_starting);
} else {
- pe__clear_resource_flags(rsc, pcmk_rsc_starting);
+ pcmk__clear_rsc_flags(rsc, pcmk_rsc_starting);
}
}
}
@@ -431,7 +434,9 @@ update_resource_flags_for_action(pcmk_resource_t *rsc,
static bool
valid_stop_on_fail(const char *value)
{
- return !pcmk__strcase_any_of(value, "standby", "demote", "stop", NULL);
+ return !pcmk__strcase_any_of(value,
+ PCMK_VALUE_STANDBY, PCMK_VALUE_DEMOTE,
+ PCMK_VALUE_STOP, NULL);
}
/*!
@@ -450,18 +455,17 @@ validate_on_fail(const pcmk_resource_t *rsc, const char *action_name,
const char *name = NULL;
const char *role = NULL;
const char *interval_spec = NULL;
- const char *value = g_hash_table_lookup(meta, XML_OP_ATTR_ON_FAIL);
- char *key = NULL;
- char *new_value = NULL;
+ const char *value = g_hash_table_lookup(meta, PCMK_META_ON_FAIL);
+ guint interval_ms = 0U;
// Stop actions can only use certain on-fail values
if (pcmk__str_eq(action_name, PCMK_ACTION_STOP, pcmk__str_none)
&& !valid_stop_on_fail(value)) {
- pcmk__config_err("Resetting '" XML_OP_ATTR_ON_FAIL "' for %s stop "
+ pcmk__config_err("Resetting '" PCMK_META_ON_FAIL "' for %s stop "
"action to default value because '%s' is not "
"allowed for stop", rsc->id, value);
- g_hash_table_remove(meta, XML_OP_ATTR_ON_FAIL);
+ g_hash_table_remove(meta, PCMK_META_ON_FAIL);
return;
}
@@ -475,77 +479,79 @@ validate_on_fail(const pcmk_resource_t *rsc, const char *action_name,
* block (which may have rules that need to be evaluated) rather than
* XML properties.
*/
- for (xmlNode *operation = first_named_child(rsc->ops_xml, XML_ATTR_OP);
- operation != NULL; operation = crm_next_same_xml(operation)) {
+ for (xmlNode *operation = pcmk__xe_first_child(rsc->ops_xml, PCMK_XE_OP,
+ NULL, NULL);
+ operation != NULL; operation = pcmk__xe_next_same(operation)) {
+
bool enabled = false;
const char *promote_on_fail = NULL;
/* We only care about explicit on-fail (if promote uses default, so
* can demote)
*/
- promote_on_fail = crm_element_value(operation, XML_OP_ATTR_ON_FAIL);
+ promote_on_fail = crm_element_value(operation, PCMK_META_ON_FAIL);
if (promote_on_fail == NULL) {
continue;
}
// We only care about recurring monitors for the promoted role
- name = crm_element_value(operation, "name");
- role = crm_element_value(operation, "role");
+ name = crm_element_value(operation, PCMK_XA_NAME);
+ role = crm_element_value(operation, PCMK_XA_ROLE);
if (!pcmk__str_eq(name, PCMK_ACTION_MONITOR, pcmk__str_none)
- || !pcmk__strcase_any_of(role, PCMK__ROLE_PROMOTED,
+ || !pcmk__strcase_any_of(role, PCMK_ROLE_PROMOTED,
PCMK__ROLE_PROMOTED_LEGACY, NULL)) {
continue;
}
- interval_spec = crm_element_value(operation, XML_LRM_ATTR_INTERVAL);
- if (crm_parse_interval_spec(interval_spec) == 0) {
+ interval_spec = crm_element_value(operation, PCMK_META_INTERVAL);
+ pcmk_parse_interval_spec(interval_spec, &interval_ms);
+ if (interval_ms == 0U) {
continue;
}
// We only care about enabled monitors
- if ((pcmk__xe_get_bool_attr(operation, "enabled",
+ if ((pcmk__xe_get_bool_attr(operation, PCMK_META_ENABLED,
&enabled) == pcmk_rc_ok) && !enabled) {
continue;
}
- // Demote actions can't default to on-fail="demote"
- if (pcmk__str_eq(promote_on_fail, "demote", pcmk__str_casei)) {
+ /* Demote actions can't default to
+ * PCMK_META_ON_FAIL=PCMK_VALUE_DEMOTE
+ */
+ if (pcmk__str_eq(promote_on_fail, PCMK_VALUE_DEMOTE,
+ pcmk__str_casei)) {
continue;
}
// Use value from first applicable promote action found
- key = strdup(XML_OP_ATTR_ON_FAIL);
- new_value = strdup(promote_on_fail);
- CRM_ASSERT((key != NULL) && (new_value != NULL));
- g_hash_table_insert(meta, key, new_value);
+ pcmk__insert_dup(meta, PCMK_META_ON_FAIL, promote_on_fail);
}
return;
}
if (pcmk__str_eq(action_name, PCMK_ACTION_LRM_DELETE, pcmk__str_none)
- && !pcmk__str_eq(value, "ignore", pcmk__str_casei)) {
- key = strdup(XML_OP_ATTR_ON_FAIL);
- new_value = strdup("ignore");
- CRM_ASSERT((key != NULL) && (new_value != NULL));
- g_hash_table_insert(meta, key, new_value);
+ && !pcmk__str_eq(value, PCMK_VALUE_IGNORE, pcmk__str_casei)) {
+
+ pcmk__insert_dup(meta, PCMK_META_ON_FAIL, PCMK_VALUE_IGNORE);
return;
}
- // on-fail="demote" is allowed only for certain actions
- if (pcmk__str_eq(value, "demote", pcmk__str_casei)) {
- name = crm_element_value(action_config, "name");
- role = crm_element_value(action_config, "role");
- interval_spec = crm_element_value(action_config,
- XML_LRM_ATTR_INTERVAL);
+ // PCMK_META_ON_FAIL=PCMK_VALUE_DEMOTE is allowed only for certain actions
+ if (pcmk__str_eq(value, PCMK_VALUE_DEMOTE, pcmk__str_casei)) {
+ name = crm_element_value(action_config, PCMK_XA_NAME);
+ role = crm_element_value(action_config, PCMK_XA_ROLE);
+ interval_spec = crm_element_value(action_config, PCMK_META_INTERVAL);
+ pcmk_parse_interval_spec(interval_spec, &interval_ms);
if (!pcmk__str_eq(name, PCMK_ACTION_PROMOTE, pcmk__str_none)
- && (!pcmk__str_eq(name, PCMK_ACTION_MONITOR, pcmk__str_none)
- || !pcmk__strcase_any_of(role, PCMK__ROLE_PROMOTED,
- PCMK__ROLE_PROMOTED_LEGACY, NULL)
- || (crm_parse_interval_spec(interval_spec) == 0))) {
- pcmk__config_err("Resetting '" XML_OP_ATTR_ON_FAIL "' for %s %s "
+ && ((interval_ms == 0U)
+ || !pcmk__str_eq(name, PCMK_ACTION_MONITOR, pcmk__str_none)
+ || !pcmk__strcase_any_of(role, PCMK_ROLE_PROMOTED,
+ PCMK__ROLE_PROMOTED_LEGACY, NULL))) {
+
+ pcmk__config_err("Resetting '" PCMK_META_ON_FAIL "' for %s %s "
"action to default value because 'demote' is not "
"allowed for it", rsc->id, name);
- g_hash_table_remove(meta, XML_OP_ATTR_ON_FAIL);
+ g_hash_table_remove(meta, PCMK_META_ON_FAIL);
return;
}
}
@@ -554,12 +560,12 @@ validate_on_fail(const pcmk_resource_t *rsc, const char *action_name,
static int
unpack_timeout(const char *value)
{
- int timeout_ms = crm_get_msec(value);
+ long long timeout_ms = crm_get_msec(value);
- if (timeout_ms < 0) {
+ if (timeout_ms <= 0) {
timeout_ms = PCMK_DEFAULT_ACTION_TIMEOUT_MS;
}
- return timeout_ms;
+ return (int) QB_MIN(timeout_ms, INT_MAX);
}
// true if value contains valid, non-NULL interval origin for recurring op
@@ -580,9 +586,9 @@ unpack_interval_origin(const char *value, const xmlNode *xml_obj,
// Parse interval origin from text
origin = crm_time_new(value);
if (origin == NULL) {
- pcmk__config_err("Ignoring '" XML_OP_ATTR_ORIGIN "' for operation "
- "'%s' because '%s' is not valid",
- (ID(xml_obj)? ID(xml_obj) : "(missing ID)"), value);
+ pcmk__config_err("Ignoring '" PCMK_META_INTERVAL_ORIGIN "' for "
+ "operation '%s' because '%s' is not valid",
+ pcmk__s(pcmk__xe_id(xml_obj), "(missing ID)"), value);
return false;
}
@@ -596,8 +602,7 @@ unpack_interval_origin(const char *value, const xmlNode *xml_obj,
// Calculate seconds remaining until next interval
result = ((result <= 0)? 0 : interval_sec) - result;
crm_info("Calculated a start delay of %llds for operation '%s'",
- result,
- (ID(xml_obj)? ID(xml_obj) : "(unspecified)"));
+ result, pcmk__s(pcmk__xe_id(xml_obj), "(unspecified)"));
if (start_delay != NULL) {
*start_delay = result * 1000; // milliseconds
@@ -608,22 +613,24 @@ unpack_interval_origin(const char *value, const xmlNode *xml_obj,
static int
unpack_start_delay(const char *value, GHashTable *meta)
{
- int start_delay = 0;
+ long long start_delay_ms = 0;
- if (value != NULL) {
- start_delay = crm_get_msec(value);
+ if (value == NULL) {
+ return 0;
+ }
- if (start_delay < 0) {
- start_delay = 0;
- }
+ start_delay_ms = crm_get_msec(value);
+ start_delay_ms = QB_MIN(start_delay_ms, INT_MAX);
+ if (start_delay_ms < 0) {
+ start_delay_ms = 0;
+ }
- if (meta) {
- g_hash_table_replace(meta, strdup(XML_OP_ATTR_START_DELAY),
- pcmk__itoa(start_delay));
- }
+ if (meta != NULL) {
+ g_hash_table_replace(meta, strdup(PCMK_META_START_DELAY),
+ pcmk__itoa(start_delay_ms));
}
- return start_delay;
+ return (int) start_delay_ms;
}
/*!
@@ -641,25 +648,28 @@ most_frequent_monitor(const pcmk_resource_t *rsc)
guint min_interval_ms = G_MAXUINT;
xmlNode *op = NULL;
- for (xmlNode *operation = first_named_child(rsc->ops_xml, XML_ATTR_OP);
- operation != NULL; operation = crm_next_same_xml(operation)) {
+ for (xmlNode *operation = pcmk__xe_first_child(rsc->ops_xml, PCMK_XE_OP,
+ NULL, NULL);
+ operation != NULL; operation = pcmk__xe_next_same(operation)) {
+
bool enabled = false;
- guint interval_ms = 0;
+ guint interval_ms = 0U;
const char *interval_spec = crm_element_value(operation,
- XML_LRM_ATTR_INTERVAL);
+ PCMK_META_INTERVAL);
// We only care about enabled recurring monitors
- if (!pcmk__str_eq(crm_element_value(operation, "name"),
+ if (!pcmk__str_eq(crm_element_value(operation, PCMK_XA_NAME),
PCMK_ACTION_MONITOR, pcmk__str_none)) {
continue;
}
- interval_ms = crm_parse_interval_spec(interval_spec);
- if (interval_ms == 0) {
+
+ pcmk_parse_interval_spec(interval_spec, &interval_ms);
+ if (interval_ms == 0U) {
continue;
}
- // @TODO This does not account for rules, defaults, etc.
- if ((pcmk__xe_get_bool_attr(operation, "enabled",
+ // @TODO This does not consider meta-attributes, rules, defaults, etc.
+ if ((pcmk__xe_get_bool_attr(operation, PCMK_META_ENABLED,
&enabled) == pcmk_rc_ok) && !enabled) {
continue;
}
@@ -694,15 +704,13 @@ pcmk__unpack_action_meta(pcmk_resource_t *rsc, const pcmk_node_t *node,
const xmlNode *action_config)
{
GHashTable *meta = NULL;
- char *name = NULL;
- char *value = NULL;
const char *timeout_spec = NULL;
const char *str = NULL;
pe_rsc_eval_data_t rsc_rule_data = {
- .standard = crm_element_value(rsc->xml, XML_AGENT_ATTR_CLASS),
- .provider = crm_element_value(rsc->xml, XML_AGENT_ATTR_PROVIDER),
- .agent = crm_element_value(rsc->xml, XML_EXPR_ATTR_TYPE),
+ .standard = crm_element_value(rsc->xml, PCMK_XA_CLASS),
+ .provider = crm_element_value(rsc->xml, PCMK_XA_PROVIDER),
+ .agent = crm_element_value(rsc->xml, PCMK_XA_TYPE),
};
pe_op_eval_data_t op_rule_data = {
@@ -711,8 +719,13 @@ pcmk__unpack_action_meta(pcmk_resource_t *rsc, const pcmk_node_t *node,
};
pe_rule_eval_data_t rule_data = {
+ /* @COMPAT Support for node attribute expressions in operation
+ * meta-attributes (whether in the operation configuration or operation
+ * defaults) is deprecated. When we can break behavioral backward
+ * compatibility, drop this line.
+ */
.node_hash = (node == NULL)? NULL : node->details->attrs,
- .role = pcmk_role_unknown,
+
.now = rsc->cluster->now,
.match_data = NULL,
.rsc_data = &rsc_rule_data,
@@ -722,36 +735,35 @@ pcmk__unpack_action_meta(pcmk_resource_t *rsc, const pcmk_node_t *node,
meta = pcmk__strkey_table(free, free);
// Cluster-wide <op_defaults> <meta_attributes>
- pe__unpack_dataset_nvpairs(rsc->cluster->op_defaults, XML_TAG_META_SETS,
- &rule_data, meta, NULL, FALSE, rsc->cluster);
+ pe__unpack_dataset_nvpairs(rsc->cluster->op_defaults,
+ PCMK_XE_META_ATTRIBUTES, &rule_data, meta, NULL,
+ FALSE, rsc->cluster);
// Derive default timeout for probes from recurring monitor timeouts
if (pcmk_is_probe(action_name, interval_ms)) {
xmlNode *min_interval_mon = most_frequent_monitor(rsc);
if (min_interval_mon != NULL) {
- /* @TODO This does not consider timeouts set in meta_attributes
- * blocks (which may also have rules that need to be evaluated).
+ /* @TODO This does not consider timeouts set in
+ * PCMK_XE_META_ATTRIBUTES blocks (which may also have rules that
+ * need to be evaluated).
*/
timeout_spec = crm_element_value(min_interval_mon,
- XML_ATTR_TIMEOUT);
+ PCMK_META_TIMEOUT);
if (timeout_spec != NULL) {
- pe_rsc_trace(rsc,
- "Setting default timeout for %s probe to "
- "most frequent monitor's timeout '%s'",
- rsc->id, timeout_spec);
- name = strdup(XML_ATTR_TIMEOUT);
- value = strdup(timeout_spec);
- CRM_ASSERT((name != NULL) && (value != NULL));
- g_hash_table_insert(meta, name, value);
+ pcmk__rsc_trace(rsc,
+ "Setting default timeout for %s probe to "
+ "most frequent monitor's timeout '%s'",
+ rsc->id, timeout_spec);
+ pcmk__insert_dup(meta, PCMK_META_TIMEOUT, timeout_spec);
}
}
}
if (action_config != NULL) {
// <op> <meta_attributes> take precedence over defaults
- pe__unpack_dataset_nvpairs(action_config, XML_TAG_META_SETS, &rule_data,
- meta, NULL, TRUE, rsc->cluster);
+ pe__unpack_dataset_nvpairs(action_config, PCMK_XE_META_ATTRIBUTES,
+ &rule_data, meta, NULL, TRUE, rsc->cluster);
/* Anything set as an <op> XML property has highest precedence.
* This ensures we use the name and interval from the <op> tag.
@@ -759,24 +771,19 @@ pcmk__unpack_action_meta(pcmk_resource_t *rsc, const pcmk_node_t *node,
*/
for (xmlAttrPtr attr = action_config->properties;
attr != NULL; attr = attr->next) {
- name = strdup((const char *) attr->name);
- value = strdup(pcmk__xml_attr_value(attr));
-
- CRM_ASSERT((name != NULL) && (value != NULL));
- g_hash_table_insert(meta, name, value);
+ pcmk__insert_dup(meta, (const char *) attr->name,
+ pcmk__xml_attr_value(attr));
}
}
- g_hash_table_remove(meta, XML_ATTR_ID);
+ g_hash_table_remove(meta, PCMK_XA_ID);
// Normalize interval to milliseconds
if (interval_ms > 0) {
- name = strdup(XML_LRM_ATTR_INTERVAL);
- CRM_ASSERT(name != NULL);
- value = crm_strdup_printf("%u", interval_ms);
- g_hash_table_insert(meta, name, value);
+ g_hash_table_insert(meta, pcmk__str_copy(PCMK_META_INTERVAL),
+ crm_strdup_printf("%u", interval_ms));
} else {
- g_hash_table_remove(meta, XML_LRM_ATTR_INTERVAL);
+ g_hash_table_remove(meta, PCMK_META_INTERVAL);
}
/* Timeout order of precedence (highest to lowest):
@@ -799,39 +806,33 @@ pcmk__unpack_action_meta(pcmk_resource_t *rsc, const pcmk_node_t *node,
timeout_spec = g_hash_table_lookup(params, "pcmk_monitor_timeout");
if (timeout_spec != NULL) {
- pe_rsc_trace(rsc,
- "Setting timeout for %s %s to "
- "pcmk_monitor_timeout (%s)",
- rsc->id, action_name, timeout_spec);
- name = strdup(XML_ATTR_TIMEOUT);
- value = strdup(timeout_spec);
- CRM_ASSERT((name != NULL) && (value != NULL));
- g_hash_table_insert(meta, name, value);
+ pcmk__rsc_trace(rsc,
+ "Setting timeout for %s %s to "
+ "pcmk_monitor_timeout (%s)",
+ rsc->id, action_name, timeout_spec);
+ pcmk__insert_dup(meta, PCMK_META_TIMEOUT, timeout_spec);
}
}
// Normalize timeout to positive milliseconds
- name = strdup(XML_ATTR_TIMEOUT);
- CRM_ASSERT(name != NULL);
- timeout_spec = g_hash_table_lookup(meta, XML_ATTR_TIMEOUT);
- g_hash_table_insert(meta, name, pcmk__itoa(unpack_timeout(timeout_spec)));
+ timeout_spec = g_hash_table_lookup(meta, PCMK_META_TIMEOUT);
+ g_hash_table_insert(meta, pcmk__str_copy(PCMK_META_TIMEOUT),
+ pcmk__itoa(unpack_timeout(timeout_spec)));
// Ensure on-fail has a valid value
validate_on_fail(rsc, action_name, action_config, meta);
- // Normalize start-delay
- str = g_hash_table_lookup(meta, XML_OP_ATTR_START_DELAY);
+ // Normalize PCMK_META_START_DELAY
+ str = g_hash_table_lookup(meta, PCMK_META_START_DELAY);
if (str != NULL) {
unpack_start_delay(str, meta);
} else {
long long start_delay = 0;
- str = g_hash_table_lookup(meta, XML_OP_ATTR_ORIGIN);
+ str = g_hash_table_lookup(meta, PCMK_META_INTERVAL_ORIGIN);
if (unpack_interval_origin(str, action_config, interval_ms,
rsc->cluster->now, &start_delay)) {
- name = strdup(XML_OP_ATTR_START_DELAY);
- CRM_ASSERT(name != NULL);
- g_hash_table_insert(meta, name,
+ g_hash_table_insert(meta, pcmk__str_copy(PCMK_META_START_DELAY),
crm_strdup_printf("%lld", start_delay));
}
}
@@ -870,7 +871,7 @@ pcmk__action_requires(const pcmk_resource_t *rsc, const char *action_name)
} else {
value = "nothing";
}
- pe_rsc_trace(rsc, "%s of %s requires %s", action_name, rsc->id, value);
+ pcmk__rsc_trace(rsc, "%s of %s requires %s", action_name, rsc->id, value);
return requires;
}
@@ -893,19 +894,22 @@ pcmk__parse_on_fail(const pcmk_resource_t *rsc, const char *action_name,
bool needs_remote_reset = false;
enum action_fail_response on_fail = pcmk_on_fail_ignore;
+ // There's no enum value for unknown or invalid, so assert
+ CRM_ASSERT((rsc != NULL) && (action_name != NULL));
+
if (value == NULL) {
// Use default
- } else if (pcmk__str_eq(value, "block", pcmk__str_casei)) {
+ } else if (pcmk__str_eq(value, PCMK_VALUE_BLOCK, pcmk__str_casei)) {
on_fail = pcmk_on_fail_block;
desc = "block";
- } else if (pcmk__str_eq(value, "fence", pcmk__str_casei)) {
+ } else if (pcmk__str_eq(value, PCMK_VALUE_FENCE, pcmk__str_casei)) {
if (pcmk_is_set(rsc->cluster->flags, pcmk_sched_fencing_enabled)) {
on_fail = pcmk_on_fail_fence_node;
desc = "node fencing";
} else {
- pcmk__config_err("Resetting '" XML_OP_ATTR_ON_FAIL "' for "
+ pcmk__config_err("Resetting '" PCMK_META_ON_FAIL "' for "
"%s of %s to 'stop' because 'fence' is not "
"valid when fencing is disabled",
action_name, rsc->id);
@@ -913,11 +917,12 @@ pcmk__parse_on_fail(const pcmk_resource_t *rsc, const char *action_name,
desc = "stop resource";
}
- } else if (pcmk__str_eq(value, "standby", pcmk__str_casei)) {
+ } else if (pcmk__str_eq(value, PCMK_VALUE_STANDBY, pcmk__str_casei)) {
on_fail = pcmk_on_fail_standby_node;
desc = "node standby";
- } else if (pcmk__strcase_any_of(value, "ignore", PCMK__VALUE_NOTHING,
+ } else if (pcmk__strcase_any_of(value,
+ PCMK_VALUE_IGNORE, PCMK_VALUE_NOTHING,
NULL)) {
desc = "ignore";
@@ -925,31 +930,32 @@ pcmk__parse_on_fail(const pcmk_resource_t *rsc, const char *action_name,
on_fail = pcmk_on_fail_ban;
desc = "force migration";
- } else if (pcmk__str_eq(value, "stop", pcmk__str_casei)) {
+ } else if (pcmk__str_eq(value, PCMK_VALUE_STOP, pcmk__str_casei)) {
on_fail = pcmk_on_fail_stop;
desc = "stop resource";
- } else if (pcmk__str_eq(value, "restart", pcmk__str_casei)) {
+ } else if (pcmk__str_eq(value, PCMK_VALUE_RESTART, pcmk__str_casei)) {
on_fail = pcmk_on_fail_restart;
desc = "restart (and possibly migrate)";
- } else if (pcmk__str_eq(value, "restart-container", pcmk__str_casei)) {
+ } else if (pcmk__str_eq(value, PCMK_VALUE_RESTART_CONTAINER,
+ pcmk__str_casei)) {
if (rsc->container == NULL) {
- pe_rsc_debug(rsc,
- "Using default " XML_OP_ATTR_ON_FAIL
- " for %s of %s because it does not have a container",
- action_name, rsc->id);
+ pcmk__rsc_debug(rsc,
+ "Using default " PCMK_META_ON_FAIL " for %s "
+ "of %s because it does not have a container",
+ action_name, rsc->id);
} else {
on_fail = pcmk_on_fail_restart_container;
desc = "restart container (and possibly migrate)";
}
- } else if (pcmk__str_eq(value, "demote", pcmk__str_casei)) {
+ } else if (pcmk__str_eq(value, PCMK_VALUE_DEMOTE, pcmk__str_casei)) {
on_fail = pcmk_on_fail_demote;
desc = "demote instance";
} else {
- pcmk__config_err("Using default '" XML_OP_ATTR_ON_FAIL "' for "
+ pcmk__config_err("Using default '" PCMK_META_ON_FAIL "' for "
"%s of %s because '%s' is not valid",
action_name, rsc->id, value);
}
@@ -957,9 +963,10 @@ pcmk__parse_on_fail(const pcmk_resource_t *rsc, const char *action_name,
/* Remote node connections are handled specially. Failures that result
* in dropping an active connection must result in fencing. The only
* failures that don't are probes and starts. The user can explicitly set
- * on-fail="fence" to fence after start failures.
+ * PCMK_META_ON_FAIL=PCMK_VALUE_FENCE to fence after start failures.
*/
- if (pe__resource_is_remote_conn(rsc)
+ if (rsc->is_remote_node
+ && pcmk__is_remote_node(pcmk_find_node(rsc->cluster, rsc->id))
&& !pcmk_is_probe(action_name, interval_ms)
&& !pcmk__str_eq(action_name, PCMK_ACTION_START, pcmk__str_none)) {
needs_remote_reset = true;
@@ -1003,9 +1010,9 @@ pcmk__parse_on_fail(const pcmk_resource_t *rsc, const char *action_name,
desc = "restart (and possibly migrate) (default)";
}
- pe_rsc_trace(rsc, "Failure handling for %s-interval %s of %s: %s",
- pcmk__readable_interval(interval_ms), action_name,
- rsc->id, desc);
+ pcmk__rsc_trace(rsc, "Failure handling for %s-interval %s of %s: %s",
+ pcmk__readable_interval(interval_ms), action_name,
+ rsc->id, desc);
return on_fail;
}
@@ -1044,13 +1051,18 @@ pcmk__role_after_failure(const pcmk_resource_t *rsc, const char *action_name,
}
// @COMPAT Check for explicitly configured role (deprecated)
- value = g_hash_table_lookup(meta, "role_after_failure");
+ value = g_hash_table_lookup(meta, PCMK__META_ROLE_AFTER_FAILURE);
if (value != NULL) {
- pe_warn_once(pcmk__wo_role_after,
- "Support for role_after_failure is deprecated "
- "and will be removed in a future release");
+ pcmk__warn_once(pcmk__wo_role_after,
+ "Support for " PCMK__META_ROLE_AFTER_FAILURE " is "
+ "deprecated and will be removed in a future release");
if (role == pcmk_role_unknown) {
- role = text2role(value);
+ role = pcmk_parse_role(value);
+ if (role == pcmk_role_unknown) {
+ pcmk__config_err("Ignoring invalid value %s for "
+ PCMK__META_ROLE_AFTER_FAILURE,
+ value);
+ }
}
}
@@ -1062,8 +1074,8 @@ pcmk__role_after_failure(const pcmk_resource_t *rsc, const char *action_name,
role = pcmk_role_started;
}
}
- pe_rsc_trace(rsc, "Role after %s %s failure is: %s",
- rsc->id, action_name, role2text(role));
+ pcmk__rsc_trace(rsc, "Role after %s %s failure is: %s",
+ rsc->id, action_name, pcmk_role_text(role));
return role;
}
@@ -1089,7 +1101,7 @@ unpack_operation(pcmk_action_t *action, const xmlNode *xml_obj,
action->task, interval_ms, xml_obj);
action->needs = pcmk__action_requires(action->rsc, action->task);
- value = g_hash_table_lookup(action->meta, XML_OP_ATTR_ON_FAIL);
+ value = g_hash_table_lookup(action->meta, PCMK_META_ON_FAIL);
action->on_fail = pcmk__parse_on_fail(action->rsc, action->task,
interval_ms, value);
@@ -1132,6 +1144,11 @@ custom_action(pcmk_resource_t *rsc, char *key, const char *task,
update_action_optional(action, optional);
if (rsc != NULL) {
+ /* An action can be initially created with a NULL node, and later have
+ * the node added via find_existing_action() (above) -> find_actions().
+ * That is why the extra parameters are unpacked here rather than in
+ * new_action().
+ */
if ((action->node != NULL) && (action->op_entry != NULL)
&& !pcmk_is_set(action->flags, pcmk_action_attrs_evaluated)) {
@@ -1142,7 +1159,7 @@ custom_action(pcmk_resource_t *rsc, char *key, const char *task,
}
action->extra = pcmk__unpack_action_rsc_params(action->op_entry,
attrs, scheduler);
- pe__set_action_flags(action, pcmk_action_attrs_evaluated);
+ pcmk__set_action_flags(action, pcmk_action_attrs_evaluated);
}
update_resource_action_runnable(action, scheduler);
@@ -1163,7 +1180,7 @@ get_pseudo_op(const char *name, pcmk_scheduler_t *scheduler)
if (op == NULL) {
op = custom_action(NULL, strdup(name), name, NULL, TRUE, scheduler);
- pe__set_action_flags(op, pcmk_action_pseudo|pcmk_action_runnable);
+ pcmk__set_action_flags(op, pcmk_action_pseudo|pcmk_action_runnable);
}
return op;
}
@@ -1185,8 +1202,7 @@ find_unfencing_devices(GList *candidates, GList *matches)
} else if (pcmk__str_eq(g_hash_table_lookup(candidate->meta,
PCMK_STONITH_PROVIDES),
- PCMK__VALUE_UNFENCING,
- pcmk__str_casei)) {
+ PCMK_VALUE_UNFENCING, pcmk__str_casei)) {
matches = g_list_prepend(matches, candidate);
}
}
@@ -1203,7 +1219,7 @@ node_priority_fencing_delay(const pcmk_node_t *node,
int lowest_priority = 0;
GList *gIter = NULL;
- // `priority-fencing-delay` is disabled
+ // PCMK_OPT_PRIORITY_FENCING_DELAY is disabled
if (scheduler->priority_fencing_delay <= 0) {
return 0;
}
@@ -1281,9 +1297,10 @@ pe_fence_op(pcmk_node_t *node, const char *op, bool optional,
stonith_op = custom_action(NULL, op_key, PCMK_ACTION_STONITH, node,
TRUE, scheduler);
- add_hash_param(stonith_op->meta, XML_LRM_ATTR_TARGET, node->details->uname);
- add_hash_param(stonith_op->meta, XML_LRM_ATTR_TARGET_UUID, node->details->id);
- add_hash_param(stonith_op->meta, "stonith_action", op);
+ pcmk__insert_meta(stonith_op, PCMK__META_ON_NODE, node->details->uname);
+ pcmk__insert_meta(stonith_op, PCMK__META_ON_NODE_UUID,
+ node->details->id);
+ pcmk__insert_meta(stonith_op, PCMK__META_STONITH_ACTION, op);
if (pcmk_is_set(scheduler->flags, pcmk_sched_enable_unfencing)) {
/* Extra work to detect device changes
@@ -1293,28 +1310,25 @@ pe_fence_op(pcmk_node_t *node, const char *op, bool optional,
GList *matches = find_unfencing_devices(scheduler->resources, NULL);
- char *key = NULL;
- char *value = NULL;
-
for (GList *gIter = matches; gIter != NULL; gIter = gIter->next) {
pcmk_resource_t *match = gIter->data;
const char *agent = g_hash_table_lookup(match->meta,
- XML_ATTR_TYPE);
- op_digest_cache_t *data = NULL;
+ PCMK_XA_TYPE);
+ pcmk__op_digest_t *data = NULL;
data = pe__compare_fencing_digest(match, agent, node,
scheduler);
if (data->rc == pcmk__digest_mismatch) {
optional = FALSE;
crm_notice("Unfencing node %s because the definition of "
- "%s changed", pe__node_name(node), match->id);
+ "%s changed", pcmk__node_name(node), match->id);
if (!pcmk__is_daemon && scheduler->priv != NULL) {
pcmk__output_t *out = scheduler->priv;
out->info(out,
"notice: Unfencing node %s because the "
"definition of %s changed",
- pe__node_name(node), match->id);
+ pcmk__node_name(node), match->id);
}
}
@@ -1325,16 +1339,12 @@ pe_fence_op(pcmk_node_t *node, const char *op, bool optional,
match->id, ":", agent, ":",
data->digest_secure_calc, ",", NULL);
}
- key = strdup(XML_OP_ATTR_DIGESTS_ALL);
- value = strdup((const char *) digests_all->str);
- CRM_ASSERT((key != NULL) && (value != NULL));
- g_hash_table_insert(stonith_op->meta, key, value);
+ pcmk__insert_dup(stonith_op->meta, PCMK__META_DIGESTS_ALL,
+ digests_all->str);
g_string_free(digests_all, TRUE);
- key = strdup(XML_OP_ATTR_DIGESTS_SECURE);
- value = strdup((const char *) digests_secure->str);
- CRM_ASSERT((key != NULL) && (value != NULL));
- g_hash_table_insert(stonith_op->meta, key, value);
+ pcmk__insert_dup(stonith_op->meta, PCMK__META_DIGESTS_SECURE,
+ digests_secure->str);
g_string_free(digests_secure, TRUE);
}
@@ -1344,8 +1354,10 @@ pe_fence_op(pcmk_node_t *node, const char *op, bool optional,
if (scheduler->priority_fencing_delay > 0
- /* It's a suitable case where `priority-fencing-delay` applies.
- * At least add `priority-fencing-delay` field as an indicator. */
+ /* It's a suitable case where PCMK_OPT_PRIORITY_FENCING_DELAY
+ * applies. At least add PCMK_OPT_PRIORITY_FENCING_DELAY field as
+ * an indicator.
+ */
&& (priority_delay
/* The priority delay needs to be recalculated if this function has
@@ -1353,22 +1365,22 @@ pe_fence_op(pcmk_node_t *node, const char *op, bool optional,
* priority has already been calculated by native_add_running().
*/
|| g_hash_table_lookup(stonith_op->meta,
- XML_CONFIG_ATTR_PRIORITY_FENCING_DELAY) != NULL)) {
+ PCMK_OPT_PRIORITY_FENCING_DELAY) != NULL)) {
- /* Add `priority-fencing-delay` to the fencing op even if it's 0 for
- * the targeting node. So that it takes precedence over any possible
- * `pcmk_delay_base/max`.
+ /* Add PCMK_OPT_PRIORITY_FENCING_DELAY to the fencing op even if
+ * it's 0 for the targeting node. So that it takes precedence over
+ * any possible `pcmk_delay_base/max`.
*/
char *delay_s = pcmk__itoa(node_priority_fencing_delay(node,
scheduler));
g_hash_table_insert(stonith_op->meta,
- strdup(XML_CONFIG_ATTR_PRIORITY_FENCING_DELAY),
+ strdup(PCMK_OPT_PRIORITY_FENCING_DELAY),
delay_s);
}
if(optional == FALSE && pe_can_fence(scheduler, node)) {
- pe__clear_action_flags(stonith_op, pcmk_action_optional);
+ pcmk__clear_action_flags(stonith_op, pcmk_action_optional);
pe_action_set_reason(stonith_op, reason, false);
} else if(reason && stonith_op->reason == NULL) {
@@ -1400,61 +1412,12 @@ pe_free_action(pcmk_action_t *action)
free(action);
}
-int
-pe_get_configured_timeout(pcmk_resource_t *rsc, const char *action,
- pcmk_scheduler_t *scheduler)
-{
- xmlNode *child = NULL;
- GHashTable *action_meta = NULL;
- const char *timeout_spec = NULL;
- int timeout_ms = 0;
-
- pe_rule_eval_data_t rule_data = {
- .node_hash = NULL,
- .role = pcmk_role_unknown,
- .now = scheduler->now,
- .match_data = NULL,
- .rsc_data = NULL,
- .op_data = NULL
- };
-
- for (child = first_named_child(rsc->ops_xml, XML_ATTR_OP);
- child != NULL; child = crm_next_same_xml(child)) {
- if (pcmk__str_eq(action, crm_element_value(child, XML_NVPAIR_ATTR_NAME),
- pcmk__str_casei)) {
- timeout_spec = crm_element_value(child, XML_ATTR_TIMEOUT);
- break;
- }
- }
-
- if (timeout_spec == NULL && scheduler->op_defaults) {
- action_meta = pcmk__strkey_table(free, free);
- pe__unpack_dataset_nvpairs(scheduler->op_defaults, XML_TAG_META_SETS,
- &rule_data, action_meta, NULL, FALSE,
- scheduler);
- timeout_spec = g_hash_table_lookup(action_meta, XML_ATTR_TIMEOUT);
- }
-
- // @TODO check meta-attributes
- // @TODO maybe use min-interval monitor timeout as default for monitors
-
- timeout_ms = crm_get_msec(timeout_spec);
- if (timeout_ms < 0) {
- timeout_ms = PCMK_DEFAULT_ACTION_TIMEOUT_MS;
- }
-
- if (action_meta != NULL) {
- g_hash_table_destroy(action_meta);
- }
- return timeout_ms;
-}
-
enum action_tasks
get_complex_task(const pcmk_resource_t *rsc, const char *name)
{
- enum action_tasks task = text2task(name);
+ enum action_tasks task = pcmk_parse_action(name);
- if ((rsc != NULL) && (rsc->variant == pcmk_rsc_variant_primitive)) {
+ if (pcmk__is_primitive(rsc)) {
switch (task) {
case pcmk_action_stopped:
case pcmk_action_started:
@@ -1503,7 +1466,7 @@ find_first_action(const GList *input, const char *uuid, const char *task,
} else if (action->node == NULL) {
continue;
- } else if (on_node->details == action->node->details) {
+ } else if (pcmk__same_node(on_node, action->node)) {
return action;
}
}
@@ -1531,13 +1494,13 @@ find_actions(GList *input, const char *key, const pcmk_node_t *on_node)
} else if (action->node == NULL) {
crm_trace("Action %s matches (unallocated, assigning to %s)",
- key, pe__node_name(on_node));
+ key, pcmk__node_name(on_node));
action->node = pe__copy_node(on_node);
result = g_list_prepend(result, action);
- } else if (on_node->details == action->node->details) {
- crm_trace("Action %s on %s matches", key, pe__node_name(on_node));
+ } else if (pcmk__same_node(on_node, action->node)) {
+ crm_trace("Action %s on %s matches", key, pcmk__node_name(on_node));
result = g_list_prepend(result, action);
}
}
@@ -1564,7 +1527,7 @@ find_actions_exact(GList *input, const char *key, const pcmk_node_t *on_node)
&& pcmk__str_eq(on_node->details->id, action->node->details->id,
pcmk__str_casei)) {
- crm_trace("Action %s on %s matches", key, pe__node_name(on_node));
+ crm_trace("Action %s on %s matches", key, pcmk__node_name(on_node));
result = g_list_prepend(result, action);
}
}
@@ -1640,11 +1603,12 @@ void pe_action_set_reason(pcmk_action_t *action, const char *reason,
bool overwrite)
{
if (action->reason != NULL && overwrite) {
- pe_rsc_trace(action->rsc, "Changing %s reason from '%s' to '%s'",
- action->uuid, action->reason, pcmk__s(reason, "(none)"));
+ pcmk__rsc_trace(action->rsc, "Changing %s reason from '%s' to '%s'",
+ action->uuid, action->reason,
+ pcmk__s(reason, "(none)"));
} else if (action->reason == NULL) {
- pe_rsc_trace(action->rsc, "Set %s reason to '%s'",
- action->uuid, pcmk__s(reason, "(none)"));
+ pcmk__rsc_trace(action->rsc, "Set %s reason to '%s'",
+ action->uuid, pcmk__s(reason, "(none)"));
} else {
// crm_assert(action->reason != NULL && !overwrite);
return;
@@ -1688,17 +1652,17 @@ pe__is_newer_op(const xmlNode *xml_a, const xmlNode *xml_b,
char *a_uuid = NULL;
char *b_uuid = NULL;
- const char *a_xml_id = crm_element_value(xml_a, XML_ATTR_ID);
- const char *b_xml_id = crm_element_value(xml_b, XML_ATTR_ID);
+ const char *a_xml_id = crm_element_value(xml_a, PCMK_XA_ID);
+ const char *b_xml_id = crm_element_value(xml_b, PCMK_XA_ID);
- const char *a_node = crm_element_value(xml_a, XML_LRM_ATTR_TARGET);
- const char *b_node = crm_element_value(xml_b, XML_LRM_ATTR_TARGET);
+ const char *a_node = crm_element_value(xml_a, PCMK__META_ON_NODE);
+ const char *b_node = crm_element_value(xml_b, PCMK__META_ON_NODE);
bool same_node = true;
/* @COMPAT The on_node attribute was added to last_failure as of 1.1.13 (via
* 8b3ca1c) and the other entries as of 1.1.12 (via 0b07b5c).
*
- * In case that any of the lrm_rsc_op entries doesn't have on_node
+ * In case that any of the PCMK__XE_LRM_RSC_OP entries doesn't have on_node
* attribute, we need to explicitly tell whether the two operations are on
* the same node.
*/
@@ -1710,17 +1674,18 @@ pe__is_newer_op(const xmlNode *xml_a, const xmlNode *xml_b,
}
if (same_node && pcmk__str_eq(a_xml_id, b_xml_id, pcmk__str_none)) {
- /* We have duplicate lrm_rsc_op entries in the status
+ /* We have duplicate PCMK__XE_LRM_RSC_OP entries in the status
* section which is unlikely to be a good thing
* - we can handle it easily enough, but we need to get
* to the bottom of why it's happening.
*/
- pe_err("Duplicate lrm_rsc_op entries named %s", a_xml_id);
+ pcmk__config_err("Duplicate " PCMK__XE_LRM_RSC_OP " entries named %s",
+ a_xml_id);
sort_return(0, "duplicate");
}
- crm_element_value_int(xml_a, XML_LRM_ATTR_CALLID, &a_call_id);
- crm_element_value_int(xml_b, XML_LRM_ATTR_CALLID, &b_call_id);
+ crm_element_value_int(xml_a, PCMK__XA_CALL_ID, &a_call_id);
+ crm_element_value_int(xml_b, PCMK__XA_CALL_ID, &b_call_id);
if (a_call_id == -1 && b_call_id == -1) {
/* both are pending ops so it doesn't matter since
@@ -1736,15 +1701,14 @@ pe__is_newer_op(const xmlNode *xml_a, const xmlNode *xml_b,
} else if (a_call_id >= 0 && b_call_id >= 0
&& (!same_node || a_call_id == b_call_id)) {
- /*
- * The op and last_failed_op are the same
- * Order on last-rc-change
+ /* The op and last_failed_op are the same. Order on
+ * PCMK_XA_LAST_RC_CHANGE.
*/
time_t last_a = -1;
time_t last_b = -1;
- crm_element_value_epoch(xml_a, XML_RSC_OP_LAST_CHANGE, &last_a);
- crm_element_value_epoch(xml_b, XML_RSC_OP_LAST_CHANGE, &last_b);
+ crm_element_value_epoch(xml_a, PCMK_XA_LAST_RC_CHANGE, &last_a);
+ crm_element_value_epoch(xml_b, PCMK_XA_LAST_RC_CHANGE, &last_b);
crm_trace("rc-change: %lld vs %lld",
(long long) last_a, (long long) last_b);
@@ -1757,15 +1721,18 @@ pe__is_newer_op(const xmlNode *xml_a, const xmlNode *xml_b,
sort_return(0, "rc-change");
} else {
- /* One of the inputs is a pending operation
- * Attempt to use XML_ATTR_TRANSITION_MAGIC to determine its age relative to the other
+ /* One of the inputs is a pending operation.
+ * Attempt to use PCMK__XA_TRANSITION_MAGIC to determine its age relative
+ * to the other.
*/
int a_id = -1;
int b_id = -1;
- const char *a_magic = crm_element_value(xml_a, XML_ATTR_TRANSITION_MAGIC);
- const char *b_magic = crm_element_value(xml_b, XML_ATTR_TRANSITION_MAGIC);
+ const char *a_magic = crm_element_value(xml_a,
+ PCMK__XA_TRANSITION_MAGIC);
+ const char *b_magic = crm_element_value(xml_b,
+ PCMK__XA_TRANSITION_MAGIC);
CRM_CHECK(a_magic != NULL && b_magic != NULL, sort_return(0, "No magic"));
if (!decode_transition_magic(a_magic, &a_uuid, &a_id, NULL, NULL, NULL,
@@ -1841,9 +1808,9 @@ pe__new_rsc_pseudo_action(pcmk_resource_t *rsc, const char *task, bool optional,
action = custom_action(rsc, pcmk__op_key(rsc->id, task, 0), task, NULL,
optional, rsc->cluster);
- pe__set_action_flags(action, pcmk_action_pseudo);
+ pcmk__set_action_flags(action, pcmk_action_pseudo);
if (runnable) {
- pe__set_action_flags(action, pcmk_action_runnable);
+ pcmk__set_action_flags(action, pcmk_action_runnable);
}
return action;
}
@@ -1855,17 +1822,13 @@ pe__new_rsc_pseudo_action(pcmk_resource_t *rsc, const char *task, bool optional,
* \param[in,out] action Action to add expected result to
* \param[in] expected_result Expected result to add
*
- * \note This is more efficient than calling add_hash_param().
+ * \note This is more efficient than calling pcmk__insert_meta().
*/
void
pe__add_action_expected_result(pcmk_action_t *action, int expected_result)
{
- char *name = NULL;
-
CRM_ASSERT((action != NULL) && (action->meta != NULL));
- name = strdup(XML_ATTR_TE_TARGET_RC);
- CRM_ASSERT (name != NULL);
-
- g_hash_table_insert(action->meta, name, pcmk__itoa(expected_result));
+ g_hash_table_insert(action->meta, pcmk__str_copy(PCMK__META_OP_TARGET_RC),
+ pcmk__itoa(expected_result));
}