12 #include <sys/param.h> 54 for (GList *lpc = synapse->
inputs; lpc != NULL; lpc = lpc->next) {
57 if (prereq->
id == action_id) {
58 crm_trace(
"Confirming input %d of synapse %d",
59 action_id, synapse->
id);
64 crm_trace(
"Synapse %d still not ready after action %d",
65 synapse->
id, action_id);
69 crm_trace(
"Synapse %d is now ready to execute", synapse->
id);
83 bool all_confirmed =
true;
85 for (GList *lpc = synapse->
actions; lpc != NULL; lpc = lpc->next) {
88 if (
action->id == action_id) {
89 crm_trace(
"Confirmed action %d of synapse %d",
90 action_id, synapse->
id);
93 }
else if (all_confirmed &&
95 all_confirmed =
false;
96 crm_trace(
"Synapse %d still not confirmed after action %d",
97 synapse->
id, action_id);
118 for (GList *lpc = graph->
synapses; lpc != NULL; lpc = lpc->next) {
121 if (pcmk_any_flags_set(synapse->
flags,
126 update_synapse_confirmed(synapse,
action->id);
130 update_synapse_ready(synapse,
action->id);
155 crm_debug(
"Setting custom functions for executing transition graphs");
180 for (lpc = synapse->
inputs; lpc != NULL; lpc = lpc->next) {
184 crm_trace(
"Input %d for synapse %d not yet confirmed",
185 prereq->
id, synapse->
id);
192 crm_trace(
"Input %d for synapse %d confirmed but failed",
193 prereq->
id, synapse->
id);
199 crm_trace(
"Synapse %d is ready to execute", synapse->
id);
204 for (lpc = synapse->
actions; lpc != NULL; lpc = lpc->next) {
211 crm_trace(
"Skipping synapse %d: priority %d is less than " 217 }
else if (graph_fns->
allowed && !(graph_fns->
allowed(graph, a))) {
218 crm_trace(
"Deferring synapse %d: not allowed", synapse->
id);
257 crm_trace(
"Executing fencing action %d (%s)",
285 for (GList *lpc = synapse->
actions; lpc != NULL; lpc = lpc->next) {
287 int rc = initiate_action(graph,
action);
318 static int fail = -1;
324 && (fail_ll > 0LL) && (fail_ll <= INT_MAX)) {
325 fail = (int) fail_ll;
332 crm_err(
"Dummy event handler: pretending action %d failed",
action->id);
362 int log_level = LOG_DEBUG;
364 const char *status =
"In progress";
366 if (graph_fns == NULL) {
367 graph_fns = &default_fns;
380 for (lpc = graph->
synapses; lpc != NULL; lpc = lpc->next) {
391 crm_trace(
"Executing graph %d (%d synapses already completed, %d pending)",
395 for (lpc = graph->
synapses; lpc != NULL; lpc = lpc->next) {
401 crm_debug(
"Throttling graph execution: batch limit (%d) reached",
409 }
else if (pcmk_any_flags_set(synapse->
flags,
414 }
else if (should_fire_synapse(graph, synapse)) {
416 if (fire_synapse(graph, synapse) !=
pcmk_rc_ok) {
417 crm_err(
"Synapse %d failed to fire", synapse->
id);
438 log_level = LOG_WARNING;
440 status =
"Terminated";
442 }
else if (graph->
skipped != 0) {
443 log_level = LOG_NOTICE;
448 log_level = LOG_NOTICE;
453 }
else if (graph->
fired == 0) {
458 "Transition %d (Complete=%d, Pending=%d," 459 " Fired=%d, Skipped=%d, Incomplete=%d, Source=%s): %s",
485 const char *value =
ID(xml_action);
488 crm_err(
"Ignoring transition graph action without id (bug?)");
503 crm_err(
"Ignoring transition graph action of unknown type '%s' (bug?)",
511 crm_perror(LOG_CRIT,
"Cannot unpack transition graph action");
520 action->type = action_type;
523 value = g_hash_table_lookup(
action->params,
"CRM_meta_timeout");
527 value = g_hash_table_lookup(
action->params,
"CRM_meta_start_delay");
532 action->timeout += start_delay;
541 value = g_hash_table_lookup(
action->params,
"CRM_meta_can_fail");
551 #ifndef PCMK__COMPAT_2_0 553 crm_warn(
"Support for the can_fail meta-attribute is deprecated" 554 " and will be removed in a future release");
574 unpack_synapse(
pcmk__graph_t *new_graph,
const xmlNode *xml_synapse)
576 const char *value = NULL;
577 xmlNode *action_set = NULL;
580 crm_trace(
"Unpacking synapse %s",
ID(xml_synapse));
583 if (new_synapse == NULL) {
597 crm_trace(
"Unpacking synapse %s action sets",
603 for (xmlNode *
action = pcmk__xml_first_child(action_set);
609 if (new_action == NULL) {
613 crm_trace(
"Adding action %d to synapse %d",
614 new_action->
id, new_synapse->
id);
621 crm_trace(
"Unpacking synapse %s inputs",
ID(xml_synapse));
629 for (xmlNode *
input = pcmk__xml_first_child(trigger);
635 if (new_input == NULL) {
639 crm_trace(
"Adding input %d to synapse %d",
640 new_input->
id, new_synapse->
id);
642 new_synapse->
inputs = g_list_append(new_synapse->
inputs,
682 if (new_graph == NULL) {
686 new_graph->
source = strdup((reference == NULL)?
"unknown" : reference);
687 if (new_graph->
source == NULL) {
699 if (xml_graph != NULL) {
747 if (new_synapse != NULL) {
753 crm_debug(
"Unpacked transition %d from %s: %d actions in %d synapses",
772 free_graph_action(gpointer user_data)
778 g_source_remove(
action->timer);
780 if (
action->params != NULL) {
781 g_hash_table_destroy(
action->params);
794 free_graph_synapse(gpointer user_data)
798 g_list_free_full(synapse->
actions, free_graph_action);
799 g_list_free_full(synapse->
inputs, free_graph_action);
813 g_list_free_full(graph->
synapses, free_graph_synapse);
841 int status,
int rc,
const char *exit_reason)
845 const char *
name = NULL;
846 const char *value = NULL;
847 xmlNode *action_resource = NULL;
860 op->
t_run = time(NULL);
864 g_hash_table_iter_init(&iter,
action->params);
865 while (g_hash_table_iter_next(&iter, (
void **)&
name, (
void **)&value)) {
866 g_hash_table_insert(op->
params, strdup(
name), strdup(value));
869 for (xmlNode *xop = pcmk__xml_first_child(resource); xop != NULL;
870 xop = pcmk__xml_next(xop)) {
874 crm_debug(
"Got call_id=%d for %s", tmp,
ID(resource));
#define CRM_CHECK(expr, failure_action)
#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)
void pcmk__free_graph(pcmk__graph_t *graph)
char * failed_start_offset
Failcount after one failed start action.
xmlNode * first_named_child(const xmlNode *parent, const char *name)
#define XML_LRM_ATTR_INTERVAL
#define XML_GRAPH_TAG_RSC_OP
#define XML_GRAPH_TAG_CRM_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 XML_GRAPH_TAG_PSEUDO_EVENT
int(* fence)(pcmk__graph_t *graph, pcmk__graph_action_t *action)
#define XML_CIB_ATTR_PRIORITY
void pcmk__update_graph(pcmk__graph_t *graph, const pcmk__graph_action_t *action)
xmlNode * copy_xml(xmlNode *src_node)
#define XML_LRM_ATTR_TASK
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.
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
const char * crm_element_value(const xmlNode *data, const char *name)
Retrieve the value of an XML attribute.
#define XML_CIB_TAG_RESOURCE
#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)
void pcmk__str_update(char **str, const char *value)
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__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)
int crm_str_to_boolean(const char *s, int *ret)
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 crm_err(fmt, args...)
#define pcmk__set_graph_action_flags(action, flags_to_set)
char guint crm_parse_interval_spec(const char *input)
Parse milliseconds from a Pacemaker interval specification.
void lrmd__set_result(lrmd_event_data_t *event, enum ocf_exitcode rc, int op_status, const char *exit_reason)
#define XML_LRM_ATTR_CALLID
int(* cluster)(pcmk__graph_t *graph, pcmk__graph_action_t *action)
#define crm_log_xml_trace(xml, text)
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 * crm_next_same_xml(const xmlNode *sibling)
Get next instance of same XML tag.