76 check_for_role_change(
const pe_resource_t *rsc,
bool *demoting,
bool *promoting)
78 const GList *iter = NULL;
82 for (iter = rsc->
children; iter != NULL; iter = iter->next) {
89 for (iter = rsc->
actions; iter != NULL; iter = iter->next) {
92 if (*promoting && *demoting) {
121 const GList *location_constraints,
124 for (
const GList *iter = location_constraints; iter; iter = iter->next) {
132 if (weighted_node != NULL) {
137 "Applying location %s to %s promotion priority on %s: " 139 location->
id, child->
id, pe__node_name(weighted_node),
164 for (GList *iter = rsc->
children; iter != NULL; iter = iter->next) {
167 if (node_to_be_promoted_on(child) == NULL) {
169 "%s can't be promoted because member %s can't",
177 pe_rsc_trace(rsc,
"%s can't be promoted because it won't be active",
183 crm_notice(
"Unmanaged instance %s will be left promoted on %s",
184 rsc->
id, pe__node_name(node));
186 pe_rsc_trace(rsc,
"%s can't be promoted because it is unmanaged",
193 "%s can't be promoted because its promotion priority %d " 199 pe_rsc_trace(rsc,
"%s can't be promoted because %s can't run resources",
200 rsc->
id, pe__node_name(node));
205 local_node = pe_hash_table_lookup(
parent->allowed_nodes, node->
details->
id);
207 if (local_node == NULL) {
213 crm_warn(
"%s can't be promoted because %s is not allowed on %s " 215 rsc->
id,
parent->id, pe__node_name(node));
222 "%s can't be promoted because %s has " 223 "maximum promoted instances already",
224 rsc->
id, pe__node_name(node));
243 cmp_promotable_instance(gconstpointer a, gconstpointer b)
256 "%s has higher promotion priority than %s " 257 "(sort index %d > %d)",
262 "%s has lower promotion priority than %s " 263 "(sort index %d < %d)",
273 "%s has higher promotion priority than %s " 274 "(higher current role)",
277 }
else if (role1 < role2) {
279 "%s has lower promotion priority than %s " 280 "(lower current role)",
301 add_sort_index_to_node_weight(gpointer
data, gpointer user_data)
310 pe_rsc_trace(clone,
"Not adding sort index of %s: negative", child->
id);
315 if (chosen == NULL) {
316 pe_rsc_trace(clone,
"Not adding sort index of %s: inactive", child->
id);
326 "Added cumulative priority of %s (%s) to score on %s (now %s)",
339 apply_coloc_to_dependent(gpointer
data, gpointer user_data)
353 pe_rsc_trace(clone,
"Applying colocation %s (promoted %s with %s) @%s",
371 apply_coloc_to_primary(gpointer
data, gpointer user_data)
381 || !pcmk__colocation_has_influence(constraint, NULL)) {
385 pe_rsc_trace(clone,
"Applying colocation %s (%s with promoted %s) @%s",
403 set_sort_index_to_node_weight(gpointer
data, gpointer user_data)
414 "Final sort index for %s is INFINITY (unmanaged promoted)",
417 }
else if ((chosen == NULL) || (child->
sort_index < 0)) {
419 "Final sort index for %s is %d (ignoring node weight)",
430 "Merging weights for %s: final sort index for %s is %d",
450 for (GList *iter = clone->
children; iter != NULL; iter = iter->next) {
454 "Merging weights for %s: initial sort index for %s is %d",
464 g_list_foreach(clone->
children, add_sort_index_to_node_weight, clone);
465 g_list_foreach(clone->
rsc_cons, apply_coloc_to_dependent, clone);
466 g_list_foreach(clone->
rsc_cons_lhs, apply_coloc_to_primary, clone);
475 g_list_foreach(clone->
children, set_sort_index_to_node_weight, clone);
493 find_active_anon_instance(
const pe_resource_t *clone,
const char *
id,
496 for (GList *iter = clone->
children; iter; iter = iter->next) {
503 if (active != NULL) {
521 anonymous_known_on(
const pe_resource_t *clone,
const char *
id,
524 for (GList *iter = clone->
children; iter; iter = iter->next) {
556 return (allowed != NULL) && (allowed->
weight >= 0);
574 const char *reason =
"allowed";
580 active = find_active_anon_instance(
parent,
id, node);
589 if ((active == NULL) && anonymous_known_on(
parent,
id, node)) {
600 reason =
"none probed";
612 "Ignoring %s promotion score (for %s) on %s: not probed",
613 rsc->
id,
id, pe__node_name(node));
619 if (is_allowed(rsc, node)) {
620 pe_rsc_trace(rsc,
"Counting %s promotion score (for %s) on %s: %s",
621 rsc->
id,
id, pe__node_name(node), reason);
626 pe_rsc_trace(rsc,
"Ignoring %s promotion score (for %s) on %s: not allowed",
627 rsc->
id,
id, pe__node_name(node));
646 char *attr_name = NULL;
647 const char *attr_value = NULL;
649 CRM_CHECK((rsc != NULL) && (node != NULL) && (
name != NULL),
return NULL);
672 const char *attr_value = NULL;
674 if (is_default != NULL) {
678 CRM_CHECK((rsc != NULL) && (node != NULL),
return 0);
686 for (
const GList *iter = rsc->
children;
687 iter != NULL; iter = iter->next) {
690 bool child_default =
false;
691 int child_score = promotion_score(child, node, &child_default);
693 if (!child_default && (is_default != NULL)) {
696 score += child_score;
701 if (!promotion_score_applies(rsc, node)) {
711 attr_value = promotion_attr_value(rsc, node,
name);
712 if (attr_value != NULL) {
714 name, pe__node_name(node), pcmk__s(attr_value,
"(unset)"));
721 if (strcmp(rsc->
id,
name) != 0) {
722 attr_value = promotion_attr_value(rsc, node,
name);
723 pe_rsc_trace(rsc,
"Promotion score for %s on %s (for %s) = %s",
724 name, pe__node_name(node), rsc->
id,
725 pcmk__s(attr_value,
"(unset)"));
730 if (attr_value == NULL) {
734 if (is_default != NULL) {
753 for (GList *iter = rsc->
children; iter != NULL; iter = iter->next) {
758 int score, new_score;
761 while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
769 score = promotion_score(child_rsc, node, NULL);
772 if (new_score != node->weight) {
773 node->weight = new_score;
775 "Added %s promotion priority (%s) to score " 785 "Updating %s priority to promotion score (%d->%d)",
801 set_current_role_unpromoted(
void *
data,
void *user_data)
809 g_list_foreach(rsc->
children, set_current_role_unpromoted, NULL);
820 set_next_role_unpromoted(
void *
data,
void *user_data)
823 GList *assigned = NULL;
826 if (assigned == NULL) {
830 g_list_free(assigned);
832 g_list_foreach(rsc->
children, set_next_role_unpromoted, NULL);
843 set_next_role_promoted(
void *
data, gpointer user_data)
850 g_list_foreach(rsc->
children, set_next_role_promoted, NULL);
869 out->
message(out,
"promotion-score", instance, chosen,
873 "%s promotion score on %s: sort=%s priority=%s",
875 ((chosen == NULL)?
"none" : pe__node_name(chosen)),
889 set_instance_priority(gpointer
data, gpointer user_data)
897 pe_rsc_trace(clone,
"Assigning priority for %s: %s", instance->
id,
901 set_current_role_unpromoted(instance, NULL);
905 chosen = instance->
fns->
location(instance, &list, FALSE);
906 if (pcmk__list_of_multiple(list)) {
911 if (chosen == NULL) {
915 next_role = instance->
fns->
state(instance, FALSE);
921 bool is_default =
false;
923 instance->
priority = promotion_score(instance, chosen,
950 next_role, instance->
id));
954 apply_promoted_locations(instance, instance->
rsc_location, chosen);
955 apply_promoted_locations(instance, clone->
rsc_location, chosen);
959 for (GList *iter = list; iter != NULL; iter = iter->next) {
982 set_instance_role(gpointer
data, gpointer user_data)
985 int *count = (
int *) user_data;
990 show_promotion_score(instance);
993 pe_rsc_trace(clone,
"Not supposed to promote instance %s",
998 chosen = node_to_be_promoted_on(instance);
1001 if (chosen == NULL) {
1002 set_next_role_unpromoted(instance, NULL);
1009 crm_notice(
"Clone instance %s cannot be promoted without quorum",
1011 set_next_role_unpromoted(instance, NULL);
1016 pe_rsc_info(clone,
"Choosing %s (%s) on %s for promotion",
1018 pe__node_name(chosen));
1019 set_next_role_promoted(instance, NULL);
1033 GHashTableIter iter;
1038 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
1043 g_list_foreach(rsc->
children, set_instance_priority, rsc);
1044 sort_promotable_instances(rsc);
1047 g_list_foreach(rsc->
children, set_instance_role, &promoted);
1048 pe_rsc_info(rsc,
"%s: Promoted %d instances of a possible %d",
1063 bool *any_promoting,
bool *any_demoting)
1065 for (GList *iter = clone->
children; iter != NULL; iter = iter->next) {
1069 check_for_role_change(instance, any_demoting, any_promoting);
1086 for (GList *iter = clone->
children; iter != NULL; iter = iter->next) {
1102 bool any_promoting =
false;
1103 bool any_demoting =
false;
1106 create_promotable_instance_actions(clone, &any_promoting, &any_demoting);
1112 reset_instance_priorities(clone);
1128 for (GList *iter = clone->
children; iter != NULL; iter = iter->next) {
1136 order_instance_promotion(clone, instance, previous);
1137 order_instance_demotion(clone, instance, previous);
1138 previous = instance;
1155 GHashTableIter iter;
1157 const char *primary_value = NULL;
1158 const char *attr = NULL;
1172 "Applying %s (%s with %s on %s by %s @%d) to %s",
1174 colocation->
primary->
id, pe__node_name(primary_node), attr,
1175 colocation->
score, dependent->
id);
1178 while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
1184 "Added %s score (%s) to %s (now %s)",
1186 pe__node_name(node),
1204 GList *affected_nodes = NULL;
1210 for (GList *iter = primary->
children; iter != NULL; iter = iter->next) {
1218 update_dependent_allowed_nodes(dependent, node, colocation);
1219 affected_nodes = g_list_prepend(affected_nodes, node);
1235 "Applying %s (mandatory %s with %s) to %s",
1241 g_list_free(affected_nodes);
1264 if (primary_instance != NULL) {
1270 "Applying %s (%s with %s) to %s priority (%s + %s = %s)",
1276 dependent->
priority = new_priority;
1281 "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)
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,...)
G_GNUC_INTERNAL pe_resource_t * pcmk__find_compatible_instance(const pe_resource_t *match_rsc, const pe_resource_t *rsc, enum rsc_role_e role, bool current)
resource_alloc_functions_t * cmds
int pe__clone_promoted_max(const pe_resource_t *clone)
enum rsc_role_e next_role
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)
const pe_resource_t * pe__const_top_resource(const pe_resource_t *rsc, bool include_bundle)
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)
#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...)
G_GNUC_INTERNAL bool pcmk__node_available(const pe_node_t *node, bool consider_score, bool consider_guest)
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
GList * pcmk__this_with_colocations(const pe_resource_t *rsc)
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
int pe__clone_promoted_node_max(const pe_resource_t *clone)
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)
#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)
enum rsc_role_e(* state)(const pe_resource_t *, gboolean)
G_GNUC_INTERNAL void pcmk__require_promotion_tickets(pe_resource_t *rsc)
pe_node_t * pe_find_node_id(const GList *node_list, const char *id)
Find a node by ID in a list of nodes.
#define crm_err(fmt, args...)
bool pe__clone_is_ordered(const pe_resource_t *clone)
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
void(* add_colocated_node_scores)(pe_resource_t *rsc, const char *log_id, GHashTable **nodes, const char *attr, float factor, uint32_t flags)
match resource active on specified node
#define pe_rsc_info(rsc, fmt, args...)
GHashTable * allowed_nodes