12 #include <sys/param.h> 25 #define action_type_str(flags) \ 26 (pcmk_is_set((flags), pcmk_action_pseudo)? "pseudo-action" : "action") 28 #define action_optional_str(flags) \ 29 (pcmk_is_set((flags), pcmk_action_optional)? "optional" : "required") 31 #define action_runnable_str(flags) \ 32 (pcmk_is_set((flags), pcmk_action_runnable)? "runnable" : "unrunnable") 34 #define action_node_str(a) \ 35 (((a)->node == NULL)? "no node" : (a)->node->details->uname) 45 add_node_to_xml_by_id(
const char *
id, xmlNode *xml)
65 add_node_to_xml_by_id(node->
details->
id, (xmlNode *) xml);
81 xmlNode *maintenance = NULL;
88 iter != NULL; iter = iter->next) {
91 if (pcmk__is_pacemaker_remote_node(node) &&
94 if (maintenance != NULL) {
103 crm_trace(
"%s %d nodes in need of maintenance mode update in state",
104 ((maintenance == NULL)?
"Counted" :
"Added"), count);
119 if (add_maintenance_nodes(NULL,
scheduler) != 0) {
146 add_node_to_xml_by_id(
action->node->details->id, downed);
152 const char *fence = g_hash_table_lookup(
action->meta,
157 add_node_to_xml_by_id(
action->node->details->id, downed);
159 action->node, add_node_to_xml, downed);
171 bool migrating =
false;
173 for (iter =
action->actions_before; iter != NULL; iter = iter->next) {
175 if ((
input->rsc != NULL)
185 add_node_to_xml_by_id(
action->rsc->id, downed);
203 const char *n_type = g_hash_table_lookup(
action->meta,
"notify_type");
204 const char *n_task = g_hash_table_lookup(
action->meta,
210 }
else if (
action->cancel_task != NULL) {
232 if (router_node != NULL) {
247 xmlNode *rsc_xml = NULL;
248 const char *attr_list[] = {
260 (
long long)
action->rsc->lock_time);
266 (
const char *)
action->rsc->xml->name);
268 && (
action->rsc->clone_name != NULL)) {
277 crm_debug(
"Using orphan clone name %s instead of %s",
283 const char *xml_id = pcmk__xe_id(
action->rsc->xml);
285 crm_debug(
"Using anonymous clone name %s for %s (aka %s)",
302 if ((
action->rsc->clone_name != NULL)
303 && !pcmk__str_eq(xml_id,
action->rsc->clone_name,
315 for (
int lpc = 0; lpc <
PCMK__NELEM(attr_list); lpc++) {
317 g_hash_table_lookup(
action->rsc->meta, attr_list[lpc]));
331 xmlNode *args_xml = NULL;
351 }
else if ((
action->rsc != NULL)
360 if (
action->rsc != NULL) {
371 && (
action->node != NULL)) {
399 bool needs_node_info =
true;
400 bool needs_maintenance_info =
false;
401 xmlNode *action_xml = NULL;
431 needs_maintenance_info =
true;
434 needs_node_info =
false;
443 if ((
action->rsc != NULL) && (
action->rsc->clone_name != NULL)) {
444 char *clone_key = NULL;
451 clone_key = clone_op_key(
action, interval_ms);
460 if (needs_node_info && (
action->node != NULL)) {
461 add_node_details(
action, action_xml);
463 action->node->details->uname);
465 action->node->details->id);
476 add_resource_details(
action, action_xml);
480 add_action_attributes(
action, action_xml);
483 if (needs_node_info && (
action->node != NULL)) {
484 add_downed_nodes(action_xml,
action);
487 if (needs_maintenance_info) {
488 add_maintenance_nodes(action_xml,
scheduler);
504 crm_trace(
"Ignoring action %s (%d): unrunnable",
511 crm_trace(
"Ignoring action %s (%d): optional",
523 const char *interval_ms_s;
532 crm_trace(
"Ignoring action %s (%d): for unmanaged resource (%s)",
547 if (
action->node == NULL) {
549 "because it was not assigned to a node (bug?)",
556 crm_trace(
"Action %s (%d) should be dumped: " 557 "can run on DC instead of %s",
560 }
else if (pcmk__is_guest_or_bundle_node(
action->node)
561 && !
action->node->details->remote_requires_reset) {
562 crm_trace(
"Action %s (%d) should be dumped: " 563 "assuming will be runnable on guest %s",
566 }
else if (!
action->node->details->online) {
568 "because it was scheduled for offline node (bug?)",
573 }
else if (
action->node->details->unclean) {
575 "because it was scheduled for unclean node (bug?)",
594 return pcmk_any_flags_set(ordering->
type,
620 crm_trace(
"Ignoring %s (%d) input %s (%d): " 627 && !ordering_can_change_actions(
input)) {
628 crm_trace(
"Ignoring %s (%d) input %s (%d): " 629 "optional and input unrunnable",
636 crm_trace(
"Ignoring %s (%d) input %s (%d): " 637 "minimum number of instances required but input unrunnable",
644 crm_trace(
"Ignoring %s (%d) input %s (%d): " 645 "input blocked if 'then' unmigratable",
652 crm_trace(
"Ignoring %s (%d) input %s (%d): ordering applies " 653 "only if input is unmigratable, but it is migratable",
661 crm_trace(
"Ignoring %s (%d) input %s (%d): " 662 "optional but stop in migration",
680 if (!pcmk__same_node(input_node, assigned)) {
681 crm_trace(
"Ignoring %s (%d) input %s (%d): " 682 "migration target %s is not same as input node %s",
691 }
else if (!pcmk__same_node(input_node,
action->node)) {
692 crm_trace(
"Ignoring %s (%d) input %s (%d): " 693 "not on same node (%s vs %s)",
696 (
action->node?
action->node->details->uname :
"<none>"),
702 crm_trace(
"Ignoring %s (%d) input %s (%d): " 712 && !pcmk__same_node(
input->action->node,
action->node)) {
713 crm_trace(
"Ignoring %s (%d) input %s (%d): " 714 "not on same node (%s vs %s)",
717 pcmk__node_name(
action->node),
718 pcmk__node_name(
input->action->node));
723 crm_trace(
"Ignoring %s (%d) input %s (%d): optional",
730 }
else if (
input->action->rsc
735 && pcmk__is_clone(
action->rsc)) {
736 crm_warn(
"Ignoring requirement that %s complete before %s:" 737 " unmanaged failed resources cannot prevent clone shutdown",
742 && !pcmk_any_flags_set(
input->action->flags,
745 && !should_add_action_to_graph(
input->action)) {
746 crm_trace(
"Ignoring %s (%d) input %s (%d): " 753 crm_trace(
"%s (%d) input %s %s (%d) on %s should be dumped: %s %s %#.6x",
778 bool has_loop =
false;
781 crm_trace(
"Breaking tracking loop: %s@%s -> %s@%s (%#.6x)",
783 input->action->node?
input->action->node->details->uname :
"",
795 if (
input->action == init_action) {
796 crm_debug(
"Input loop found in %s@%s ->...-> %s@%s",
806 crm_trace(
"Checking inputs of action %s@%s input %s@%s (%#.6x)" 807 "for graph loop with %s@%s ",
811 input->action->node?
input->action->node->details->uname :
"",
817 for (GList *iter =
input->action->actions_before;
818 iter != NULL; iter = iter->next) {
831 crm_trace(
"No input loop found in %s@%s -> %s@%s (%#.6x)",
833 input->action->node?
input->action->node->details->uname :
"",
853 int synapse_priority = 0;
859 if (
action->rsc != NULL) {
860 synapse_priority =
action->rsc->priority;
862 if (
action->priority > synapse_priority) {
863 synapse_priority =
action->priority;
865 if (synapse_priority > 0) {
888 add_action_to_graph(gpointer
data, gpointer user_data)
907 || !should_add_action_to_graph(
action)) {
912 crm_trace(
"Adding action %d (%s%s%s) to graph",
914 ((
action->node == NULL)?
"" :
" on "),
915 ((
action->node == NULL)?
"" :
action->node->details->uname));
923 for (GList *lpc =
action->actions_before; lpc != NULL; lpc = lpc->next) {
935 static int transition_id = 0;
947 crm_err(
"Calculated transition %d (with errors)%s%s",
949 (filename == NULL)?
"" :
", saving inputs in ",
950 (filename == NULL)?
"" : filename);
953 crm_warn(
"Calculated transition %d (with warnings)%s%s",
955 (filename == NULL)?
"" :
", saving inputs in ",
956 (filename == NULL)?
"" : filename);
961 (filename == NULL)?
"" :
", saving inputs in ",
962 (filename == NULL)?
"" : filename);
965 crm_notice(
"Configuration errors found during scheduler processing," 966 " please run \"crm_verify -L\" to identify issues");
988 for (iter = rsc->
children; iter != NULL; iter = iter->next) {
1005 const char *value = NULL;
1006 long long limit = 0LL;
1011 crm_trace(
"Creating transition graph %d", transition_id);
1039 }
else if (limit > 0) {
1044 char *recheck_epoch = NULL;
1049 free(recheck_epoch);
1072 if ((
action->rsc != NULL)
1073 && (
action->node != NULL)
1074 &&
action->node->details->shutdown
1076 && !pcmk_any_flags_set(
action->flags,
1090 crm_crit(
"Cannot %s %s because of %s:%s%s (%s)",
1091 action->node->details->unclean?
"fence" :
"shut down",
1093 (managed?
" blocked" :
" unmanaged"),
1094 (failed?
" failed" :
""),
action->uuid);
pcmk_assignment_methods_t * cmds
#define PCMK__XA_OPERATION_KEY
#define CRM_CHECK(expr, failure_action)
#define PCMK__XA_PRIORITY
enum pe_quorum_policy no_quorum_policy
#define crm_notice(fmt, args...)
pcmk_scheduler_t * cluster
Actions are ordered if on same node (or migration target for migrate_to)
#define crm_crit(fmt, args...)
pcmk_action_t * get_pseudo_op(const char *name, pcmk_scheduler_t *scheduler)
void hash2field(gpointer key, gpointer value, gpointer user_data)
Set XML attribute based on hash table entry.
#define PCMK__XA_ROUTER_NODE
bool pcmk__strcase_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
#define action_type_str(flags)
gboolean was_processing_warning
#define pcmk__rsc_trace(rsc, fmt, args...)
#define PCMK_OPT_SHUTDOWN_LOCK
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
Create an XML attribute with specified name and integer value.
#define PCMK_ACTION_MONITOR
#define PCMK__XE_PSEUDO_EVENT
#define PCMK__XE_ATTRIBUTES
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
void pcmk__log_transition_summary(const char *filename)
#define PCMK_ACTION_MIGRATE_TO
#define PCMK_ACTION_DO_SHUTDOWN
#define PCMK__META_STONITH_ACTION
G_GNUC_INTERNAL void pcmk__add_guest_meta_to_xml(xmlNode *args_xml, const pcmk_action_t *action)
Add special guest node meta-attributes to XML.
#define CRM_LOG_ASSERT(expr)
#define PCMK_ACTION_CLEAR_FAILCOUNT
#define PCMK__META_ON_NODE
G_GNUC_INTERNAL pcmk_node_t * pcmk__connection_host_for_action(const pcmk_action_t *action)
const char * pcmk__cluster_option(GHashTable *options, const char *name)
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
#define PCMK__XE_TRANSITION_GRAPH
bool pcmk__ends_with(const char *s, const char *match)
void hash2smartfield(gpointer key, gpointer value, gpointer user_data)
Safely add hash table entry to XML as attribute or name-value pair.
#define PCMK_XA_OPERATION
void(* add_actions_to_graph)(pcmk_resource_t *rsc)
gboolean remote_maintenance
#define PCMK_ACTION_MAINTENANCE_NODES
gboolean crm_config_error
int pcmk__scan_ll(const char *text, long long *result, long long default_value)
#define crm_warn(fmt, args...)
#define PCMK_OPT_BATCH_LIMIT
int pcmk__guint_from_hash(GHashTable *table, const char *key, guint default_val, guint *result)
#define crm_debug(fmt, args...)
Actions are ordered (optionally, if no other flags are set)
#define pcmk__clear_action_flags(action, flags_to_clear)
G_GNUC_INTERNAL void pcmk__log_action(const char *pre_text, const pcmk_action_t *action, bool details)
#define pcmk__sched_err(fmt...)
#define crm_trace(fmt, args...)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
struct pe_node_shared_s * details
gboolean was_processing_error
#define PCMK__META_ON_NODE_UUID
Wrappers for and extensions to libxml2.
Ordering applies only if 'first' is required and on same node as 'then'.
#define PCMK_ACTION_STONITH
#define PCMK_OPT_CLUSTER_DELAY
char * pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key (RESOURCE_ACTION_INTERVAL)
void free_xml(xmlNode *child)
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
xmlNode * sorted_xml(xmlNode *input, xmlNode *parent, gboolean recursive)
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.
#define pcmk__assert(expr)
#define PCMK_XA_CRM_FEATURE_SET
void pcmk__add_rsc_actions_to_graph(pcmk_resource_t *rsc)
#define PCMK_ACTION_LRM_DELETE
#define PCMK_OPT_STONITH_TIMEOUT
bool pcmk__graph_has_loop(const pcmk_action_t *init_action, const pcmk_action_t *action, pcmk__related_action_t *input)
char * pcmk__notify_key(const char *rsc_id, const char *notify_type, const char *op_type)
void pcmk__create_graph(pcmk_scheduler_t *scheduler)
G_GNUC_INTERNAL bool pcmk__action_locks_rsc_to_node(const pcmk_action_t *action)
#define PCMK_META_INTERVAL
If 'then' is required, 'first' must be added to the transition graph.
bool pcmk__is_fencing_action(const char *action)
#define PCMK__XE_CRM_EVENT
void pe_foreach_guest_node(const pcmk_scheduler_t *scheduler, const pcmk_node_t *host, void(*helper)(const pcmk_node_t *, void *), void *user_data)
#define crm_err(fmt, args...)
pcmk_scheduler_t * scheduler
G_GNUC_INTERNAL void pcmk__substitute_remote_addr(pcmk_resource_t *rsc, GHashTable *params)
If 'first' is required and runnable, 'then' must be in graph.
Relation applies only if 'first' cannot be part of a live migration.
#define PCMK_ACTION_MIGRATE_FROM
gboolean crm_config_warning
G_GNUC_INTERNAL void pcmk__deduplicate_action_inputs(pcmk_action_t *action)
void hash2metafield(gpointer key, gpointer value, gpointer user_data)
Set XML attribute based on hash table entry, as meta-attribute name.
#define PCMK_OPT_MIGRATION_LIMIT
#define pcmk__set_action_flags(action, flags_to_set)
#define crm_log_xml_trace(xml, text)
#define action_optional_str(flags)
#define action_node_str(a)
GHashTable * pe_rsc_params(pcmk_resource_t *rsc, const pcmk_node_t *node, pcmk_scheduler_t *scheduler)
Get a table of resource parameters.
#define action_runnable_str(flags)
xmlNode * pcmk__xe_create(xmlNode *parent, const char *name)
'then' action is runnable if certain number of 'first' instances are
void pcmk__insert_dup(GHashTable *table, const char *name, const char *value)
#define PCMK__XE_MAINTENANCE
#define PCMK__XA_NODE_IN_MAINTENANCE
#define PCMK_ACTION_NOTIFY
No relation (compare with equality rather than bit set)