15 #define VARIANT_CLONE 1
23 child_promoting_constraints(clone_variant_data_t * clone_data,
enum pe_ordering type,
28 if (clone_data->ordered && last != NULL) {
42 if (clone_data->ordered) {
59 child_demoting_constraints(clone_variant_data_t * clone_data,
enum pe_ordering type,
64 if (clone_data->ordered && last != NULL) {
78 if (clone_data->ordered && last != NULL) {
84 }
else if (clone_data->ordered) {
95 check_promotable_actions(
pe_resource_t *rsc, gboolean *demoting,
102 for (; gIter != NULL; gIter = gIter->next) {
105 check_promotable_actions(child, demoting, promoting);
114 for (; gIter != NULL; gIter = gIter->next) {
117 if (*promoting && *demoting) {
133 apply_promoted_location(
pe_resource_t *child, GList *location_constraints,
137 for (GList *gIter = location_constraints; gIter; gIter = gIter->next) {
145 if (cons_node != NULL) {
151 new_priority, cons_node->
weight);
171 clone_variant_data_t *clone_data = NULL;
183 for (; gIter != NULL; gIter = gIter->next) {
186 if (node_to_be_promoted_on(child) == NULL) {
195 pe_rsc_trace(rsc,
"%s cannot be promoted: not allocated", rsc->
id);
200 crm_notice(
"Forcing unmanaged instance %s to remain promoted on %s",
208 pe_rsc_trace(rsc,
"%s cannot be promoted: preference: %d",
221 pe_rsc_trace(rsc,
"%s cannot be promoted: guest %s not allocated",
226 get_clone_variant_data(clone_data, parent);
229 if (local_node == NULL) {
233 }
else if ((local_node->
count < clone_data->promoted_node_max)
238 pe_rsc_trace(rsc,
"%s cannot be promoted on %s: node full",
246 sort_promotable_instance(gconstpointer a, gconstpointer b, gpointer data_set)
258 role1 = resource1->
fns->
state(resource1, TRUE);
259 role2 = resource2->
fns->
state(resource2, TRUE);
263 crm_trace(
"%s %c %s (index)", resource1->
id, rc < 0 ?
'<' :
'>', resource2->
id);
268 crm_trace(
"%s %c %s (role)", resource1->
id,
'<', resource2->
id);
271 }
else if (role1 < role2) {
272 crm_trace(
"%s %c %s (role)", resource1->
id,
'>', resource2->
id);
285 clone_variant_data_t *clone_data = NULL;
287 size_t len =
sizeof(score);
289 get_clone_variant_data(clone_data, rsc);
291 if (clone_data->added_promoted_constraints) {
294 clone_data->added_promoted_constraints =
true;
298 for (gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
306 for (; gIter != NULL; gIter = gIter->next) {
310 if (chosen == NULL || child->
sort_index < 0) {
327 for (; gIter != NULL; gIter = gIter->next) {
347 for (; gIter != NULL; gIter = gIter->next) {
350 if (!pcmk__colocation_has_influence(constraint, NULL)) {
371 for (; gIter != NULL; gIter = gIter->next) {
385 for (; gIter != NULL; gIter = gIter->next) {
393 }
else if (chosen == NULL || child->
sort_index < 0) {
406 sort_promotable_instance, data_set);
417 for (rIter = parent->
children; rIter; rIter = rIter->next) {
437 for (rIter = parent->
children; rIter; rIter = rIter->next) {
465 const char *attr_value = NULL;
479 char *name = rsc->
id;
480 const char *attr_value = NULL;
481 int score = not_set_value;
484 CRM_CHECK(node != NULL,
return not_set_value);
489 for (; gIter != NULL; gIter = gIter->next) {
491 int c_score = promotion_score(child, node, not_set_value);
493 if (score == not_set_value) {
503 && filter_anonymous_instance(rsc, node)) {
517 if ((match == NULL) && (known == NULL)) {
518 pe_rsc_trace(rsc,
"skipping %s (aka. %s) promotion score on %s because inactive",
528 }
else if (match->
weight < 0) {
541 attr_value = lookup_promotion_score(rsc, node, name);
551 if (strcmp(rsc->
id, name)) {
552 attr_value = lookup_promotion_score(rsc, node, name);
553 pe_rsc_trace(rsc,
"stripped promotion score for %s on %s = %s",
559 if (attr_value != NULL) {
569 int score, new_score;
571 clone_variant_data_t *clone_data = NULL;
573 get_clone_variant_data(clone_data, rsc);
575 if (clone_data->added_promotion_scores) {
580 clone_data->added_promotion_scores =
true;
582 for (; gIter != NULL; gIter = gIter->next) {
588 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
596 score = promotion_score(child_rsc, node, 0);
599 if (new_score != node->
weight) {
600 pe_rsc_trace(rsc,
"\t%s: Updating preference for %s (%d->%d)",
606 new_score = QB_MAX(child_rsc->
priority, score);
607 if (new_score != child_rsc->
priority) {
609 child_rsc->
id, child_rsc->
priority, new_score);
627 GList *allocated = NULL;
631 "unpromoted instance");
632 g_list_free(allocated);
635 for (; gIter != NULL; gIter = gIter->next) {
638 set_role_unpromoted(child_rsc, current);
651 for (; gIter != NULL; gIter = gIter->next) {
654 set_role_promoted(child_rsc);
663 GList *gIter2 = NULL;
669 size_t len =
sizeof(score);
670 clone_variant_data_t *clone_data = NULL;
672 get_clone_variant_data(clone_data, rsc);
676 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
683 for (gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
691 set_role_unpromoted(child_rsc,
true);
694 chosen = child_rsc->
fns->
location(child_rsc, &list, FALSE);
695 if (pcmk__list_of_multiple(list)) {
701 if (chosen == NULL) {
705 next_role = child_rsc->
fns->
state(child_rsc, FALSE);
717 child_rsc->
priority = promotion_score(child_rsc, chosen, -1);
730 crm_err(
"Unknown resource role: %d for %s", next_role, child_rsc->
id));
733 apply_promoted_location(child_rsc, child_rsc->
rsc_location, chosen);
734 apply_promoted_location(child_rsc, rsc->
rsc_location, chosen);
736 for (gIter2 = child_rsc->
rsc_cons; gIter2 != NULL; gIter2 = gIter2->next) {
752 promotion_order(rsc, data_set);
755 for (gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
759 chosen = child_rsc->
fns->
location(child_rsc, NULL, FALSE);
761 if (data_set->
priv != NULL) {
763 out->
message(out,
"promotion-score", child_rsc, chosen, score);
776 pe_rsc_trace(rsc,
"Not supposed to promote child: %s", child_rsc->
id);
778 }
else if ((promoted < clone_data->promoted_max)
780 chosen = node_to_be_promoted_on(child_rsc);
785 if (chosen == NULL) {
786 set_role_unpromoted(child_rsc,
false);
792 crm_notice(
"Resource %s cannot be elevated from %s to %s: no-quorum-policy=freeze",
794 set_role_unpromoted(child_rsc,
false);
801 set_role_promoted(child_rsc);
805 pe_rsc_info(rsc,
"%s: Promoted %d instances of a possible %d",
806 rsc->
id, promoted, clone_data->promoted_max);
817 gboolean any_promoting = FALSE;
818 gboolean any_demoting = FALSE;
822 clone_variant_data_t *clone_data = NULL;
824 get_clone_variant_data(clone_data, rsc);
828 for (; gIter != NULL; gIter = gIter->next) {
829 gboolean child_promoting = FALSE;
830 gboolean child_demoting = FALSE;
835 check_promotable_actions(child_rsc, &child_demoting, &child_promoting);
837 any_demoting = any_demoting || child_demoting;
838 any_promoting = any_promoting || child_promoting;
839 pe_rsc_trace(rsc,
"Created actions for %s: %d %d", child_rsc->
id, child_promoting,
849 rsc, NULL, last_promote_rsc, data_set);
851 if (clone_data->promote_notify == NULL) {
852 clone_data->promote_notify =
861 child_demoting_constraints(clone_data,
pe_order_optional, rsc, NULL, last_demote_rsc, data_set);
863 if (clone_data->demote_notify == NULL) {
864 clone_data->demote_notify =
867 if (clone_data->promote_notify) {
871 order_actions(clone_data->stop_notify->post_done, clone_data->promote_notify->pre,
873 order_actions(clone_data->start_notify->post_done, clone_data->promote_notify->pre,
875 order_actions(clone_data->demote_notify->post_done, clone_data->promote_notify->pre,
877 order_actions(clone_data->demote_notify->post_done, clone_data->start_notify->pre,
879 order_actions(clone_data->demote_notify->post_done, clone_data->stop_notify->pre,
887 for (; gIter != NULL; gIter = gIter->next) {
925 clone_variant_data_t *clone_data = NULL;
927 get_clone_variant_data(clone_data, rsc);
931 for (; gIter != NULL; gIter = gIter->next) {
938 rsc, child_rsc, last_rsc, data_set);
941 rsc, child_rsc, last_rsc, data_set);
943 last_rsc = child_rsc;
948 node_hash_update_one(GHashTable * hash,
pe_node_t * other,
const char *attr,
int score)
952 const char *value = NULL;
957 }
else if (attr == NULL) {
962 g_hash_table_iter_init(&iter, hash);
963 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
983 for (gIter = rsc_rh->
children; gIter != NULL; gIter = gIter->next) {
989 if (chosen != NULL && next_role == constraint->
role_rh) {
996 rhs = g_list_prepend(rhs, chosen);
1019 pe_rsc_trace(rsc_lh,
"%s can't be promoted %s", rsc_lh->
id, constraint->
id);
1022 }
else if (rh_child != NULL) {
#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)
enum rsc_role_e(* state)(const pe_resource_t *, gboolean)
pe_resource_t * container
resource_alloc_functions_t * cmds
enum rsc_role_e next_role
gint sort_clone_instance(gconstpointer a, gconstpointer b, gpointer data_set)
int char2score(const char *score)
#define pcmk__config_err(fmt...)
pe_resource_t * remote_rsc
char * score2char_stack(int score, char *buf, size_t len)
resource_object_functions_t * fns
int(* message)(pcmk__output_t *out, const char *message_id,...)
void node_list_exclude(GHashTable *list, GList *list2, gboolean merge_scores)
GHashTable *(* merge_weights)(pe_resource_t *, const char *, GHashTable *, const char *, float, enum pe_weights)
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
void pcmk__add_promotion_scores(pe_resource_t *rsc)
gboolean can_run_resources(const pe_node_t *node)
#define pe_flag_have_quorum
notify_data_t * create_notification_boundaries(pe_resource_t *rsc, const char *action, pe_action_t *start, pe_action_t *end, pe_working_set_t *data_set)
void promotable_constraints(pe_resource_t *rsc, pe_working_set_t *data_set)
#define pe__set_resource_flags(resource, flags_to_set)
#define pe_rsc_provisional
const char * role2text(enum rsc_role_e role)
void(* create_actions)(pe_resource_t *, pe_working_set_t *)
void create_promotable_actions(pe_resource_t *rsc, pe_working_set_t *data_set)
pe_action_t * create_pseudo_resource_op(pe_resource_t *rsc, const char *task, bool optional, bool runnable, pe_working_set_t *data_set)
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)
pe_resource_t *(* find_rsc)(pe_resource_t *parent, const char *search, const pe_node_t *node, int flags)
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.
void promote_demote_constraints(pe_resource_t *rsc, pe_working_set_t *data_set)
struct pe_node_shared_s * details
gboolean order_actions(pe_action_t *lh_action, pe_action_t *rh_action, enum pe_ordering order)
const char * pe_node_attribute_raw(pe_node_t *node, const char *name)
int new_rsc_order(pe_resource_t *lh_rsc, const char *lh_task, pe_resource_t *rh_rsc, const char *rh_task, enum pe_ordering type, pe_working_set_t *data_set)
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)
int pe__add_scores(int score1, int score2)
#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.
enum pe_action_flags flags
pe_node_t *(* location)(const pe_resource_t *, GList **, int)
#define order_start_start(rsc1, rsc2, type)
const char * node_attribute
void promotable_colocation_rh(pe_resource_t *lh_rsc, pe_resource_t *rh_rsc, pcmk__colocation_t *constraint, pe_working_set_t *data_set)
#define pe_rsc_trace(rsc, fmt, args...)
pe_node_t * pcmk__set_instance_roles(pe_resource_t *rsc, pe_working_set_t *data_set)
#define pe_flag_show_scores
#define crm_info(fmt, args...)
void(* rsc_colocation_lh)(pe_resource_t *, pe_resource_t *, pcmk__colocation_t *, pe_working_set_t *)
match resource active on specified node
#define pe_rsc_info(rsc, fmt, args...)
GHashTable * allowed_nodes