12 #include <sys/param.h>
33 if (pe_rsc_is_clone(
action->rsc) && node) {
60 convert_non_atomic_uuid(
char *old_uuid,
pe_resource_t * rsc, gboolean allow_notify,
61 gboolean free_original)
63 guint interval_ms = 0;
66 char *raw_task = NULL;
71 if (old_uuid == NULL) {
74 }
else if (strstr(old_uuid,
"notify") != NULL) {
82 if (interval_ms > 0) {
107 crm_err(
"Unknown action: %s", raw_task);
119 pe_rsc_trace(rsc,
"Converted %s -> %s", old_uuid, uuid);
124 uuid = strdup(old_uuid);
139 gboolean notify = FALSE;
159 uuid = convert_non_atomic_uuid(
action->uuid, rsc, notify, FALSE);
164 if (result == NULL) {
165 crm_err(
"Couldn't expand %s to %s in %s",
action->uuid, uuid, rsc->
id);
181 gboolean processed = FALSE;
229 first_flags, restart,
257 crm_trace(
"implies left: %s (%d) then %s (%d)",
273 "implies left when right rsc is Master role: %s then %s: changed",
276 crm_trace(
"implies left when right rsc is Master role: %s then %s", first->
uuid,
313 pe_rsc_trace(then->
rsc,
"Ignoring %s then %s - %s is about to be stopped",
442 if (processed == FALSE) {
456 for (; gIter != NULL; gIter = gIter->next) {
495 for (gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
503 for (gIter = rsc->
rsc_cons_lhs; gIter != NULL; gIter = gIter->next) {
506 mark_start_blocked(colocate_with->
rsc_lh,
action->rsc, data_set);
516 int last_flags = then->
flags;
561 crm_trace(
"First: Found node %s for %s", first_node->details->uname, first->
uuid);
568 crm_trace(
"Then: Found node %s for %s", then_node->details->uname, then->
uuid);
573 && (first_node->details != then_node->details)) {
575 crm_trace(
"Disabled constraint %s on %s -> %s on %s",
576 other->
action->
uuid, first_node->details->uname,
577 then->
uuid, then_node->details->uname);
596 if (first->
rsc && then->
rsc && (first->
rsc != then->
rsc)
598 first = rsc_expand_action(first);
600 if (first != other->
action) {
605 first_flags = get_action_flags(first, then_node);
606 then_flags = get_action_flags(then, first_node);
608 crm_trace(
"Checking %s (%s %s %s) against %s (%s %s %s) filter=0x%.6x type=0x%.6x",
614 uname :
"", first->
uuid, is_set(first_flags,
621 if (first == other->
action) {
636 changed |= graph_update_action(first, then, node, first_flags,
637 then_flags, other, data_set);
650 crm_trace(
"Disabled constraint %s -> %s in favor of %s -> %s",
659 crm_trace(
"Updated %s (first %s %s %s), processing dependents ",
666 for (lpc2 = first->
actions_after; lpc2 != NULL; lpc2 = lpc2->next) {
676 if (last_flags != then->
flags) {
684 crm_trace(
"Updated %s (then %s %s %s), processing dependents ",
696 for (lpc = then->
actions_after; lpc != NULL; lpc = lpc->next) {
714 for (lpc = data_set->
actions; lpc != NULL; lpc = lpc->next) {
764 CRM_CHECK(stonith_op && data_set,
return);
765 for (GList *r = data_set->
resources; r != NULL; r = r->next) {
776 bool partial_migration = FALSE;
777 const char *task =
action->task;
786 began_on = pe__current_node(
action->node->details->remote_rsc);
787 ended_on =
action->node->details->remote_rsc->allocated_to;
788 if (
action->node->details->remote_rsc
789 && (
action->node->details->remote_rsc->container == NULL)
790 &&
action->node->details->remote_rsc->partial_migration_target) {
791 partial_migration = TRUE;
796 if (!began_on || !ended_on) {
798 return began_on ? began_on : ended_on;
827 task = g_hash_table_lookup(
action->meta,
"notify_operation");
834 safe_str_eq(task,
"migrate_to")) && !partial_migration) {
836 router_node = began_on;
840 router_node = ended_on;
853 add_node_to_xml_by_id(
const char *
id, xmlNode *xml)
871 add_node_to_xml(
const pe_node_t *node,
void *xml)
873 add_node_to_xml_by_id(node->
details->
id, (xmlNode *) xml);
887 xmlNode *maintenance =
891 for (gIter = data_set->
nodes; gIter != NULL;
892 gIter = gIter->next) {
900 if (details->maintenance != details->remote_maintenance) {
903 add_node_to_xml_by_id(node->
details->
id, maintenance),
909 crm_trace(
"%s %d nodes to adjust maintenance-mode "
910 "to transition", maintenance?
"Added":
"Counted", count);
925 if (add_maintenance_nodes(NULL, data_set)) {
926 crm_trace(
"adding maintenance state update pseudo action");
954 add_node_to_xml_by_id(
action->node->details->id, downed);
959 const char *fence = g_hash_table_lookup(
action->meta,
"stonith_action");
963 add_node_to_xml_by_id(
action->node->details->id, downed);
975 gboolean migrating = FALSE;
977 for (iter =
action->actions_before; iter != NULL; iter = iter->next) {
987 add_node_to_xml_by_id(
action->rsc->id, downed);
996 if ((
action->rsc->lock_node == NULL) || (
action->node == NULL)
997 || (
action->node->details !=
action->rsc->lock_node->details)) {
1015 gboolean needs_node_info = TRUE;
1016 gboolean needs_maintenance_info = FALSE;
1017 xmlNode *action_xml = NULL;
1018 xmlNode *args_xml = NULL;
1019 #if ENABLE_VERSIONED_ATTRS
1020 pe_rsc_action_details_t *rsc_details = NULL;
1053 needs_maintenance_info = TRUE;
1056 needs_node_info = FALSE;
1061 #if ENABLE_VERSIONED_ATTRS
1062 rsc_details = pe_rsc_action_details(
action);
1068 if (
action->rsc != NULL &&
action->rsc->clone_name != NULL) {
1069 char *clone_key = NULL;
1079 const char *n_type = g_hash_table_lookup(
action->meta,
"notify_type");
1080 const char *n_task = g_hash_table_lookup(
action->meta,
"notify_operation");
1084 crm_err(
"No notify operation value found for %s",
action->uuid));
1088 }
else if(
action->cancel_task) {
1090 action->cancel_task, interval_ms);
1093 action->task, interval_ms);
1105 if (needs_node_info &&
action->node != NULL) {
1125 xmlNode *rsc_xml = NULL;
1126 const char *attr_list[] = {
1135 if (should_lock_action(
action)) {
1137 (
long long)
action->rsc->lock_time);
1143 crm_element_name(
action->rsc->xml));
1145 &&
action->rsc->clone_name) {
1157 crm_debug(
"Using orphan clone name %s instead of %s",
action->rsc->id,
1158 action->rsc->clone_name);
1163 const char *xml_id =
ID(
action->rsc->xml);
1165 crm_debug(
"Using anonymous clone name %s for %s (aka. %s)", xml_id,
action->rsc->id,
1166 action->rsc->clone_name);
1193 for (lpc = 0; lpc <
DIMOF(attr_list); lpc++) {
1195 g_hash_table_lookup(
action->rsc->meta, attr_list[lpc]));
1205 GHashTable *p = crm_str_table_new();
1209 g_hash_table_destroy(p);
1211 #if ENABLE_VERSIONED_ATTRS
1215 pe_get_versioned_attributes(versioned_parameters,
action->rsc,
1227 #if ENABLE_VERSIONED_ATTRS
1234 #if ENABLE_VERSIONED_ATTRS
1237 add_node_copy(action_xml, rsc_details->versioned_parameters);
1247 if (
action->rsc != NULL) {
1248 const char *value = g_hash_table_lookup(
action->rsc->meta,
"external-ip");
1251 while (parent != NULL) {
1257 hash2smartfield((gpointer)
"pcmk_external_ip", (gpointer)value, (gpointer)args_xml);
1266 const char *n_task = g_hash_table_lookup(
action->meta,
"notify_operation");
1276 host = pe__current_node(
action->node->details->remote_rsc->container);
1283 host =
action->node->details->remote_rsc->container->allocated_to;
1294 (gpointer)args_xml);
1312 if (needs_node_info && (
action->node != NULL)) {
1313 add_downed_nodes(action_xml,
action, data_set);
1316 if (needs_maintenance_info) {
1317 add_maintenance_nodes(action_xml, data_set);
1352 for (lpc =
action->actions_after; lpc != NULL; lpc = lpc->next) {
1360 || should_dump_action(wrapper->
action)) {
1361 crm_trace(
"Action %s (%d) should be dumped: "
1362 "dependency of %s (%d)",
1371 crm_trace(
"Ignoring action %s (%d): unrunnable",
1377 crm_trace(
"Ignoring action %s (%d): optional",
1385 const char *interval_ms_s = g_hash_table_lookup(
action->meta,
1389 if ((interval_ms_s == NULL) || !strcmp(interval_ms_s,
"0")) {
1390 crm_trace(
"Ignoring action %s (%d): for unmanaged resource (%s)",
1403 if (
action->node == NULL) {
1404 pe_err(
"Skipping action %s (%d) "
1405 "because it was not allocated to a node (bug?)",
1411 crm_trace(
"Action %s (%d) should be dumped: "
1412 "can run on DC instead of %s",
1416 && !
action->node->details->remote_requires_reset) {
1417 crm_trace(
"Action %s (%d) should be dumped: "
1418 "assuming will be runnable on guest node %s",
1421 }
else if (
action->node->details->online ==
false) {
1422 pe_err(
"Skipping action %s (%d) "
1423 "because it was scheduled for offline node (bug?)",
1431 }
else if (
action->node->details->unclean ==
false) {
1432 pe_err(
"Skipping action %s (%d) "
1433 "because it was scheduled for unclean node (bug?)",
1444 sort_action_id(gconstpointer a, gconstpointer b)
1491 crm_trace(
"Ignoring %s (%d) input %s (%d): "
1492 "ordering disabled",
1500 crm_trace(
"Ignoring %s (%d) input %s (%d): "
1501 "optional and input unrunnable",
1508 crm_trace(
"Ignoring %s (%d) input %s (%d): "
1509 "one-or-more and input unrunnable",
1516 crm_trace(
"Ignoring %s (%d) input %s (%d): "
1517 "stonith stop but action is pseudo",
1524 crm_trace(
"Ignoring %s (%d) input %s (%d): "
1525 "implies input migratable but input unrunnable",
1532 crm_trace(
"Ignoring %s (%d) input %s (%d): "
1533 "only if input unmigratable but input unrunnable",
1541 crm_trace(
"Ignoring %s (%d) input %s (%d): "
1542 "optional but stop in migration",
1558 if ((input_node == NULL) || (allocated == NULL)
1560 crm_trace(
"Ignoring %s (%d) input %s (%d): "
1561 "load ordering node mismatch %s vs %s",
1570 }
else if ((input_node == NULL) || (
action->node == NULL)
1572 crm_trace(
"Ignoring %s (%d) input %s (%d): "
1573 "load ordering node mismatch %s vs %s",
1576 (
action->node?
action->node->details->uname :
"<none>"),
1582 crm_trace(
"Ignoring %s (%d) input %s (%d): "
1583 "load ordering input optional",
1593 crm_trace(
"Ignoring %s (%d) input %s (%d): "
1594 "anti-colocation node mismatch %s vs %s",
1597 action->node->details->uname,
1603 crm_trace(
"Ignoring %s (%d) input %s (%d): "
1604 "anti-colocation input optional",
1617 crm_warn(
"Ignoring requirement that %s complete before %s:"
1618 " unmanaged failed resources cannot prevent clone shutdown",
1625 && !should_dump_action(input->
action)) {
1626 crm_trace(
"Ignoring %s (%d) input %s (%d): "
1633 crm_trace(
"%s (%d) input %s (%d) @ %s should be dumped: %s, %s, %s, 0x%.6x",
1648 bool has_loop =
false;
1651 crm_trace(
"Breaking tracking loop: %s@%s -> %s@%s (0x%.6x)",
1661 if (!check_dump_input(
action, input)) {
1665 if (input->
action == init_action) {
1666 crm_debug(
"Input loop found in %s@%s ->...-> %s@%s",
1676 crm_trace(
"Checking inputs of action %s@%s input %s@%s (0x%.6x)"
1677 "for graph loop with %s@%s ",
1688 iter != NULL; iter = iter->next) {
1690 if (graph_has_loop(init_action, input->
action,
1702 crm_trace(
"No input loop found in %s@%s -> %s@%s (0x%.6x)",
1723 crm_warn(
"Invalid ordering constraint between %s and %s",
1752 action->actions_before = g_list_sort(
action->actions_before,
1754 for (item =
action->actions_before; item != NULL; item = next) {
1759 crm_trace(
"Input %s (%d) duplicate skipped for action %s (%d)",
1773 action->actions_before = g_list_delete_link(
action->actions_before,
1801 int synapse_priority = 0;
1802 xmlNode *syn = NULL;
1803 xmlNode *set = NULL;
1805 xmlNode *xml_action = NULL;
1812 deduplicate_inputs(
action);
1816 if (should_dump_action(
action) == FALSE) {
1829 if (
action->rsc != NULL) {
1830 synapse_priority =
action->rsc->priority;
1832 if (
action->priority > synapse_priority) {
1833 synapse_priority =
action->priority;
1835 if (synapse_priority > 0) {
1839 xml_action = action2xml(
action, FALSE, data_set);
1842 for (lpc =
action->actions_before; lpc != NULL; lpc = lpc->next) {
1844 if (check_dump_input(
action, input)) {
1848 xml_action = action2xml(input->
action, TRUE, data_set);
enum crm_ais_msg_types type
char * pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key (RESOURCE_ACTION_INTERVAL)
char * pcmk__notify_key(const char *rsc_id, const char *notify_type, const char *op_type)
bool pcmk__ends_with(const char *s, const char *match)
int pcmk__guint_from_hash(GHashTable *table, const char *key, guint default_val, guint *result)
gboolean parse_op_key(const char *key, char **rsc_id, char **op_type, guint *interval_ms)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
gboolean safe_str_neq(const char *a, const char *b)
#define safe_str_eq(a, b)
enum action_tasks text2task(const char *task)
const char * task2text(enum action_tasks task)
void get_rsc_attributes(GHashTable *meta_hash, pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set)
gboolean is_parent(pe_resource_t *child, pe_resource_t *rsc)
pe_resource_t * uber_parent(pe_resource_t *rsc)
#define CRM_OP_LRM_REFRESH
#define CRMD_ACTION_MIGRATED
#define CRMD_ACTION_RELOAD
#define CRM_OP_CLEAR_FAILCOUNT
#define CRM_OP_MAINTENANCE_NODES
#define CRM_OP_LRM_DELETE
#define clear_bit(word, bit)
#define PCMK__ENV_PHYSICAL_HOST
#define set_bit(word, bit)
#define crm_warn(fmt, args...)
#define CRM_CHECK(expr, failure_action)
#define crm_debug(fmt, args...)
#define crm_err(fmt, args...)
#define crm_log_xml_trace(xml, text)
#define crm_trace(fmt, args...)
#define XML_LRM_ATTR_ROUTER_NODE
#define XML_ATTR_CRM_VERSION
#define XML_RSC_ATTR_TARGET
#define XML_TAG_RSC_VER_ATTRS
#define XML_CIB_ATTR_PRIORITY
#define XML_LRM_ATTR_TASK_KEY
#define XML_CONFIG_ATTR_SHUTDOWN_LOCK
#define XML_LRM_ATTR_TARGET_UUID
#define XML_AGENT_ATTR_PROVIDER
#define XML_AGENT_ATTR_CLASS
#define XML_NODE_IS_MAINTENANCE
#define XML_GRAPH_TAG_CRM_EVENT
#define XML_GRAPH_TAG_DOWNED
#define XML_LRM_ATTR_TASK
#define XML_LRM_ATTR_TARGET
#define XML_GRAPH_TAG_PSEUDO_EVENT
#define XML_GRAPH_TAG_MAINTENANCE
#define XML_GRAPH_TAG_RSC_OP
#define XML_LRM_ATTR_INTERVAL_MS
void hash2metafield(gpointer key, gpointer value, gpointer user_data)
Set XML attribute based on hash table entry, as meta-attribute name.
void hash2field(gpointer key, gpointer value, gpointer user_data)
Set XML attribute based on hash table entry.
const char * crm_xml_add_ll(xmlNode *node, const char *name, long long value)
Create an XML attribute with specified name and long long int value.
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
Create an XML attribute with specified name and integer value.
void hash2smartfield(gpointer key, gpointer value, gpointer user_data)
Add hash table entry to XML as (possibly legacy) name/value.
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
gboolean rsc_update_action(pe_action_t *first, pe_action_t *then, enum pe_ordering type)
gboolean update_action(pe_action_t *then, pe_working_set_t *data_set)
gboolean shutdown_constraints(pe_node_t *node, pe_action_t *shutdown_op, pe_working_set_t *data_set)
void graph_element_from_action(pe_action_t *action, pe_working_set_t *data_set)
void pcmk__order_vs_fence(pe_action_t *stonith_op, pe_working_set_t *data_set)
bool pcmk__ordering_is_invalid(pe_action_t *action, pe_action_wrapper_t *input)
void update_colo_start_chain(pe_action_t *action, pe_working_set_t *data_set)
void add_maintenance_update(pe_working_set_t *data_set)
gboolean update_action_flags(pe_action_t *action, enum pe_action_flags flags, const char *source, int line)
void rsc_stonith_ordering(pe_resource_t *rsc, pe_action_t *stonith_op, pe_working_set_t *data_set)
void log_action(unsigned int log_level, const char *pre_text, pe_action_t *action, gboolean details)
int custom_action_order(pe_resource_t *lh_rsc, char *lh_task, pe_action_t *lh_action, pe_resource_t *rh_rsc, char *rh_task, pe_action_t *rh_action, enum pe_ordering type, pe_working_set_t *data_set)
@ pe_order_implies_first_printed
@ pe_order_implies_first_master
@ pe_order_anti_colocation
@ pe_order_then_cancels_first
@ pe_order_implies_then_on_node
@ pe_order_implies_first_migratable
@ pe_order_implies_then_printed
@ pe_order_apply_first_non_migratable
@ pe_link_dumped
Internal tracking for transition graph creation.
@ pe_action_dc
Internal state tracking when creating graph.
@ pe_action_migrate_runnable
#define pe_rsc_maintenance
void pe_action_set_flag_reason(const char *function, long line, pe_action_t *action, pe_action_t *reason, const char *text, enum pe_action_flags flags, bool overwrite)
pe_action_t * get_pseudo_op(const char *name, pe_working_set_t *data_set)
#define pe_clear_action_bit(action, bit)
gboolean order_actions(pe_action_t *lh_action, pe_action_t *rh_action, enum pe_ordering order)
#define pe_rsc_trace(rsc, fmt, args...)
pe_action_t * find_first_action(GListPtr input, const char *uuid, const char *task, pe_node_t *on_node)
gboolean pe__is_guest_node(pe_node_t *node)
void pe_foreach_guest_node(const pe_working_set_t *data_set, const pe_node_t *host, void(*helper)(const pe_node_t *, void *), void *user_data)
gboolean pe__is_guest_or_remote_node(pe_node_t *node)
enum pe_action_flags flags
int required_runnable_before
struct pe_node_shared_s * details
pe_resource_t * remote_rsc
enum pe_obj_types variant
pe_resource_t * container
resource_alloc_functions_t * cmds
resource_object_functions_t * fns
void(* append_meta)(pe_resource_t *rsc, xmlNode *xml)
enum pe_graph_flags(* update_actions)(pe_action_t *, pe_action_t *, pe_node_t *, enum pe_action_flags, enum pe_action_flags, enum pe_ordering, pe_working_set_t *data_set)
pe_node_t *(* location)(const pe_resource_t *, GList **, int)
Wrappers for and extensions to libxml2.
gboolean xml_has_children(const xmlNode *root)
xmlNode * sorted_xml(xmlNode *input, xmlNode *parent, gboolean recursive)
int add_node_nocopy(xmlNode *parent, const char *name, xmlNode *child)
void free_xml(xmlNode *child)
xmlNode * add_node_copy(xmlNode *new_parent, xmlNode *xml_node)
xmlNode * create_xml_node(xmlNode *parent, const char *name)