13 #define VARIANT_CLONE 1
19 child_promoting_constraints(clone_variant_data_t * clone_data,
enum pe_ordering type,
24 if (clone_data->ordered && last != NULL) {
38 if (clone_data->ordered) {
55 child_demoting_constraints(clone_variant_data_t * clone_data,
enum pe_ordering type,
60 if (clone_data->ordered && last != NULL) {
74 if (clone_data->ordered && last != NULL) {
80 }
else if (clone_data->ordered) {
91 check_promotable_actions(
resource_t *rsc, gboolean *demoting,
98 for (; gIter != NULL; gIter = gIter->next) {
101 check_promotable_actions(child, demoting, promoting);
110 for (; gIter != NULL; gIter = gIter->next) {
113 if (*promoting && *demoting) {
131 for (
GListPtr gIter = location_constraints; gIter; gIter = gIter->next) {
139 if (cons_node != NULL) {
144 new_priority, cons_node->
weight);
154 node_t *local_node = NULL;
156 clone_variant_data_t *clone_data = NULL;
168 for (; gIter != NULL; gIter = gIter->next) {
171 if (can_be_master(child) == NULL) {
185 crm_notice(
"Forcing unmanaged master %s to remain promoted on %s",
201 get_clone_variant_data(clone_data, parent);
204 if (local_node == NULL) {
208 }
else if ((local_node->
count < clone_data->promoted_node_max)
220 sort_promotable_instance(gconstpointer a, gconstpointer b, gpointer data_set)
232 role1 = resource1->
fns->
state(resource1, TRUE);
233 role2 = resource2->
fns->
state(resource2, TRUE);
237 crm_trace(
"%s %c %s (index)", resource1->
id, rc < 0 ?
'<' :
'>', resource2->
id);
242 crm_trace(
"%s %c %s (role)", resource1->
id,
'<', resource2->
id);
245 }
else if (role1 < role2) {
246 crm_trace(
"%s %c %s (role)", resource1->
id,
'>', resource2->
id);
259 clone_variant_data_t *clone_data = NULL;
261 size_t len =
sizeof(score);
263 get_clone_variant_data(clone_data, rsc);
265 if (clone_data->merged_master_weights) {
268 clone_data->merged_master_weights = TRUE;
272 for (gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
280 for (; gIter != NULL; gIter = gIter->next) {
284 if (chosen == NULL || child->
sort_index < 0) {
301 for (; gIter != NULL; gIter = gIter->next) {
321 for (; gIter != NULL; gIter = gIter->next) {
341 for (; gIter != NULL; gIter = gIter->next) {
355 for (; gIter != NULL; gIter = gIter->next) {
362 }
else if (chosen == NULL || child->
sort_index < 0) {
375 sort_promotable_instance, data_set);
386 for (rIter = parent->
children; rIter; rIter = rIter->next) {
406 for (rIter = parent->
children; rIter; rIter = rIter->next) {
432 lookup_promotion_score(
resource_t *rsc,
const node_t *node,
const char *name)
434 const char *attr_value = NULL;
448 char *name = rsc->
id;
449 const char *attr_value = NULL;
450 int score = not_set_value;
453 CRM_CHECK(node != NULL,
return not_set_value);
458 for (; gIter != NULL; gIter = gIter->next) {
460 int c_score = promotion_score(child, node, not_set_value);
462 if (score == not_set_value) {
484 if ((match == NULL) && (known == NULL)) {
485 pe_rsc_trace(rsc,
"skipping %s (aka. %s) promotion score on %s because inactive",
495 }
else if (match->
weight < 0) {
508 attr_value = lookup_promotion_score(rsc, node, name);
518 if (strcmp(rsc->
id, name)) {
519 attr_value = lookup_promotion_score(rsc, node, name);
520 pe_rsc_trace(rsc,
"stripped promotion score for %s on %s = %s",
526 if (attr_value != NULL) {
536 int score, new_score;
538 clone_variant_data_t *clone_data = NULL;
540 get_clone_variant_data(clone_data, rsc);
542 if (clone_data->applied_master_prefs) {
547 clone_data->applied_master_prefs = TRUE;
549 for (; gIter != NULL; gIter = gIter->next) {
555 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
564 score = promotion_score(child_rsc, node, 0);
567 if (new_score != node->weight) {
568 pe_rsc_trace(rsc,
"\t%s: Updating preference for %s (%d->%d)",
569 child_rsc->
id, node->details->uname, node->weight, new_score);
570 node->weight = new_score;
574 new_score = QB_MAX(child_rsc->
priority, score);
575 if (new_score != child_rsc->
priority) {
577 child_rsc->
id, child_rsc->
priority, new_score);
585 set_role_slave(
resource_t * rsc, gboolean current)
605 g_list_free(allocated);
608 for (; gIter != NULL; gIter = gIter->next) {
611 set_role_slave(child_rsc, current);
624 for (; gIter != NULL; gIter = gIter->next) {
627 set_role_master(child_rsc);
642 size_t len =
sizeof(score);
643 clone_variant_data_t *clone_data = NULL;
645 get_clone_variant_data(clone_data, rsc);
649 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
656 for (gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
664 set_role_slave(child_rsc, TRUE);
667 chosen = child_rsc->
fns->
location(child_rsc, &list, FALSE);
668 if (g_list_length(list) > 1) {
673 if (chosen == NULL) {
677 next_role = child_rsc->
fns->
state(child_rsc, FALSE);
689 child_rsc->
priority = promotion_score(child_rsc, chosen, -1);
702 crm_err(
"Unknown resource role: %d for %s", next_role, child_rsc->
id));
705 apply_master_location(child_rsc, child_rsc->
rsc_location, chosen);
706 apply_master_location(child_rsc, rsc->
rsc_location, chosen);
708 for (gIter2 = child_rsc->
rsc_cons; gIter2 != NULL; gIter2 = gIter2->next) {
724 promotion_order(rsc, data_set);
728 for (gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
732 chosen = child_rsc->
fns->
location(child_rsc, NULL, FALSE);
735 printf(
"%s promotion score on %s: %s\n",
750 pe_rsc_trace(rsc,
"Not supposed to promote child: %s", child_rsc->
id);
752 }
else if ((promoted < clone_data->promoted_max)
754 chosen = can_be_master(child_rsc);
759 if (chosen == NULL) {
760 set_role_slave(child_rsc, FALSE);
766 crm_notice(
"Resource %s cannot be elevated from %s to %s: no-quorum-policy=freeze",
768 set_role_slave(child_rsc, FALSE);
775 set_role_master(child_rsc);
779 pe_rsc_info(rsc,
"%s: Promoted %d instances of a possible %d to master",
780 rsc->
id, promoted, clone_data->promoted_max);
791 gboolean any_promoting = FALSE;
792 gboolean any_demoting = FALSE;
796 clone_variant_data_t *clone_data = NULL;
798 get_clone_variant_data(clone_data, rsc);
802 for (; gIter != NULL; gIter = gIter->next) {
803 gboolean child_promoting = FALSE;
804 gboolean child_demoting = FALSE;
809 check_promotable_actions(child_rsc, &child_demoting, &child_promoting);
811 any_demoting = any_demoting || child_demoting;
812 any_promoting = any_promoting || child_promoting;
813 pe_rsc_trace(rsc,
"Created actions for %s: %d %d", child_rsc->
id, child_promoting,
823 rsc, NULL, last_promote_rsc, data_set);
825 if (clone_data->promote_notify == NULL) {
826 clone_data->promote_notify =
835 child_demoting_constraints(clone_data,
pe_order_optional, rsc, NULL, last_demote_rsc, data_set);
837 if (clone_data->demote_notify == NULL) {
838 clone_data->demote_notify =
841 if (clone_data->promote_notify) {
845 order_actions(clone_data->stop_notify->post_done, clone_data->promote_notify->pre,
847 order_actions(clone_data->start_notify->post_done, clone_data->promote_notify->pre,
849 order_actions(clone_data->demote_notify->post_done, clone_data->promote_notify->pre,
851 order_actions(clone_data->demote_notify->post_done, clone_data->start_notify->pre,
853 order_actions(clone_data->demote_notify->post_done, clone_data->stop_notify->pre,
861 for (; gIter != NULL; gIter = gIter->next) {
899 clone_variant_data_t *clone_data = NULL;
901 get_clone_variant_data(clone_data, rsc);
905 for (; gIter != NULL; gIter = gIter->next) {
912 rsc, child_rsc, last_rsc, data_set);
915 rsc, child_rsc, last_rsc, data_set);
917 last_rsc = child_rsc;
922 node_hash_update_one(GHashTable * hash,
node_t * other,
const char *attr,
int score)
926 const char *value = NULL;
931 }
else if (attr == NULL) {
936 g_hash_table_iter_init(&iter, hash);
937 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
941 crm_trace(
"%s: %d + %d", node->details->uname, node->weight, other->
weight);
957 for (gIter = rsc_rh->
children; gIter != NULL; gIter = gIter->next) {
963 if (chosen != NULL && next_role == constraint->
role_rh) {
970 rhs = g_list_prepend(rhs, chosen);
990 pe_rsc_trace(rsc_lh,
"%s can't be promoted %s", rsc_lh->
id, constraint->
id);
993 }
else if (rh_child != NULL) {