15 #define VARIANT_CLONE 1 21 child_promoting_constraints(clone_variant_data_t * clone_data,
enum pe_ordering type,
26 if (clone_data->ordered && last != NULL) {
40 if (clone_data->ordered) {
57 child_demoting_constraints(clone_variant_data_t * clone_data,
enum pe_ordering type,
62 if (clone_data->ordered && last != NULL) {
76 if (clone_data->ordered && last != NULL) {
82 }
else if (clone_data->ordered) {
93 check_promotable_actions(
pe_resource_t *rsc, gboolean *demoting,
100 for (; gIter != NULL; gIter = gIter->next) {
103 check_promotable_actions(child, demoting, promoting);
112 for (; gIter != NULL; gIter = gIter->next) {
115 if (*promoting && *demoting) {
133 for (
GListPtr gIter = location_constraints; gIter; gIter = gIter->next) {
141 if (cons_node != NULL) {
147 new_priority, cons_node->
weight);
167 clone_variant_data_t *clone_data = NULL;
179 for (; gIter != NULL; gIter = gIter->next) {
182 if (can_be_master(child) == NULL) {
196 crm_notice(
"Forcing unmanaged master %s to remain promoted on %s",
216 pe_rsc_trace(rsc,
"%s cannot be promoted: guest %s not allocated",
221 get_clone_variant_data(clone_data, parent);
224 if (local_node == NULL) {
228 }
else if ((local_node->
count < clone_data->promoted_node_max)
240 sort_promotable_instance(gconstpointer a, gconstpointer b, gpointer data_set)
252 role1 = resource1->
fns->
state(resource1, TRUE);
253 role2 = resource2->
fns->
state(resource2, TRUE);
257 crm_trace(
"%s %c %s (index)", resource1->
id,
rc < 0 ?
'<' :
'>', resource2->
id);
262 crm_trace(
"%s %c %s (role)", resource1->
id,
'<', resource2->
id);
265 }
else if (role1 < role2) {
266 crm_trace(
"%s %c %s (role)", resource1->
id,
'>', resource2->
id);
279 clone_variant_data_t *clone_data = NULL;
281 size_t len =
sizeof(score);
283 get_clone_variant_data(clone_data, rsc);
285 if (clone_data->merged_master_weights) {
288 clone_data->merged_master_weights = TRUE;
292 for (gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
300 for (; gIter != NULL; gIter = gIter->next) {
304 if (chosen == NULL || child->
sort_index < 0) {
321 for (; gIter != NULL; gIter = gIter->next) {
324 if (constraint->
score == 0) {
345 for (; gIter != NULL; gIter = gIter->next) {
348 if (constraint->
score == 0) {
369 for (; gIter != NULL; gIter = gIter->next) {
383 for (; gIter != NULL; gIter = gIter->next) {
391 }
else if (chosen == NULL || child->
sort_index < 0) {
404 sort_promotable_instance, data_set);
415 for (rIter = parent->
children; rIter; rIter = rIter->next) {
435 for (rIter = parent->
children; rIter; rIter = rIter->next) {
463 const char *attr_value = NULL;
478 const char *attr_value = NULL;
479 int score = not_set_value;
482 CRM_CHECK(node != NULL,
return not_set_value);
487 for (; gIter != NULL; gIter = gIter->next) {
489 int c_score = promotion_score(child, node, not_set_value);
491 if (score == not_set_value) {
501 && filter_anonymous_instance(rsc, node)) {
515 if ((match == NULL) && (known == NULL)) {
516 pe_rsc_trace(rsc,
"skipping %s (aka. %s) promotion score on %s because inactive",
526 }
else if (match->
weight < 0) {
539 attr_value = lookup_promotion_score(rsc, node,
name);
549 if (strcmp(rsc->
id,
name)) {
550 attr_value = lookup_promotion_score(rsc, node,
name);
551 pe_rsc_trace(rsc,
"stripped promotion score for %s on %s = %s",
557 if (attr_value != NULL) {
567 int score, new_score;
569 clone_variant_data_t *clone_data = NULL;
571 get_clone_variant_data(clone_data, rsc);
573 if (clone_data->applied_master_prefs) {
578 clone_data->applied_master_prefs = TRUE;
580 for (; gIter != NULL; gIter = gIter->next) {
586 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
595 score = promotion_score(child_rsc, node, 0);
598 if (new_score != node->weight) {
599 pe_rsc_trace(rsc,
"\t%s: Updating preference for %s (%d->%d)",
600 child_rsc->
id, node->details->uname, node->weight, new_score);
601 node->weight = new_score;
605 new_score = QB_MAX(child_rsc->
priority, score);
606 if (new_score != child_rsc->
priority) {
608 child_rsc->
id, child_rsc->
priority, new_score);
636 g_list_free(allocated);
639 for (; gIter != NULL; gIter = gIter->next) {
642 set_role_slave(child_rsc, current);
655 for (; gIter != NULL; gIter = gIter->next) {
658 set_role_master(child_rsc);
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_slave(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_master_location(child_rsc, child_rsc->
rsc_location, chosen);
738 apply_master_location(child_rsc, rsc->
rsc_location, chosen);
740 for (gIter2 = child_rsc->
rsc_cons; gIter2 != NULL; gIter2 = gIter2->next) {
743 if (cons->
score == 0) {
759 promotion_order(rsc, data_set);
763 for (gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
767 chosen = child_rsc->
fns->
location(child_rsc, NULL, FALSE);
770 printf(
"%s promotion score on %s: %s\n",
785 pe_rsc_trace(rsc,
"Not supposed to promote child: %s", child_rsc->
id);
787 }
else if ((promoted < clone_data->promoted_max)
789 chosen = can_be_master(child_rsc);
794 if (chosen == NULL) {
795 set_role_slave(child_rsc, FALSE);
801 crm_notice(
"Resource %s cannot be elevated from %s to %s: no-quorum-policy=freeze",
803 set_role_slave(child_rsc, FALSE);
810 set_role_master(child_rsc);
814 pe_rsc_info(rsc,
"%s: Promoted %d instances of a possible %d to master",
815 rsc->
id, promoted, clone_data->promoted_max);
826 gboolean any_promoting = FALSE;
827 gboolean any_demoting = FALSE;
831 clone_variant_data_t *clone_data = NULL;
833 get_clone_variant_data(clone_data, rsc);
837 for (; gIter != NULL; gIter = gIter->next) {
838 gboolean child_promoting = FALSE;
839 gboolean child_demoting = FALSE;
844 check_promotable_actions(child_rsc, &child_demoting, &child_promoting);
846 any_demoting = any_demoting || child_demoting;
847 any_promoting = any_promoting || child_promoting;
848 pe_rsc_trace(rsc,
"Created actions for %s: %d %d", child_rsc->
id, child_promoting,
858 rsc, NULL, last_promote_rsc, data_set);
860 if (clone_data->promote_notify == NULL) {
861 clone_data->promote_notify =
870 child_demoting_constraints(clone_data,
pe_order_optional, rsc, NULL, last_demote_rsc, data_set);
872 if (clone_data->demote_notify == NULL) {
873 clone_data->demote_notify =
876 if (clone_data->promote_notify) {
880 order_actions(clone_data->stop_notify->post_done, clone_data->promote_notify->pre,
882 order_actions(clone_data->start_notify->post_done, clone_data->promote_notify->pre,
884 order_actions(clone_data->demote_notify->post_done, clone_data->promote_notify->pre,
886 order_actions(clone_data->demote_notify->post_done, clone_data->start_notify->pre,
888 order_actions(clone_data->demote_notify->post_done, clone_data->stop_notify->pre,
896 for (; gIter != NULL; gIter = gIter->next) {
934 clone_variant_data_t *clone_data = NULL;
936 get_clone_variant_data(clone_data, rsc);
940 for (; gIter != NULL; gIter = gIter->next) {
947 rsc, child_rsc, last_rsc, data_set);
950 rsc, child_rsc, last_rsc, data_set);
952 last_rsc = child_rsc;
957 node_hash_update_one(GHashTable * hash,
pe_node_t * other,
const char *attr,
int score)
961 const char *value = NULL;
966 }
else if (attr == NULL) {
971 g_hash_table_iter_init(&iter, hash);
972 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
976 crm_trace(
"%s: %d + %d", node->details->uname, node->weight, other->
weight);
989 if (constraint->
score == 0) {
995 for (gIter = rsc_rh->
children; gIter != NULL; gIter = gIter->next) {
1001 if (chosen != NULL && next_role == constraint->
role_rh) {
1008 rhs = g_list_prepend(rhs, chosen);
1028 pe_rsc_trace(rsc_lh,
"%s can't be promoted %s", rsc_lh->
id, constraint->
id);
1031 }
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)
pe_resource_t * container
resource_alloc_functions_t * cmds
#define pcmk__config_err(fmt...)
enum rsc_role_e next_role
#define pe__show_node_weights(level, rsc, text, nodes)
int char2score(const char *score)
pe_resource_t * remote_rsc
char * score2char_stack(int score, char *buf, size_t len)
resource_object_functions_t * fns
#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)
gboolean can_run_resources(const pe_node_t *node)
#define pe_flag_have_quorum
pe_node_t * pe_find_node_id(GListPtr node_list, const char *id)
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)
#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_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)
const char * node_attribute
char * clone_strip(const char *last_rsc_id)
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)
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_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)
enum rsc_role_e(* state)(const pe_resource_t *, gboolean)
void(* rsc_colocation_lh)(pe_resource_t *, pe_resource_t *, rsc_colocation_t *, pe_working_set_t *)
int pe__add_scores(int score1, int score2)
#define crm_err(fmt, args...)
void node_list_exclude(GHashTable *list, GListPtr list2, gboolean merge_scores)
#define pe__clear_resource_flags(resource, flags_to_clear)
void(* create_actions)(pe_resource_t *, pe_working_set_t *)
#define order_start_start(rsc1, rsc2, type)
#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)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
#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)
enum crm_ais_msg_types type
#define pe_rsc_info(rsc, fmt, args...)
GHashTable * allowed_nodes