84 const GList *iter = NULL;
88 for (iter = rsc->
children; iter != NULL; iter = iter->next) {
95 for (iter = rsc->
actions; iter != NULL; iter = iter->next) {
98 if (*promoting && *demoting) {
129 const GList *location_constraints,
132 for (
const GList *iter = location_constraints; iter; iter = iter->next) {
140 if (constraint_node != NULL) {
145 "Applying location %s to %s promotion priority on " 147 location->
id, child->
id,
148 pcmk__node_name(constraint_node),
173 for (GList *iter = rsc->
children; iter != NULL; iter = iter->next) {
176 if (node_to_be_promoted_on(child) == NULL) {
178 "%s can't be promoted because member %s can't",
186 pcmk__rsc_trace(rsc,
"%s can't be promoted because it won't be active",
192 crm_notice(
"Unmanaged instance %s will be left promoted on %s",
193 rsc->
id, pcmk__node_name(node));
202 "%s can't be promoted because its promotion priority " 209 "%s can't be promoted because %s can't run resources",
210 rsc->
id, pcmk__node_name(node));
215 local_node = g_hash_table_lookup(
parent->allowed_nodes, node->
details->
id);
217 if (local_node == NULL) {
224 "on %s (scheduler bug?)",
225 rsc->
id,
parent->id, pcmk__node_name(node));
232 "%s can't be promoted because %s has " 233 "maximum promoted instances already",
234 rsc->
id, pcmk__node_name(node));
253 cmp_promotable_instance(gconstpointer a, gconstpointer b)
266 "%s has higher promotion priority than %s " 267 "(sort index %d > %d)",
272 "%s has lower promotion priority than %s " 273 "(sort index %d < %d)",
283 "%s has higher promotion priority than %s " 284 "(higher current role)",
287 }
else if (role1 < role2) {
289 "%s has lower promotion priority than %s " 290 "(lower current role)",
311 add_sort_index_to_node_score(gpointer
data, gpointer user_data)
326 if (chosen == NULL) {
337 "Added cumulative priority of %s (%s) to score on %s " 351 apply_coloc_to_primary(gpointer
data, gpointer user_data)
361 || !pcmk__colocation_has_influence(colocation, NULL)) {
365 pcmk__rsc_trace(clone,
"Applying colocation %s (%s with promoted %s) @%s",
371 colocation, factor,
flags);
382 set_sort_index_to_node_score(gpointer
data, gpointer user_data)
393 "Final sort index for %s is INFINITY " 394 "(unmanaged promoted)",
397 }
else if (chosen == NULL) {
400 "Final promotion priority for %s is %s " 401 "(will not be active)",
406 "Final sort index for %s is %d (ignoring node score)",
416 "Adding scores for %s: final sort index for %s is %d",
430 GList *colocations = NULL;
438 for (GList *iter = clone->
children; iter != NULL; iter = iter->next) {
442 "Adding scores for %s: initial sort index for %s is %d",
448 g_list_foreach(clone->
children, add_sort_index_to_node_score, clone);
452 g_list_foreach(colocations, apply_coloc_to_primary, clone);
453 g_list_free(colocations);
462 g_list_foreach(clone->
children, set_sort_index_to_node_score, clone);
480 find_active_anon_instance(
const pcmk_resource_t *clone,
const char *
id,
483 for (GList *iter = clone->
children; iter; iter = iter->next) {
491 if (active != NULL) {
512 for (GList *iter = clone->
children; iter; iter = iter->next) {
545 return (allowed != NULL) && (allowed->
weight >= 0);
563 const char *reason =
"allowed";
569 active = find_active_anon_instance(
parent,
id, node);
578 if ((active == NULL) && anonymous_known_on(
parent,
id, node)) {
589 reason =
"none probed";
601 "Ignoring %s promotion score (for %s) on %s: " 603 rsc->
id,
id, pcmk__node_name(node));
609 if (is_allowed(rsc, node)) {
611 rsc->
id,
id, pcmk__node_name(node), reason);
617 "Ignoring %s promotion score (for %s) on %s: not allowed",
618 rsc->
id,
id, pcmk__node_name(node));
637 char *attr_name = NULL;
638 const char *attr_value = NULL;
639 const char *
target = NULL;
669 const char *attr_value = NULL;
671 if (is_default != NULL) {
675 CRM_CHECK((rsc != NULL) && (node != NULL),
return 0);
683 for (
const GList *iter = rsc->
children;
684 iter != NULL; iter = iter->next) {
687 bool child_default =
false;
688 int child_score = promotion_score(child, node, &child_default);
690 if (!child_default && (is_default != NULL)) {
693 score += child_score;
698 if (!promotion_score_applies(rsc, node)) {
708 attr_value = promotion_attr_value(rsc, node,
name);
709 if (attr_value != NULL) {
711 name, pcmk__node_name(node),
712 pcmk__s(attr_value,
"(unset)"));
719 if (strcmp(rsc->
id,
name) != 0) {
720 attr_value = promotion_attr_value(rsc, node,
name);
722 name, pcmk__node_name(node), rsc->
id,
723 pcmk__s(attr_value,
"(unset)"));
728 if (attr_value == NULL) {
732 if (is_default != NULL) {
752 for (GList *iter = rsc->
children; iter != NULL; iter = iter->next) {
757 int score, new_score;
760 while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
768 score = promotion_score(child_rsc, node, NULL);
771 if (new_score != node->weight) {
772 node->weight = new_score;
774 "Added %s promotion priority (%s) to score " 777 pcmk__node_name(node),
784 "Updating %s priority to promotion score " 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,
872 }
else if (chosen == NULL) {
874 "%s promotion score (inactive): %s (priority=%d)",
879 "%s promotion score on %s: %s (priority=%d)",
880 instance->
id, pcmk__node_name(chosen),
894 set_instance_priority(gpointer
data, gpointer user_data)
906 set_current_role_unpromoted(instance, NULL);
910 chosen = instance->
fns->
location(instance, &list, FALSE);
911 if (pcmk__list_of_multiple(list)) {
916 if (chosen == NULL) {
920 next_role = instance->
fns->
state(instance, FALSE);
926 bool is_default =
false;
928 instance->
priority = promotion_score(instance, chosen,
954 next_role, instance->
id));
958 apply_promoted_locations(instance, instance->
rsc_location, chosen);
959 apply_promoted_locations(instance, clone->
rsc_location, chosen);
963 for (GList *iter = list; iter != NULL; iter = iter->next) {
986 set_instance_role(gpointer
data, gpointer user_data)
989 int *count = (
int *) user_data;
994 show_promotion_score(instance);
1002 chosen = node_to_be_promoted_on(instance);
1005 if (chosen == NULL) {
1006 set_next_role_unpromoted(instance, NULL);
1013 crm_notice(
"Clone instance %s cannot be promoted without quorum",
1015 set_next_role_unpromoted(instance, NULL);
1022 pcmk__node_name(chosen));
1023 set_next_role_promoted(instance, NULL);
1037 GHashTableIter iter;
1042 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
1047 g_list_foreach(rsc->
children, set_instance_priority, rsc);
1048 sort_promotable_instances(rsc);
1051 g_list_foreach(rsc->
children, set_instance_role, &promoted);
1052 pcmk__rsc_info(rsc,
"%s: Promoted %d instances of a possible %d",
1067 bool *any_promoting,
bool *any_demoting)
1069 for (GList *iter = clone->
children; iter != NULL; iter = iter->next) {
1073 check_for_role_change(instance, any_demoting, any_promoting);
1090 for (GList *iter = clone->
children; iter != NULL; iter = iter->next) {
1106 bool any_promoting =
false;
1107 bool any_demoting =
false;
1110 create_promotable_instance_actions(clone, &any_promoting, &any_demoting);
1116 reset_instance_priorities(clone);
1132 for (GList *iter = clone->
children; iter != NULL; iter = iter->next) {
1140 order_instance_promotion(clone, instance, previous);
1141 order_instance_demotion(clone, instance, previous);
1142 previous = instance;
1161 GHashTableIter iter;
1163 const char *primary_value = NULL;
1170 primary_value = pcmk__colocation_node_attr(primary_node, attr, primary);
1173 "Applying %s (%s with %s on %s by %s @%d) to %s",
1175 colocation->
primary->
id, pcmk__node_name(primary_node),
1176 attr, colocation->
score, dependent->
id);
1179 while (g_hash_table_iter_next(&iter, NULL, (
void **) &node)) {
1180 const char *dependent_value = pcmk__colocation_node_attr(node, attr,
1186 "Added %s score (%s) to %s (now %s)",
1189 pcmk__node_name(node),
1207 GList *affected_nodes = NULL;
1213 for (GList *iter = primary->
children; iter != NULL; iter = iter->next) {
1221 update_dependent_allowed_nodes(dependent, primary, node,
1223 affected_nodes = g_list_prepend(affected_nodes, node);
1239 "Applying %s (mandatory %s with %s) to %s",
1243 affected_nodes,
true);
1245 g_list_free(affected_nodes);
1270 if (primary_instance != NULL) {
1276 "Applying %s (%s with %s) to %s priority " 1283 dependent->
priority = new_priority;
1284 return colocation->
score;
1290 "Applying %s (%s with %s) to %s: can't be promoted",
pcmk_assignment_methods_t * cmds
const pcmk_resource_t * pe__const_top_resource(const pcmk_resource_t *rsc, bool include_bundle)
#define CRM_CHECK(expr, failure_action)
enum pe_quorum_policy no_quorum_policy
#define crm_notice(fmt, args...)
pcmk_scheduler_t * cluster
const char * pcmk_role_text(enum rsc_role_e role)
Get readable description of a resource role.
pcmk_node_t *(* location)(const pcmk_resource_t *rsc, GList **list, int current)
void(* create_actions)(pcmk_resource_t *rsc)
int(* message)(pcmk__output_t *out, const char *message_id,...)
const char * pcmk_readable_score(int score)
Return a displayable static string for a score value.
G_GNUC_INTERNAL void pcmk__require_promotion_tickets(pcmk_resource_t *rsc)
#define pcmk__rsc_trace(rsc, fmt, args...)
#define PCMK_META_CONTAINER_ATTRIBUTE_TARGET
Match only clones and their instances, by either clone or instance ID.
#define pcmk__rsc_info(rsc, fmt, args...)
enum rsc_role_e(* state)(const pcmk_resource_t *rsc, gboolean current)
enum rsc_role_e next_role
#define pcmk__config_err(fmt...)
G_GNUC_INTERNAL pcmk_resource_t * pcmk__find_compatible_instance(const pcmk_resource_t *match_rsc, const pcmk_resource_t *rsc, enum rsc_role_e role, bool current)
void(* add_colocated_node_scores)(pcmk_resource_t *source_rsc, const pcmk_resource_t *target_rsc, const char *log_id, GHashTable **nodes, const pcmk__colocation_t *colocation, float factor, uint32_t flags)
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)
Where resource is assigned.
int pe__set_clone_flag(pcmk_resource_t *clone, enum pcmk__clone_flags flag)
G_GNUC_INTERNAL bool pcmk__node_available(const pcmk_node_t *node, bool consider_score, bool consider_guest)
#define pcmk__rsc_debug(rsc, fmt, args...)
pcmk_resource_t *(* find_rsc)(pcmk_resource_t *rsc, const char *search, const pcmk_node_t *node, int flags)
#define PCMK_ACTION_DEMOTE
void pe__set_next_role(pcmk_resource_t *rsc, enum rsc_role_e role, const char *why)
Actions are ordered (optionally, if no other flags are set)
pcmk_node_t * pe_find_node_id(const GList *node_list, const char *id)
Find a node by ID in a list of nodes.
char * clone_strip(const char *last_rsc_id)
#define pcmk__sched_err(fmt...)
int char2score(const char *score)
Get the integer value of a score string.
#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(pcmk_resource_t *clone, bool any_promoting, bool any_demoting)
G_GNUC_INTERNAL gint pcmk__cmp_instance(gconstpointer a, gconstpointer b)
Wrappers for and extensions to libxml2.
#define pcmk__set_rsc_flags(resource, flags_to_set)
int pcmk__add_scores(int score1, int score2)
int pe__clone_promoted_node_max(const pcmk_resource_t *clone)
int pe__clone_promoted_max(const pcmk_resource_t *clone)
#define pcmk__order_resource_actions(first_rsc, first_task, then_rsc, then_task, flags)
pcmk_resource_t * primary
If 'then' is required, 'first' must be added to the transition graph.
G_GNUC_INTERNAL GList * pcmk__with_this_colocations(const pcmk_resource_t *rsc)
#define crm_err(fmt, args...)
If matching by node, compare current node instead of assigned node.
If 'first' is required and runnable, 'then' must be in graph.
G_GNUC_INTERNAL GList * pcmk__this_with_colocations(const pcmk_resource_t *rsc)
const char * pcmk__node_attr(const pcmk_node_t *node, const char *name, const char *target, enum pcmk__rsc_node node_type)
This structure contains everything that makes up a single output formatter.
enum rsc_role_e role_filter
G_GNUC_INTERNAL void pcmk__promotable_restart_ordering(pcmk_resource_t *rsc)
#define PCMK_ACTION_PROMOTE
pcmk_resource_t * dependent
#define pe__show_node_scores(level, rsc, text, nodes, scheduler)
const char * node_attribute
#define PCMK_ACTION_PROMOTED
Resource role is unknown.
Location constraint object.
bool pe__clone_is_ordered(const pcmk_resource_t *clone)
#define PCMK_ACTION_DEMOTED
#define pcmk__clear_rsc_flags(resource, flags_to_clear)
int(* apply_coloc_score)(pcmk_resource_t *dependent, const pcmk_resource_t *primary, const pcmk__colocation_t *colocation, bool for_dependent)
G_GNUC_INTERNAL void pcmk__colocation_intersect_nodes(pcmk_resource_t *dependent, const pcmk_resource_t *primary, const pcmk__colocation_t *colocation, const GList *primary_nodes, bool merge_scores)
#define PCMK_SCORE_INFINITY
Integer score to use to represent "infinity".
GHashTable * allowed_nodes
Where resource is running.