34 crm_trace(
"%s: online=%d, unclean=%d, standby=%d, maintenance=%d",
53 GHashTable *new_table = NULL;
61 g_hash_table_iter_init(&iter, nodes);
62 while (g_hash_table_iter_next(&iter, NULL, (gpointer *) &node)) {
65 g_hash_table_insert(new_table, (gpointer) new_node->
details->
id,
85 for (
const GList *gIter = list; gIter != NULL; gIter = gIter->next) {
93 result = g_list_prepend(result, new_node);
98 struct node_weight_s {
108 sort_node_weight(gconstpointer a, gconstpointer b, gpointer
data)
112 struct node_weight_s *nw =
data;
114 int node1_weight = 0;
115 int node2_weight = 0;
126 node1_weight = node1->
weight;
127 node2_weight = node2->
weight;
136 if (node1_weight > node2_weight) {
142 if (node1_weight < node2_weight) {
151 if (pcmk__str_eq(nw->data_set->placement_strategy,
"minimal",
pcmk__str_casei)) {
155 if (pcmk__str_eq(nw->data_set->placement_strategy,
"balanced",
pcmk__str_casei)) {
161 }
else if (result > 0) {
170 crm_trace(
"%s (%d) > %s (%d) : resources",
176 crm_trace(
"%s (%d) < %s (%d) : resources",
182 if (nw->active && nw->active->details == node1->
details) {
187 }
else if (nw->active && nw->active->details == node2->
details) {
202 struct node_weight_s nw = { active_node, data_set };
204 return g_list_sort_with_data(nodes, sort_node_weight, &nw);
232 if (force == FALSE && chosen != NULL) {
244 crm_debug(
"All nodes for resource %s are unavailable" 245 ", unclean or shutting down (%s: %d, %d)",
259 if (chosen == NULL) {
263 crm_debug(
"Could not allocate a node for %s", rsc->
id);
266 for (gIter = rsc->
actions; gIter != NULL; gIter = gIter->next) {
278 }
else if (interval_ms_s && !pcmk__str_eq(interval_ms_s,
"0",
pcmk__str_casei)) {
302 out->
message(out,
"resource-util", rsc, chosen, __func__);
311 const char *node_uname = NULL;
312 const char *node_uuid = NULL;
313 const char *desc = NULL;
316 crm_trace(
"%s%s: <NULL>", pre_text == NULL ?
"" : pre_text, pre_text == NULL ?
"" :
": ");
324 }
else if (
action->node != NULL) {
325 node_uname =
action->node->details->uname;
326 node_uuid =
action->node->details->id;
328 node_uname =
"<none>";
340 desc =
"!!Non-Startable!! ";
344 desc =
"(Provisional) ";
346 crm_trace(
"%s%s%sAction %d: %s%s%s%s%s%s",
347 ((pre_text == NULL)?
"" : pre_text),
348 ((pre_text == NULL)?
"" :
": "),
350 (node_uname?
"\ton " :
""), (node_uname? node_uname :
""),
351 (node_uuid?
"\t\t(" :
""), (node_uuid? node_uuid :
""),
352 (node_uuid?
")" :
""));
360 desc =
"!!Non-Startable!! ";
364 desc =
"(Provisional) ";
366 crm_trace(
"%s%s%sAction %d: %s %s%s%s%s%s%s",
367 ((pre_text == NULL)?
"" : pre_text),
368 ((pre_text == NULL)?
"" :
": "),
371 (node_uname?
"\ton " :
""), (node_uname? node_uname :
""),
372 (node_uuid?
"\t\t(" :
""), (node_uuid? node_uuid :
""),
373 (node_uuid?
")" :
""));
380 crm_trace(
"\t\t====== Preceding Actions");
382 gIter =
action->actions_before;
383 for (; gIter != NULL; gIter = gIter->next) {
389 crm_trace(
"\t\t====== Subsequent Actions");
391 gIter =
action->actions_after;
392 for (; gIter != NULL; gIter = gIter->next) {
402 g_list_length(
action->actions_before), g_list_length(
action->actions_after));
416 g_hash_table_iter_init(&iter, nodes);
417 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
430 task, NULL, optional, TRUE, data_set);
464 free(cancel_op->
task);
493 node, FALSE, TRUE, data_set);
501 generate_transition_magic(
const char *transition_key,
int op_status,
int op_rc)
503 CRM_CHECK(transition_key != NULL,
return NULL);
509 const char *magic,
int level)
516 xmlNode *args_xml = NULL;
532 do_crm_log(level,
"Calculated digest %s for %s (%s). Source: %s\n",
533 digest,
ID(update), magic, digest_source);
543 #define FAKE_TE_ID "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" 561 const char *caller_version,
int target_rc,
562 const char *node,
const char *origin,
int level)
567 char *op_id_additional = NULL;
568 char *local_user_data = NULL;
569 const char *exit_reason = NULL;
571 xmlNode *xml_op = NULL;
572 const char *task = NULL;
575 do_crm_log(level,
"%s: Updating resource %s after %s op %s (interval=%u)",
579 crm_trace(
"DC version: %s", caller_version);
636 if (xml_op == NULL) {
671 "): last=%u change=%u exec=%u queue=%u",
681 (
long long) op->
t_run);
701 append_digest(op, xml_op, caller_version, magic, LOG_DEBUG);
703 if (op_id_additional) {
705 op_id = op_id_additional;
706 op_id_additional = NULL;
710 if (local_user_data) {
711 free(local_user_data);
725 const char* argv[] = {
"", NULL };
734 crm_err(
"Can't log resource details due to internal error: %s\n",
760 int fail_count, remaining_tries;
777 if (fail_count <= 0) {
789 if (remaining_tries <= 0) {
790 crm_warn(
"%s cannot run on %s due to reaching migration threshold " 791 "(clean up resource to allow again)" 792 CRM_XS " failures=%d migration-threshold=%d",
795 if (failed != NULL) {
796 *failed = rsc_to_ban;
801 crm_info(
"%s can fail %d more time%s on " 802 "%s before reaching migration threshold (%d)",
811 if (injections == NULL) {
815 g_list_free_full(injections->
node_up, g_free);
816 g_list_free_full(injections->
node_down, g_free);
817 g_list_free_full(injections->
node_fail, g_free);
818 g_list_free_full(injections->
op_fail, g_free);
819 g_list_free_full(injections->
op_inject, g_free);
#define CRM_CHECK(expr, failure_action)
#define XML_RSC_OP_LAST_CHANGE
bool pcmk__threshold_reached(pe_resource_t *rsc, pe_node_t *node, pe_working_set_t *data_set, pe_resource_t **failed)
void log_action(unsigned int log_level, const char *pre_text, pe_action_t *action, gboolean details)
#define PCMK__SUPPORTED_FORMAT_LOG
gboolean can_run_resources(const pe_node_t *node)
#define CRMD_ACTION_MIGRATED
#define pe__set_action_flags(action, flags_to_set)
void hash2field(gpointer key, gpointer value, gpointer user_data)
Set XML attribute based on hash table entry.
const char * crm_xml_add_ms(xmlNode *node, const char *name, guint ms)
Create an XML attribute with specified name and unsigned value.
#define XML_ATTR_TRANSITION_MAGIC
GList * pcmk__copy_node_list(const GList *list, bool reset)
pe_action_t * pe_cancel_op(pe_resource_t *rsc, const char *task, guint interval_ms, pe_node_t *node, pe_working_set_t *data_set)
int(* message)(pcmk__output_t *out, const char *message_id,...)
G_GNUC_INTERNAL void pcmk__order_stops_before_shutdown(pe_node_t *node, pe_action_t *shutdown_op, pe_working_set_t *data_set)
xmlNode * pcmk__create_history_xml(xmlNode *parent, lrmd_event_data_t *op, const char *caller_version, int target_rc, const char *node, const char *origin, int level)
const char * crm_xml_add_int(xmlNode *node, const char *name, int value)
Create an XML attribute with specified name and integer value.
#define CRMD_ACTION_NOTIFY
#define XML_RSC_OP_T_EXEC
const char * crm_meta_value(GHashTable *hash, const char *field)
xmlNode * pcmk__xe_match(xmlNode *parent, const char *node_name, const char *attr_n, const char *attr_v)
const char * crm_xml_add(xmlNode *node, const char *name, const char *value)
Create an XML attribute with specified name and value.
pe_node_t * pe__copy_node(const pe_node_t *this_node)
#define XML_LRM_ATTR_OP_DIGEST
pe_action_t * create_pseudo_resource_op(pe_resource_t *rsc, const char *task, bool optional, bool runnable, pe_working_set_t *data_set)
void pcmk__filter_op_for_digest(xmlNode *param_set)
enum action_tasks text2task(const char *task)
#define CRM_LOG_ASSERT(expr)
const char * pcmk_rc_str(int rc)
Get a user-friendly description of a return code.
void pcmk__register_formats(GOptionGroup *group, pcmk__supported_format_t *table)
#define XML_RSC_OP_T_QUEUE
pcmk__output_t * pcmk__new_logger(void)
#define pe__set_resource_flags(resource, flags_to_set)
void calculate_utilization(GHashTable *current_utilization, GHashTable *utilization, gboolean plus)
#define CRMD_ACTION_START
#define XML_LRM_ATTR_TASK_KEY
#define pe_rsc_provisional
#define XML_LRM_ATTR_TASK
char * calculate_operation_digest(xmlNode *local_cib, const char *version)
Calculate and return digest of XML operation.
#define crm_warn(fmt, args...)
#define CRMD_ACTION_RELOAD_AGENT
char * pcmk__notify_key(const char *rsc_id, const char *notify_type, const char *op_type)
#define crm_debug(fmt, args...)
pe_resource_t * uber_parent(pe_resource_t *rsc)
bool pe__is_guest_node(const pe_node_t *node)
#define pe__clear_action_flags(action, flags_to_clear)
void native_deallocate(pe_resource_t *rsc)
#define crm_trace(fmt, args...)
#define do_crm_log(level, fmt, args...)
Log a message.
char * crm_strdup_printf(char const *format,...) G_GNUC_PRINTF(1
GList * sort_nodes_by_weight(GList *nodes, pe_node_t *active_node, pe_working_set_t *data_set)
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
gboolean can_run_any(GHashTable *nodes)
struct pe_node_shared_s * details
void pcmk__register_lib_messages(pcmk__output_t *out)
#define XML_ATTR_TE_NOWAIT
xmlNode * create_xml_node(xmlNode *parent, const char *name)
Action completed, result is known.
GHashTable * pcmk__copy_node_table(GHashTable *nodes)
#define XML_LRM_ATTR_MIGRATE_TARGET
#define XML_LRM_ATTR_EXIT_REASON
void pe__register_messages(pcmk__output_t *out)
void free_xml(xmlNode *child)
enum pe_obj_types variant
bool pcmk__str_any_of(const char *s,...) G_GNUC_NULL_TERMINATED
char * pcmk__op_key(const char *rsc_id, const char *op_type, guint interval_ms)
Generate an operation key (RESOURCE_ACTION_INTERVAL)
void pcmk_free_injections(pcmk_injections_t *injections)
Free a :pcmk_injections_t structure.
#define CRMD_ACTION_RELOAD
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 XML_ATTR_TRANSITION_KEY
unsigned int get_crm_log_level(void)
GHashTable * pcmk__strkey_table(GDestroyNotify key_destroy_func, GDestroyNotify value_destroy_func)
void add_hash_param(GHashTable *hash, const char *name, const char *value)
#define pe_flag_show_utilization
gboolean did_rsc_op_fail(lrmd_event_data_t *event, int target_rc)
#define crm_err(fmt, args...)
void lrmd__set_result(lrmd_event_data_t *event, enum ocf_exitcode rc, int op_status, const char *exit_reason)
gboolean native_assign_node(pe_resource_t *rsc, pe_node_t *chosen, gboolean force)
void pe__set_next_role(pe_resource_t *rsc, enum rsc_role_e role, const char *why)
Synthetic cluster events that can be injected into the cluster for running simulations.
This structure contains everything that makes up a single output formatter.
int compare_version(const char *version1, const char *version2)
#define XML_LRM_ATTR_INTERVAL_MS
char * dump_xml_unformatted(xmlNode *msg)
#define XML_LRM_ATTR_CALLID
#define CRMD_ACTION_MIGRATE
#define pe__clear_resource_flags(resource, flags_to_clear)
#define XML_LRM_ATTR_OPSTATUS
#define XML_ATTR_CRM_VERSION
char * pcmk__transition_key(int transition_id, int action_id, int target_rc, const char *node)
#define pcmk__plural_s(i)
#define pe_rsc_failure_ignored
pe_working_set_t * cluster
pe_action_t * sched_shutdown_op(pe_node_t *node, pe_working_set_t *data_set)
int pcmk__output_new(pcmk__output_t **out, const char *fmt_name, const char *filename, char **argv)
#define XML_LRM_ATTR_TARGET
#define XML_LRM_TAG_RSC_OP
int compare_capacity(const pe_node_t *node1, const pe_node_t *node2)
#define XML_LRM_ATTR_MIGRATE_SOURCE
#define crm_info(fmt, args...)
#define XML_ATTR_TE_TARGET_RC
int pe_get_failcount(pe_node_t *node, pe_resource_t *rsc, time_t *last_failure, uint32_t flags, xmlNode *xml_op, pe_working_set_t *data_set)
pe_action_t * custom_action(pe_resource_t *rsc, char *key, const char *task, pe_node_t *on_node, gboolean optional, gboolean foo, pe_working_set_t *data_set)
Create or update an action object.
#define CRMD_ACTION_STATUS