76 check_for_role_change(
pe_resource_t *rsc,
bool *demoting,
bool *promoting)
82 for (iter = rsc->
children; iter != NULL; iter = iter->next) {
89 for (iter = rsc->
actions; iter != NULL; iter = iter->next) {
92 if (*promoting && *demoting) {
120 apply_promoted_locations(
pe_resource_t *child, GList *location_constraints,
123 for (GList *iter = location_constraints; iter; iter = iter->next) {
131 if (weighted_node != NULL) {
136 "Applying location %s to %s promotion priority on %s: " 138 location->
id, child->
id, pe__node_name(weighted_node),
161 for (GList *iter = rsc->
children; iter != NULL; iter = iter->next) {
164 if (node_to_be_promoted_on(child) == NULL) {
166 "%s can't be promoted because member %s can't",
174 pe_rsc_trace(rsc,
"%s can't be promoted because it won't be active",
180 crm_notice(
"Unmanaged instance %s will be left promoted on %s",
181 rsc->
id, pe__node_name(node));
183 pe_rsc_trace(rsc,
"%s can't be promoted because it is unmanaged",
190 "%s can't be promoted because its promotion priority %d " 196 pe_rsc_trace(rsc,
"%s can't be promoted because %s can't run resources",
197 rsc->
id, pe__node_name(node));
201 local_node = pe_hash_table_lookup(
parent->allowed_nodes, node->
details->
id);
203 if (local_node == NULL) {
209 crm_warn(
"%s can't be promoted because %s is not allowed on %s " 211 rsc->
id,
parent->id, pe__node_name(node));
218 "%s can't be promoted because %s has " 219 "maximum promoted instances already",
220 rsc->
id, pe__node_name(node));
239 cmp_promotable_instance(gconstpointer a, gconstpointer b)
252 "%s has higher promotion priority than %s " 253 "(sort index %d > %d)",
258 "%s has lower promotion priority than %s " 259 "(sort index %d < %d)",
269 "%s has higher promotion priority than %s " 270 "(higher current role)",
273 }
else if (role1 < role2) {
275 "%s has lower promotion priority than %s " 276 "(lower current role)",
297 add_sort_index_to_node_weight(gpointer
data, gpointer user_data)
306 pe_rsc_trace(clone,
"Not adding sort index of %s: negative", child->
id);
311 if (chosen == NULL) {
312 pe_rsc_trace(clone,
"Not adding sort index of %s: inactive", child->
id);
320 pe_rsc_trace(clone,
"Adding sort index %s of %s to weight for %s",
322 pe__node_name(node));
334 apply_coloc_to_dependent(gpointer
data, gpointer user_data)
348 pe_rsc_trace(clone,
"Applying colocation %s (promoted %s with %s) @%s",
364 apply_coloc_to_primary(gpointer
data, gpointer user_data)
374 || !pcmk__colocation_has_influence(constraint, NULL)) {
378 pe_rsc_trace(clone,
"Applying colocation %s (%s with promoted %s) @%s",
394 set_sort_index_to_node_weight(gpointer
data, gpointer user_data)
405 "Final sort index for %s is INFINITY (unmanaged promoted)",
408 }
else if ((chosen == NULL) || (child->
sort_index < 0)) {
410 "Final sort index for %s is %d (ignoring node weight)",
422 "Merging weights for %s: final sort index for %s is %d",
442 for (GList *iter = clone->
children; iter != NULL; iter = iter->next) {
446 "Merging weights for %s: initial sort index for %s is %d",
452 g_list_foreach(clone->
children, add_sort_index_to_node_weight, clone);
453 g_list_foreach(clone->
rsc_cons, apply_coloc_to_dependent, clone);
454 g_list_foreach(clone->
rsc_cons_lhs, apply_coloc_to_primary, clone);
463 g_list_foreach(clone->
children, set_sort_index_to_node_weight, clone);
481 find_active_anon_instance(
pe_resource_t *clone,
const char *
id,
484 for (GList *iter = clone->
children; iter; iter = iter->next) {
491 if (active != NULL) {
509 anonymous_known_on(
const pe_resource_t *clone,
const char *
id,
512 for (GList *iter = clone->
children; iter; iter = iter->next) {
544 return (allowed != NULL) && (allowed->
weight >= 0);
562 const char *reason =
"allowed";
568 active = find_active_anon_instance(
parent,
id, node);
577 if ((active == NULL) && anonymous_known_on(
parent,
id, node)) {
588 reason =
"none probed";
600 "Ignoring %s promotion score (for %s) on %s: not probed",
601 rsc->
id,
id, pe__node_name(node));
607 if (is_allowed(rsc, node)) {
608 pe_rsc_trace(rsc,
"Counting %s promotion score (for %s) on %s: %s",
609 rsc->
id,
id, pe__node_name(node), reason);
614 pe_rsc_trace(rsc,
"Ignoring %s promotion score (for %s) on %s: not allowed",
615 rsc->
id,
id, pe__node_name(node));
634 char *attr_name = NULL;
635 const char *attr_value = NULL;
637 CRM_CHECK((rsc != NULL) && (node != NULL) && (
name != NULL),
return NULL);
659 const char *attr_value = NULL;
661 if (is_default != NULL) {
665 CRM_CHECK((rsc != NULL) && (node != NULL),
return 0);
673 for (GList *iter = rsc->
children; iter != NULL; iter = iter->next) {
675 bool child_default =
false;
676 int child_score = promotion_score(child, node, &child_default);
678 if (!child_default && (is_default != NULL)) {
681 score += child_score;
686 if (!promotion_score_applies(rsc, node)) {
696 attr_value = promotion_attr_value(rsc, node,
name);
697 if (attr_value != NULL) {
699 name, pe__node_name(node), pcmk__s(attr_value,
"(unset)"));
706 if (strcmp(rsc->
id,
name) != 0) {
707 attr_value = promotion_attr_value(rsc, node,
name);
708 pe_rsc_trace(rsc,
"Promotion score for %s on %s (for %s) = %s",
709 name, pe__node_name(node), rsc->
id,
710 pcmk__s(attr_value,
"(unset)"));
715 if (attr_value == NULL) {
719 if (is_default != NULL) {
738 for (GList *iter = rsc->
children; iter != NULL; iter = iter->next) {
743 int score, new_score;
746 while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
754 score = promotion_score(child_rsc, node, NULL);
757 if (new_score != node->weight) {
759 "Adding promotion score to preference " 760 "for %s on %s (%d->%d)",
761 child_rsc->
id, pe__node_name(node),
762 node->weight, new_score);
763 node->weight = new_score;
769 "Updating %s priority to promotion score (%d->%d)",
785 set_current_role_unpromoted(
void *
data,
void *user_data)
793 g_list_foreach(rsc->
children, set_current_role_unpromoted, NULL);
804 set_next_role_unpromoted(
void *
data,
void *user_data)
807 GList *assigned = NULL;
810 if (assigned == NULL) {
814 g_list_free(assigned);
816 g_list_foreach(rsc->
children, set_next_role_unpromoted, NULL);
827 set_next_role_promoted(
void *
data, gpointer user_data)
834 g_list_foreach(rsc->
children, set_next_role_promoted, NULL);
853 out->
message(out,
"promotion-score", instance, chosen,
857 "%s promotion score on %s: sort=%s priority=%s",
859 ((chosen == NULL)?
"none" : pe__node_name(chosen)),
873 set_instance_priority(gpointer
data, gpointer user_data)
881 pe_rsc_trace(clone,
"Assigning priority for %s: %s", instance->
id,
885 set_current_role_unpromoted(instance, NULL);
889 chosen = instance->
fns->
location(instance, &list, FALSE);
890 if (pcmk__list_of_multiple(list)) {
895 if (chosen == NULL) {
899 next_role = instance->
fns->
state(instance, FALSE);
905 bool is_default =
false;
907 instance->
priority = promotion_score(instance, chosen,
934 next_role, instance->
id));
938 apply_promoted_locations(instance, instance->
rsc_location, chosen);
939 apply_promoted_locations(instance, clone->
rsc_location, chosen);
942 for (GList *iter = instance->
rsc_cons; iter != NULL; iter = iter->next) {
964 set_instance_role(gpointer
data, gpointer user_data)
967 int *count = (
int *) user_data;
972 show_promotion_score(instance);
975 pe_rsc_trace(clone,
"Not supposed to promote instance %s",
980 chosen = node_to_be_promoted_on(instance);
983 if (chosen == NULL) {
984 set_next_role_unpromoted(instance, NULL);
991 crm_notice(
"Clone instance %s cannot be promoted without quorum",
993 set_next_role_unpromoted(instance, NULL);
998 pe_rsc_info(clone,
"Choosing %s (%s) on %s for promotion",
1000 pe__node_name(chosen));
1001 set_next_role_promoted(instance, NULL);
1015 GHashTableIter iter;
1020 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
1025 g_list_foreach(rsc->
children, set_instance_priority, rsc);
1026 sort_promotable_instances(rsc);
1029 g_list_foreach(rsc->
children, set_instance_role, &promoted);
1030 pe_rsc_info(rsc,
"%s: Promoted %d instances of a possible %d",
1045 bool *any_promoting,
bool *any_demoting)
1047 for (GList *iter = clone->
children; iter != NULL; iter = iter->next) {
1051 check_for_role_change(instance, any_demoting, any_promoting);
1068 for (GList *iter = clone->
children; iter != NULL; iter = iter->next) {
1084 bool any_promoting =
false;
1085 bool any_demoting =
false;
1088 create_promotable_instance_actions(clone, &any_promoting, &any_demoting);
1094 reset_instance_priorities(clone);
1110 for (GList *iter = clone->
children; iter != NULL; iter = iter->next) {
1118 order_instance_promotion(clone, instance, previous);
1119 order_instance_demotion(clone, instance, previous);
1120 previous = instance;
1137 GHashTableIter iter;
1139 const char *primary_value = NULL;
1140 const char *attr = NULL;
1154 "Applying %s (%s with %s on %s by %s @%d) to %s",
1156 colocation->
primary->
id, pe__node_name(primary_node), attr,
1157 colocation->
score, dependent->
id);
1160 while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
1165 pe__node_name(node), node->weight, colocation->
score);
1183 GList *affected_nodes = NULL;
1189 for (GList *iter = primary->
children; iter != NULL; iter = iter->next) {
1197 update_dependent_allowed_nodes(dependent, node, colocation);
1198 affected_nodes = g_list_prepend(affected_nodes, node);
1214 "Applying %s (mandatory %s with %s) to %s",
1220 g_list_free(affected_nodes);
1242 if (primary_instance != NULL) {
1248 "Applying %s (%s with %s) to %s priority (%s + %s = %s)",
1254 dependent->
priority = new_priority;
1259 "Applying %s (%s with %s) to %s: can't be promoted",
#define CRM_CHECK(expr, failure_action)
enum rsc_role_e role_filter
enum pe_quorum_policy no_quorum_policy
#define crm_notice(fmt, args...)
const char * pe_node_attribute_calculated(const pe_node_t *node, const char *name, const pe_resource_t *rsc)
#define pe_rsc_debug(rsc, fmt, args...)
#define pe__show_node_weights(level, rsc, text, nodes, data_set)
int pe__clone_promoted_node_max(pe_resource_t *clone)
const char * pcmk_readable_score(int score)
Return a displayable static string for a score value.
int(* message)(pcmk__output_t *out, const char *message_id,...)
resource_alloc_functions_t * cmds
enum rsc_role_e next_role
int pe__clone_promoted_max(pe_resource_t *clone)
int char2score(const char *score)
Get the integer value of a score string.
#define pcmk__config_err(fmt...)
int pe__set_clone_flag(pe_resource_t *clone, enum pe__clone_flags flag)
resource_object_functions_t * fns
pe_resource_t * dependent
void node_list_exclude(GHashTable *list, GList *list2, gboolean merge_scores)
char * pcmk_promotion_score_name(const char *rsc_id)
Return the name of the node attribute used as a promotion score.
#define CRM_LOG_ASSERT(expr)
G_GNUC_INTERNAL void pcmk__add_colocated_node_scores(pe_resource_t *rsc, const char *log_id, GHashTable **nodes, const char *attr, float factor, uint32_t flags)
#define pe_flag_have_quorum
#define pe__set_resource_flags(resource, flags_to_set)
const char * role2text(enum rsc_role_e role)
pe_node_t *(* location)(const pe_resource_t *, GList **, int)
#define crm_warn(fmt, args...)
pe_resource_t * find_compatible_child(const pe_resource_t *local_child, const pe_resource_t *rsc, enum rsc_role_e filter, gboolean current)
G_GNUC_INTERNAL bool pcmk__node_available(const pe_node_t *node, bool consider_score, bool consider_guest)
pe_resource_t * uber_parent(pe_resource_t *rsc)
const char * pe_node_attribute_raw(const pe_node_t *node, const char *name)
char * clone_strip(const char *last_rsc_id)
match only clone instances
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
struct pe_node_shared_s * details
void pe__create_promotable_pseudo_ops(pe_resource_t *clone, bool any_promoting, bool any_demoting)
G_GNUC_INTERNAL gint pcmk__cmp_instance(gconstpointer a, gconstpointer b)
void(* create_actions)(pe_resource_t *rsc)
bool pe__clone_is_ordered(pe_resource_t *clone)
#define pcmk__order_resource_actions(first_rsc, first_task, then_rsc, then_task, flags)
void(* apply_coloc_score)(pe_resource_t *dependent, const pe_resource_t *primary, const pcmk__colocation_t *colocation, bool for_dependent)
pe_node_t * pe_find_node_id(GList *node_list, const char *id)
enum rsc_role_e(* state)(const pe_resource_t *, gboolean)
G_GNUC_INTERNAL void pcmk__require_promotion_tickets(pe_resource_t *rsc)
#define crm_err(fmt, args...)
void pe__set_next_role(pe_resource_t *rsc, enum rsc_role_e role, const char *why)
This structure contains everything that makes up a single output formatter.
G_GNUC_INTERNAL void pcmk__promotable_restart_ordering(pe_resource_t *rsc)
#define pe__clear_resource_flags(resource, flags_to_clear)
rsc_role_e
Possible roles that a resource can be in.
pe_working_set_t * cluster
const char * node_attribute
int pcmk__add_scores(int score1, int score2)
#define pe_rsc_trace(rsc, fmt, args...)
pe_resource_t *(* find_rsc)(pe_resource_t *parent, const char *search, const pe_node_t *node, int flags)
#define pe_flag_show_scores
match resource active on specified node
#define pe_rsc_info(rsc, fmt, args...)
GHashTable * allowed_nodes