17 #define VARIANT_CLONE 1 25 child_promoting_constraints(clone_variant_data_t * clone_data,
enum pe_ordering type,
30 if (clone_data->ordered && last != NULL) {
47 if (clone_data->ordered) {
65 child_demoting_constraints(clone_variant_data_t * clone_data,
enum pe_ordering type,
70 if (clone_data->ordered && last != NULL) {
87 if (clone_data->ordered && last != NULL) {
94 }
else if (clone_data->ordered) {
106 check_promotable_actions(
pe_resource_t *rsc, gboolean *demoting,
113 for (; gIter != NULL; gIter = gIter->next) {
116 check_promotable_actions(child, demoting, promoting);
125 for (; gIter != NULL; gIter = gIter->next) {
128 if (*promoting && *demoting) {
144 apply_promoted_location(
pe_resource_t *child, GList *location_constraints,
148 for (GList *gIter = location_constraints; gIter; gIter = gIter->next) {
156 if (cons_node != NULL) {
162 new_priority, cons_node->
weight);
182 clone_variant_data_t *clone_data = NULL;
194 for (; gIter != NULL; gIter = gIter->next) {
197 if (node_to_be_promoted_on(child) == NULL) {
206 pe_rsc_trace(rsc,
"%s cannot be promoted: not allocated", rsc->
id);
211 crm_notice(
"Forcing unmanaged instance %s to remain promoted on %s",
219 pe_rsc_trace(rsc,
"%s cannot be promoted: preference: %d",
232 pe_rsc_trace(rsc,
"%s cannot be promoted: guest %s not allocated",
237 get_clone_variant_data(clone_data,
parent);
238 local_node = pe_hash_table_lookup(
parent->allowed_nodes, node->
details->
id);
240 if (local_node == NULL) {
244 }
else if ((local_node->
count < clone_data->promoted_node_max)
249 pe_rsc_trace(rsc,
"%s cannot be promoted on %s: node full",
257 sort_promotable_instance(gconstpointer a, gconstpointer b, gpointer
data_set)
269 role1 = resource1->
fns->
state(resource1, TRUE);
270 role2 = resource2->
fns->
state(resource2, TRUE);
274 crm_trace(
"%s %c %s (index)", resource1->
id, rc < 0 ?
'<' :
'>', resource2->
id);
279 crm_trace(
"%s %c %s (role)", resource1->
id,
'<', resource2->
id);
282 }
else if (role1 < role2) {
283 crm_trace(
"%s %c %s (role)", resource1->
id,
'>', resource2->
id);
296 clone_variant_data_t *clone_data = NULL;
298 size_t len =
sizeof(score);
300 get_clone_variant_data(clone_data, rsc);
302 if (clone_data->added_promoted_constraints) {
305 clone_data->added_promoted_constraints =
true;
309 for (gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
317 for (; gIter != NULL; gIter = gIter->next) {
321 if (chosen == NULL || child->
sort_index < 0) {
338 for (; gIter != NULL; gIter = gIter->next) {
358 for (; gIter != NULL; gIter = gIter->next) {
361 if (!pcmk__colocation_has_influence(constraint, NULL)) {
381 for (; gIter != NULL; gIter = gIter->next) {
395 for (; gIter != NULL; gIter = gIter->next) {
403 }
else if (chosen == NULL || child->
sort_index < 0) {
416 sort_promotable_instance,
data_set);
427 for (rIter =
parent->children; rIter; rIter = rIter->next) {
447 for (rIter =
parent->children; rIter; rIter = rIter->next) {
475 const char *attr_value = NULL;
490 const char *attr_value = NULL;
491 int score = not_set_value;
494 CRM_CHECK(node != NULL,
return not_set_value);
499 for (; gIter != NULL; gIter = gIter->next) {
501 int c_score = promotion_score(child, node, not_set_value);
503 if (score == not_set_value) {
513 && filter_anonymous_instance(rsc, node)) {
527 if ((match == NULL) && (known == NULL)) {
528 pe_rsc_trace(rsc,
"skipping %s (aka. %s) promotion score on %s because inactive",
538 }
else if (match->
weight < 0) {
551 attr_value = lookup_promotion_score(rsc, node,
name);
561 if (strcmp(rsc->
id,
name)) {
562 attr_value = lookup_promotion_score(rsc, node,
name);
563 pe_rsc_trace(rsc,
"stripped promotion score for %s on %s = %s",
569 if (attr_value != NULL) {
579 int score, new_score;
581 clone_variant_data_t *clone_data = NULL;
583 get_clone_variant_data(clone_data, rsc);
585 if (clone_data->added_promotion_scores) {
590 clone_data->added_promotion_scores =
true;
592 for (; gIter != NULL; gIter = gIter->next) {
598 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
606 score = promotion_score(child_rsc, node, 0);
609 if (new_score != node->weight) {
610 pe_rsc_trace(rsc,
"\t%s: Updating preference for %s (%d->%d)",
611 child_rsc->
id, node->details->uname, node->weight, new_score);
612 node->weight = new_score;
616 new_score = QB_MAX(child_rsc->
priority, score);
617 if (new_score != child_rsc->
priority) {
619 child_rsc->
id, child_rsc->
priority, new_score);
637 GList *allocated = NULL;
641 "unpromoted instance");
642 g_list_free(allocated);
645 for (; gIter != NULL; gIter = gIter->next) {
648 set_role_unpromoted(child_rsc, current);
659 g_list_foreach(rsc->
children, (GFunc) set_role_promoted, NULL);
667 GList *gIter2 = NULL;
673 size_t len =
sizeof(score);
674 clone_variant_data_t *clone_data = NULL;
676 get_clone_variant_data(clone_data, rsc);
680 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
687 for (gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
695 set_role_unpromoted(child_rsc,
true);
698 chosen = child_rsc->
fns->
location(child_rsc, &list, FALSE);
699 if (pcmk__list_of_multiple(list)) {
705 if (chosen == NULL) {
709 next_role = child_rsc->
fns->
state(child_rsc, FALSE);
721 child_rsc->
priority = promotion_score(child_rsc, chosen, -1);
734 crm_err(
"Unknown resource role: %d for %s", next_role, child_rsc->
id));
737 apply_promoted_location(child_rsc, child_rsc->
rsc_location, chosen);
738 apply_promoted_location(child_rsc, rsc->
rsc_location, chosen);
740 for (gIter2 = child_rsc->
rsc_cons; gIter2 != NULL; gIter2 = gIter2->next) {
759 for (gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
763 chosen = child_rsc->
fns->
location(child_rsc, NULL, FALSE);
767 out->
message(out,
"promotion-score", child_rsc, chosen, score);
780 pe_rsc_trace(rsc,
"Not supposed to promote child: %s", child_rsc->
id);
782 }
else if ((promoted < clone_data->promoted_max)
784 chosen = node_to_be_promoted_on(child_rsc);
789 if (chosen == NULL) {
790 set_role_unpromoted(child_rsc,
false);
796 crm_notice(
"Resource %s cannot be elevated from %s to %s: no-quorum-policy=freeze",
798 set_role_unpromoted(child_rsc,
false);
805 set_role_promoted(child_rsc, NULL);
809 pe_rsc_info(rsc,
"%s: Promoted %d instances of a possible %d",
810 rsc->
id, promoted, clone_data->promoted_max);
821 gboolean any_promoting = FALSE;
822 gboolean any_demoting = FALSE;
826 clone_variant_data_t *clone_data = NULL;
828 get_clone_variant_data(clone_data, rsc);
832 for (; gIter != NULL; gIter = gIter->next) {
833 gboolean child_promoting = FALSE;
834 gboolean child_demoting = FALSE;
839 check_promotable_actions(child_rsc, &child_demoting, &child_promoting);
841 any_demoting = any_demoting || child_demoting;
842 any_promoting = any_promoting || child_promoting;
843 pe_rsc_trace(rsc,
"Created actions for %s: %d %d", child_rsc->
id, child_promoting,
851 !any_promoting,
true);
855 rsc, NULL, last_promote_rsc,
data_set);
857 if (clone_data->promote_notify == NULL) {
867 !any_demoting,
true);
872 if (clone_data->demote_notify == NULL) {
878 if (clone_data->promote_notify) {
882 order_actions(clone_data->stop_notify->post_done, clone_data->promote_notify->pre,
884 order_actions(clone_data->start_notify->post_done, clone_data->promote_notify->pre,
886 order_actions(clone_data->demote_notify->post_done, clone_data->promote_notify->pre,
888 order_actions(clone_data->demote_notify->post_done, clone_data->start_notify->pre,
890 order_actions(clone_data->demote_notify->post_done, clone_data->stop_notify->pre,
898 for (; gIter != NULL; gIter = gIter->next) {
943 clone_variant_data_t *clone_data = NULL;
945 get_clone_variant_data(clone_data, rsc);
949 for (; gIter != NULL; gIter = gIter->next) {
957 rsc, child_rsc, last_rsc,
data_set);
960 rsc, child_rsc, last_rsc,
data_set);
962 last_rsc = child_rsc;
967 node_hash_update_one(GHashTable * hash,
pe_node_t * other,
const char *attr,
int score)
971 const char *value = NULL;
976 }
else if (attr == NULL) {
981 g_hash_table_iter_init(&iter, hash);
982 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
986 crm_trace(
"%s: %d + %d", node->details->uname, node->weight, other->
weight);
1000 GList *affected_nodes = NULL;
1002 for (gIter = primary->
children; gIter != NULL; gIter = gIter->next) {
1008 if ((chosen != NULL) && (next_role == constraint->
primary_role)) {
1015 affected_nodes = g_list_prepend(affected_nodes, chosen);
1031 g_list_free(affected_nodes);
1039 if ((primary_instance == NULL) && (constraint->
score >=
INFINITY)) {
1041 dependent->
id, constraint->
id);
1044 }
else if (primary_instance != NULL) {
1049 constraint->
id, dependent->
id);
1051 dependent->
id, dependent->
priority, new_priority);
1052 dependent->
priority = new_priority;
#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...)
gint sort_rsc_index(gconstpointer a, gconstpointer b)
#define pe__show_node_weights(level, rsc, text, nodes, data_set)
#define pcmk__order_starts(rsc1, rsc2, type, data_set)
pe_resource_t * container
int(* message)(pcmk__output_t *out, const char *message_id,...)
G_GNUC_INTERNAL bool pcmk__node_available(const pe_node_t *node)
resource_alloc_functions_t * cmds
enum rsc_role_e next_role
int char2score(const char *score)
Get the integer value of a score string.
#define pcmk__config_err(fmt...)
pe_resource_t * remote_rsc
char * score2char_stack(int score, char *buf, size_t len)
Convert an integer score to a string, using a provided buffer.
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)
void resource_location(pe_resource_t *rsc, pe_node_t *node, int score, const char *tag, pe_working_set_t *data_set)
enum crm_ais_msg_types type
#define pe_flag_have_quorum
#define pe__set_resource_flags(resource, flags_to_set)
#define pe_rsc_provisional
const char * role2text(enum rsc_role_e role)
pe_node_t *(* location)(const pe_resource_t *, GList **, int)
pe_resource_t * uber_parent(pe_resource_t *rsc)
bool pe__is_guest_node(const pe_node_t *node)
char * clone_strip(const char *last_rsc_id)
void(* rsc_colocation_lh)(pe_resource_t *, pe_resource_t *, pcmk__colocation_t *, pe_working_set_t *)
G_GNUC_INTERNAL notify_data_t * pcmk__clone_notif_pseudo_ops(pe_resource_t *rsc, const char *task, pe_action_t *action, pe_action_t *complete)
match only clone instances
#define crm_trace(fmt, args...)
#define pcmk_is_set(g, f)
Convenience alias for pcmk_all_flags_set(), to check single flag.
struct pe_node_shared_s * details
gboolean order_actions(pe_action_t *lh_action, pe_action_t *rh_action, enum pe_ordering order)
pe_working_set_t * data_set
#define pcmk__order_resource_actions(lh_rsc, lh_task, rh_rsc, rh_task, flags, data_set)
const char * pe_node_attribute_raw(pe_node_t *node, const char *name)
pe_node_t * pe_find_node_id(GList *node_list, const char *id)
pe_resource_t * find_compatible_child(pe_resource_t *local_child, pe_resource_t *rsc, enum rsc_role_e filter, gboolean current, pe_working_set_t *data_set)
G_GNUC_INTERNAL pe_action_t * pcmk__new_rsc_pseudo_action(pe_resource_t *rsc, const char *task, bool optional, bool runnable)
enum rsc_role_e(* state)(const pe_resource_t *, gboolean)
#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.
#define pe__clear_resource_flags(resource, flags_to_clear)
rsc_role_e
Possible roles that a resource can be in.
void(* create_actions)(pe_resource_t *, pe_working_set_t *)
const char * node_attribute
int pcmk__add_scores(int score1, int score2)
#define pe_rsc_trace(rsc, fmt, args...)
#define pe_flag_show_scores
#define crm_info(fmt, args...)
match resource active on specified node
GHashTable *(* merge_weights)(pe_resource_t *, const char *, GHashTable *, const char *, float, enum pe_weights)
#define pe_rsc_info(rsc, fmt, args...)
GHashTable * allowed_nodes