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->priv->name) 45 add_node_to_xml_by_id(
const char *
id, xmlNode *xml)
65 add_node_to_xml_by_id(node->
priv->
id, (xmlNode *) xml);
81 xmlNode *maintenance = NULL;
88 iter != NULL; iter = iter->next) {
91 if (!pcmk__is_pacemaker_remote_node(node)) {
99 if (maintenance != NULL) {
108 crm_trace(
"%s %d nodes in need of maintenance mode update in state",
109 ((maintenance == NULL)?
"Counted" :
"Added"), count);
124 if (add_maintenance_nodes(NULL,
scheduler) != 0) {
151 add_node_to_xml_by_id(
action->node->priv->id, downed);
157 const char *fence = g_hash_table_lookup(
action->meta,
162 add_node_to_xml_by_id(
action->node->priv->id, downed);
164 action->node, add_node_to_xml, downed);
167 }
else if ((
action->rsc != NULL)
178 bool migrating =
false;
180 for (iter =
action->actions_before; iter != NULL; iter = iter->next) {
182 if ((
input->rsc != NULL)
192 add_node_to_xml_by_id(
action->rsc->id, downed);
210 const char *n_type = g_hash_table_lookup(
action->meta,
"notify_type");
211 const char *n_task = g_hash_table_lookup(
action->meta,
236 if (router_node != NULL) {
251 xmlNode *rsc_xml = NULL;
252 const char *attr_list[] = {
264 (
long long)
action->rsc->priv->lock_time);
270 (
const char *)
action->rsc->priv->xml->name);
272 && (
action->rsc->priv->history_id != NULL)) {
281 crm_debug(
"Using orphan clone name %s instead of history ID %s",
287 const char *xml_id = pcmk__xe_id(
action->rsc->priv->xml);
289 crm_debug(
"Using anonymous clone name %s for %s (aka %s)",
290 xml_id,
action->rsc->id,
action->rsc->priv->history_id);
306 if ((
action->rsc->priv->history_id != NULL)
307 && !pcmk__str_eq(xml_id,
action->rsc->priv->history_id,
310 action->rsc->priv->history_id);
320 for (
int lpc = 0; lpc <
PCMK__NELEM(attr_list); lpc++) {
322 g_hash_table_lookup(
action->rsc->priv->meta,
337 xmlNode *args_xml = NULL;
349 if ((rsc != NULL) && (
action->node != NULL)) {
358 }
else if ((rsc != NULL)
393 bool needs_node_info =
true;
394 bool needs_maintenance_info =
false;
395 xmlNode *action_xml = NULL;
425 needs_maintenance_info =
true;
428 needs_node_info =
false;
437 if ((
action->rsc != NULL) && (
action->rsc->priv->history_id != NULL)) {
438 char *clone_key = NULL;
445 clone_key = clone_op_key(
action, interval_ms);
454 if (needs_node_info && (
action->node != NULL)) {
455 add_node_details(
action, action_xml);
457 action->node->priv->name);
470 add_resource_details(
action, action_xml);
474 add_action_attributes(
action, action_xml);
477 if (needs_node_info && (
action->node != NULL)) {
478 add_downed_nodes(action_xml,
action);
481 if (needs_maintenance_info) {
482 add_maintenance_nodes(action_xml,
scheduler);
498 crm_trace(
"Ignoring action %s (%d): unrunnable",
505 crm_trace(
"Ignoring action %s (%d): optional",
517 const char *interval_ms_s;
526 crm_trace(
"Ignoring action %s (%d): for unmanaged resource (%s)",
541 if (
action->node == NULL) {
543 "Skipping action %s (%d) " 544 "because it was not assigned to a node (bug?)",
551 crm_trace(
"Action %s (%d) should be dumped: " 552 "can run on DC instead of %s",
555 }
else if (pcmk__is_guest_or_bundle_node(
action->node)
558 crm_trace(
"Action %s (%d) should be dumped: " 559 "assuming will be runnable on guest %s",
562 }
else if (!
action->node->details->online) {
564 "Skipping action %s (%d) " 565 "because it was scheduled for offline node (bug?)",
570 }
else if (
action->node->details->unclean) {
572 "Skipping action %s (%d) " 573 "because it was scheduled for unclean node (bug?)",
592 return pcmk_any_flags_set(ordering->
flags,
613 if (
input->graphed) {
618 crm_trace(
"Ignoring %s (%d) input %s (%d): " 625 && !ordering_can_change_actions(
input)) {
626 crm_trace(
"Ignoring %s (%d) input %s (%d): " 627 "optional and input unrunnable",
634 crm_trace(
"Ignoring %s (%d) input %s (%d): " 635 "minimum number of instances required but input unrunnable",
642 crm_trace(
"Ignoring %s (%d) input %s (%d): " 643 "input blocked if 'then' unmigratable",
650 crm_trace(
"Ignoring %s (%d) input %s (%d): ordering applies " 651 "only if input is unmigratable, but it is migratable",
659 crm_trace(
"Ignoring %s (%d) input %s (%d): " 660 "optional but stop in migration",
678 if (!pcmk__same_node(input_node, assigned)) {
679 crm_trace(
"Ignoring %s (%d) input %s (%d): " 680 "migration target %s is not same as input node %s",
683 (assigned? assigned->
priv->
name :
"<none>"),
684 (input_node? input_node->
priv->
name :
"<none>"));
689 }
else if (!pcmk__same_node(input_node,
action->node)) {
690 crm_trace(
"Ignoring %s (%d) input %s (%d): " 691 "not on same node (%s vs %s)",
695 (input_node? input_node->
priv->
name :
"<none>"));
700 crm_trace(
"Ignoring %s (%d) input %s (%d): " 710 && !pcmk__same_node(
input->action->node,
action->node)) {
711 crm_trace(
"Ignoring %s (%d) input %s (%d): " 712 "not on same node (%s vs %s)",
715 pcmk__node_name(
action->node),
716 pcmk__node_name(
input->action->node));
721 crm_trace(
"Ignoring %s (%d) input %s (%d): optional",
728 }
else if (
input->action->rsc
733 && pcmk__is_clone(
action->rsc)) {
734 crm_warn(
"Ignoring requirement that %s complete before %s:" 735 " unmanaged failed resources cannot prevent clone shutdown",
740 && !pcmk_any_flags_set(
input->action->flags,
743 && !should_add_action_to_graph(
input->action)) {
744 crm_trace(
"Ignoring %s (%d) input %s (%d): " 751 crm_trace(
"%s (%d) input %s %s (%d) on %s should be dumped: %s %s %#.6x",
776 bool has_loop =
false;
779 crm_trace(
"Breaking tracking loop: %s@%s -> %s@%s (%#.6x)",
781 input->action->node?
input->action->node->priv->name :
"",
793 if (
input->action == init_action) {
794 crm_debug(
"Input loop found in %s@%s ->...-> %s@%s",
804 crm_trace(
"Checking inputs of action %s@%s input %s@%s (%#.6x)" 805 "for graph loop with %s@%s ",
809 input->action->node?
input->action->node->priv->name :
"",
815 for (GList *iter =
input->action->actions_before;
816 iter != NULL; iter = iter->next) {
829 crm_trace(
"No input loop found in %s@%s -> %s@%s (%#.6x)",
831 input->action->node?
input->action->node->priv->name :
"",
851 int synapse_priority = 0;
856 if (
action->rsc != NULL) {
857 synapse_priority =
action->rsc->priv->priority;
859 if (
action->priority > synapse_priority) {
860 synapse_priority =
action->priority;
862 if (synapse_priority > 0) {
885 add_action_to_graph(gpointer
data, gpointer user_data)
904 || !should_add_action_to_graph(
action)) {
909 crm_trace(
"Adding action %d (%s%s%s) to graph",
911 ((
action->node == NULL)?
"" :
" on "),
912 ((
action->node == NULL)?
"" :
action->node->priv->name));
920 for (GList *lpc =
action->actions_before; lpc != NULL; lpc = lpc->next) {
926 input->graphed =
true;
932 static int transition_id = 0;
943 const char *filename)
947 crm_err(
"Calculated transition %d (with errors)%s%s",
949 (filename == NULL)?
"" :
", saving inputs in ",
950 (filename == NULL)?
"" : filename);
954 crm_warn(
"Calculated transition %d (with warnings)%s%s",
956 (filename == NULL)?
"" :
", saving inputs in ",
957 (filename == NULL)?
"" : filename);
962 (filename == NULL)?
"" :
", saving inputs in ",
963 (filename == NULL)?
"" : filename);
966 crm_notice(
"Configuration errors found during scheduler processing," 967 " please run \"crm_verify -L\" to identify issues");
987 g_list_foreach(rsc->
priv->
actions, add_action_to_graph,
991 for (iter = rsc->
priv->
children; iter != NULL; iter = iter->next) {
1008 const char *value = NULL;
1009 long long limit = 0LL;
1014 crm_trace(
"Creating transition graph %d", transition_id);
1044 }
else if (limit > 0) {
1049 char *recheck_epoch = NULL;
1054 free(recheck_epoch);
1077 if ((
action->rsc != NULL)
1078 && (
action->node != NULL)
1079 &&
action->node->details->shutdown
1081 && !pcmk_any_flags_set(
action->flags,
1095 crm_crit(
"Cannot %s %s because of %s:%s%s (%s)",
1096 action->node->details->unclean?
"fence" :
"shut down",
1098 (managed?
" blocked" :
" unmanaged"),
1099 (failed?
" failed" :
""),
action->uuid);
#define PCMK__XE_ACTION_SET
#define PCMK__XA_OPERATION_KEY
#define CRM_CHECK(expr, failure_action)
#define PCMK__XA_PRIORITY
#define crm_notice(fmt, args...)
#define pcmk__sched_err(scheduler, fmt...)
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
#define PCMK_VALUE_INFINITY
bool pcmk__strcase_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
#define action_type_str(flags)
#define pcmk__rsc_trace(rsc, fmt, args...)
#define PCMK_OPT_SHUTDOWN_LOCK
#define PCMK_ACTION_MONITOR
#define PCMK__XE_PSEUDO_EVENT
#define PCMK__XE_ATTRIBUTES
pcmk__scheduler_private_t * priv
void pcmk__xe_sort_attrs(xmlNode *xml)
#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 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.
void(* add_actions_to_graph)(pcmk_resource_t *rsc)
#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
#define PCMK__XA_FAILED_STOP_OFFSET
xmlNode * pcmk__xe_create(xmlNode *parent, const char *name)
enum pe_quorum_policy no_quorum_policy
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(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
#define PCMK_ACTION_MAINTENANCE_NODES
pcmk__node_private_t * priv
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...)
pcmk_scheduler_t * scheduler
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)
bool pcmk__config_has_error
enum pcmk__rsc_variant variant
#define crm_trace(fmt, args...)
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
#define PCMK__XA_FAILED_START_OFFSET
pcmk__resource_private_t * priv
#define PCMK__META_ON_NODE_UUID
void pcmk__log_transition_summary(const pcmk_scheduler_t *scheduler, const char *filename)
Wrappers for and extensions to libxml2.
Ordering applies only if 'first' is required and on same node as 'then'.
#define PCMK_ACTION_STONITH
Act as if partition still holds quorum.
#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)
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
#define pcmk__assert(expr)
bool pcmk__config_has_warning
#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
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)
struct pcmk__node_details * details
'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
const pcmk__assignment_methods_t * cmds
#define PCMK__XA_NODE_IN_MAINTENANCE
#define PCMK_ACTION_NOTIFY
No relation (compare with equality rather than bit set)
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
Create an XML attribute with specified name and integer value.