12 #include <sys/param.h> 33 free_graph_action(gpointer user_data)
39 g_source_remove(
action->timer);
41 if (
action->params != NULL) {
42 g_hash_table_destroy(
action->params);
55 free_graph_synapse(gpointer user_data)
59 g_list_free_full(synapse->
actions, free_graph_action);
60 g_list_free_full(synapse->
inputs, free_graph_action);
74 g_list_free_full(graph->
synapses, free_graph_synapse);
114 for (GList *lpc = synapse->
inputs; lpc != NULL; lpc = lpc->next) {
117 if (prereq->
id == action_id) {
118 crm_trace(
"Confirming input %d of synapse %d",
119 action_id, synapse->
id);
124 crm_trace(
"Synapse %d still not ready after action %d",
125 synapse->
id, action_id);
129 crm_trace(
"Synapse %d is now ready to execute", synapse->
id);
143 bool all_confirmed =
true;
145 for (GList *lpc = synapse->
actions; lpc != NULL; lpc = lpc->next) {
148 if (
action->id == action_id) {
149 crm_trace(
"Confirmed action %d of synapse %d",
150 action_id, synapse->
id);
153 }
else if (all_confirmed &&
155 all_confirmed =
false;
156 crm_trace(
"Synapse %d still not confirmed after action %d",
157 synapse->
id, action_id);
178 for (GList *lpc = graph->
synapses; lpc != NULL; lpc = lpc->next) {
181 if (pcmk_any_flags_set(synapse->
flags,
186 update_synapse_confirmed(synapse,
action->id);
190 update_synapse_ready(synapse,
action->id);
218 crm_debug(
"Setting custom functions for executing transition graphs");
237 for (lpc = synapse->
inputs; lpc != NULL; lpc = lpc->next) {
241 crm_trace(
"Input %d for synapse %d not yet confirmed",
242 prereq->
id, synapse->
id);
249 crm_trace(
"Input %d for synapse %d confirmed but failed",
250 prereq->
id, synapse->
id);
256 crm_trace(
"Synapse %d is ready to execute", synapse->
id);
261 for (lpc = synapse->
actions; lpc != NULL; lpc = lpc->next) {
268 crm_trace(
"Skipping synapse %d: priority %d is less than " 274 }
else if (graph_fns->
allowed && !(graph_fns->
allowed(graph, a))) {
275 crm_trace(
"Deferring synapse %d: not allowed", synapse->
id);
295 const char *
id = pcmk__xe_id(
action->xml);
314 crm_trace(
"Executing fencing action %d (%s)",
342 for (GList *lpc = synapse->
actions; lpc != NULL; lpc = lpc->next) {
344 int rc = initiate_action(graph,
action);
375 static int fail = -1;
381 && (fail_ll > 0LL) && (fail_ll <= INT_MAX)) {
382 fail = (int) fail_ll;
389 crm_err(
"Dummy event handler: pretending action %d failed",
action->id);
419 int log_level = LOG_DEBUG;
421 const char *status =
"In progress";
423 if (graph_fns == NULL) {
424 graph_fns = &default_fns;
437 for (lpc = graph->
synapses; lpc != NULL; lpc = lpc->next) {
448 crm_trace(
"Executing graph %d (%d synapses already completed, %d pending)",
452 for (lpc = graph->
synapses; lpc != NULL; lpc = lpc->next) {
458 crm_debug(
"Throttling graph execution: batch limit (%d) reached",
466 }
else if (pcmk_any_flags_set(synapse->
flags,
471 }
else if (should_fire_synapse(graph, synapse)) {
473 if (fire_synapse(graph, synapse) !=
pcmk_rc_ok) {
474 crm_err(
"Synapse %d failed to fire", synapse->
id);
495 log_level = LOG_WARNING;
497 status =
"Terminated";
499 }
else if (graph->
skipped != 0) {
500 log_level = LOG_NOTICE;
505 log_level = LOG_NOTICE;
510 }
else if (graph->
fired == 0) {
515 "Transition %d (Complete=%d, Pending=%d," 516 " Fired=%d, Skipped=%d, Incomplete=%d, Source=%s): %s",
542 const char *value = pcmk__xe_id(xml_action);
561 crm_err(
"Ignoring transition graph action of unknown type '%s' (bug?)",
569 crm_perror(LOG_CRIT,
"Cannot unpack transition graph action");
578 action->type = action_type;
592 action->timeout += start_delay;
612 "is deprecated and will be removed in a future release");
631 unpack_synapse(
pcmk__graph_t *new_graph,
const xmlNode *xml_synapse)
633 const char *value = NULL;
634 xmlNode *action_set = NULL;
637 crm_trace(
"Unpacking synapse %s", pcmk__xe_id(xml_synapse));
640 if (new_synapse == NULL) {
650 free_graph_synapse((gpointer) new_synapse);
return NULL);
654 crm_trace(
"Unpacking synapse %s action sets",
668 if (new_action == NULL) {
672 crm_trace(
"Adding action %d to synapse %d",
673 new_action->
id, new_synapse->id);
675 new_synapse->actions = g_list_append(new_synapse->actions,
680 crm_trace(
"Unpacking synapse %s inputs", pcmk__xe_id(xml_synapse));
697 if (new_input == NULL) {
701 crm_trace(
"Adding input %d to synapse %d",
702 new_input->
id, new_synapse->id);
704 new_synapse->inputs = g_list_append(new_synapse->inputs,
744 if (new_graph == NULL) {
748 new_graph->
source = strdup(pcmk__s(reference,
"unknown"));
749 if (new_graph->
source == NULL) {
757 if (xml_graph != NULL) {
807 if (new_synapse != NULL) {
813 crm_debug(
"Unpacked transition %d from %s: %d actions in %d synapses",
840 int status,
int rc,
const char *exit_reason)
844 const char *
name = NULL;
845 const char *value = NULL;
846 xmlNode *action_resource = NULL;
861 op->
t_run = time(NULL);
865 g_hash_table_iter_init(&iter,
action->params);
866 while (g_hash_table_iter_next(&iter, (
void **)&
name, (
void **)&value)) {
871 xop != NULL; xop = pcmk__xe_next(xop)) {
876 crm_debug(
"Got call_id=%d for %s", tmp, pcmk__xe_id(resource));
#define CRM_CHECK(expr, failure_action)
#define PCMK__XA_PRIORITY
xmlNode * pcmk__xml_copy(xmlNode *parent, xmlNode *src)
#define pcmk__set_synapse_flags(synapse, flags_to_set)
int pcmk__scan_min_int(const char *text, int *result, int minimum)
lrmd_event_data_t * pcmk__event_from_graph_action(const xmlNode *resource, const pcmk__graph_action_t *action, int status, int rc, const char *exit_reason)
#define PCMK_XE_PRIMITIVE
void pcmk__free_graph(pcmk__graph_t *graph)
char * failed_start_offset
Failcount after one failed start action.
#define PCMK__XE_PSEUDO_EVENT
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
int crm_element_value_int(const xmlNode *data, const char *name, int *dest)
Retrieve the integer value of an XML attribute.
enum pcmk__graph_action_type type
int(* pseudo)(pcmk__graph_t *graph, pcmk__graph_action_t *action)
#define PCMK_XA_OPERATION
int(* fence)(pcmk__graph_t *graph, pcmk__graph_action_t *action)
void pcmk__update_graph(pcmk__graph_t *graph, const pcmk__graph_action_t *action)
char int pcmk_parse_interval_spec(const char *input, guint *result_ms)
Parse milliseconds from a Pacemaker interval specification.
int pcmk__scan_ll(const char *text, long long *result, long long default_value)
#define crm_warn(fmt, args...)
GHashTable * xml2list(const xmlNode *parent)
Retrieve XML attributes as a hash table.
#define PCMK_OPT_BATCH_LIMIT
int pcmk__guint_from_hash(GHashTable *table, const char *key, guint default_val, guint *result)
char * failed_stop_offset
Failcount after one failed stop action.
#define crm_debug(fmt, args...)
enum pcmk__graph_next completion_action
char * crm_element_value_copy(const xmlNode *data, const char *name)
Retrieve a copy of the value of an XML attribute.
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
xmlNode * pcmk__xe_first_child(const xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
#define PCMK_META_START_DELAY
#define crm_trace(fmt, args...)
#define do_crm_log(level, fmt, args...)
Log a message.
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
time_t recheck_by
Time (from epoch) by which the controller should re-run the scheduler.
pcmk__graph_t * pcmk__unpack_graph(const xmlNode *xml_graph, const char *reference)
Wrappers for and extensions to libxml2.
enum pcmk__graph_status pcmk__execute_graph(pcmk__graph_t *graph)
#define crm_log_xml_warn(xml, text)
int crm_element_value_epoch(const xmlNode *xml, const char *name, time_t *dest)
Retrieve the seconds-since-epoch value of an XML attribute.
#define PCMK_ACTION_STONITH
#define PCMK_OPT_CLUSTER_DELAY
#define pcmk__clear_graph_action_flags(action, flags_to_clear)
#define pcmk__clear_synapse_flags(synapse, flags_to_clear)
void free_xml(xmlNode *child)
bool(* allowed)(pcmk__graph_t *graph, pcmk__graph_action_t *action)
void pcmk__set_graph_functions(pcmk__graph_functions_t *fns)
#define PCMK_META_TIMEOUT
#define pcmk__assert(expr)
#define PCMK_OPT_STONITH_TIMEOUT
int crm_str_to_boolean(const char *s, int *ret)
#define PCMK_META_INTERVAL
GHashTable * pcmk__strkey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
#define crm_perror(level, fmt, args...)
Send a system error message to both the log and stderr.
int(* rsc)(pcmk__graph_t *graph, pcmk__graph_action_t *action)
#define PCMK__XE_CRM_EVENT
#define crm_err(fmt, args...)
#define pcmk__set_graph_action_flags(action, flags_to_set)
void lrmd__set_result(lrmd_event_data_t *event, enum ocf_exitcode rc, int op_status, const char *exit_reason)
#define PCMK_OPT_MIGRATION_LIMIT
#define PCMK__META_CAN_FAIL
int(* cluster)(pcmk__graph_t *graph, pcmk__graph_action_t *action)
#define crm_log_xml_trace(xml, text)
const char * crm_meta_value(GHashTable *hash, const char *field)
Get the value of a meta-attribute.
lrmd_event_data_t * lrmd_new_event(const char *rsc_id, const char *task, guint interval_ms)
Create a new lrmd_event_data_t object.
xmlNode * pcmk__xe_next_same(const xmlNode *node)
void pcmk__insert_dup(GHashTable *table, const char *name, const char *value)
#define PCMK_SCORE_INFINITY
Integer score to use to represent "infinity".