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);
159 clone_variant_data_t *clone_data = NULL;
171 for (; gIter != NULL; gIter = gIter->next) {
174 if (can_be_master(child) == NULL) {
188 crm_notice(
"Forcing unmanaged master %s to remain promoted on %s",
204 get_clone_variant_data(clone_data, parent);
207 if (local_node == NULL) {
211 }
else if ((local_node->
count < clone_data->promoted_node_max)
223 sort_promotable_instance(gconstpointer a, gconstpointer b, gpointer data_set)
235 role1 = resource1->
fns->
state(resource1, TRUE);
236 role2 = resource2->
fns->
state(resource2, TRUE);
240 crm_trace(
"%s %c %s (index)", resource1->
id, rc < 0 ?
'<' :
'>', resource2->
id);
245 crm_trace(
"%s %c %s (role)", resource1->
id,
'<', resource2->
id);
248 }
else if (role1 < role2) {
249 crm_trace(
"%s %c %s (role)", resource1->
id,
'>', resource2->
id);
262 clone_variant_data_t *clone_data = NULL;
264 size_t len =
sizeof(score);
266 get_clone_variant_data(clone_data, rsc);
268 if (clone_data->merged_master_weights) {
271 clone_data->merged_master_weights = TRUE;
275 for (gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
283 for (; gIter != NULL; gIter = gIter->next) {
287 if (chosen == NULL || child->
sort_index < 0) {
304 for (; gIter != NULL; gIter = gIter->next) {
307 if (constraint->
score == 0) {
328 for (; gIter != NULL; gIter = gIter->next) {
331 if (constraint->
score == 0) {
352 for (; gIter != NULL; gIter = gIter->next) {
366 for (; gIter != NULL; gIter = gIter->next) {
373 }
else if (chosen == NULL || child->
sort_index < 0) {
386 sort_promotable_instance, data_set);
397 for (rIter = parent->
children; rIter; rIter = rIter->next) {
417 for (rIter = parent->
children; rIter; rIter = rIter->next) {
445 const char *attr_value = NULL;
459 char *name = rsc->
id;
460 const char *attr_value = NULL;
461 int score = not_set_value;
464 CRM_CHECK(node != NULL,
return not_set_value);
469 for (; gIter != NULL; gIter = gIter->next) {
471 int c_score = promotion_score(child, node, not_set_value);
473 if (score == not_set_value) {
495 if ((match == NULL) && (known == NULL)) {
496 pe_rsc_trace(rsc,
"skipping %s (aka. %s) promotion score on %s because inactive",
506 }
else if (match->
weight < 0) {
519 attr_value = lookup_promotion_score(rsc, node, name);
529 if (strcmp(rsc->
id, name)) {
530 attr_value = lookup_promotion_score(rsc, node, name);
531 pe_rsc_trace(rsc,
"stripped promotion score for %s on %s = %s",
537 if (attr_value != NULL) {
547 int score, new_score;
549 clone_variant_data_t *clone_data = NULL;
551 get_clone_variant_data(clone_data, rsc);
553 if (clone_data->applied_master_prefs) {
558 clone_data->applied_master_prefs = TRUE;
560 for (; gIter != NULL; gIter = gIter->next) {
566 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
575 score = promotion_score(child_rsc, node, 0);
578 if (new_score != node->
weight) {
579 pe_rsc_trace(rsc,
"\t%s: Updating preference for %s (%d->%d)",
585 new_score = QB_MAX(child_rsc->
priority, score);
586 if (new_score != child_rsc->
priority) {
588 child_rsc->
id, child_rsc->
priority, new_score);
616 g_list_free(allocated);
619 for (; gIter != NULL; gIter = gIter->next) {
622 set_role_slave(child_rsc, current);
635 for (; gIter != NULL; gIter = gIter->next) {
638 set_role_master(child_rsc);
653 size_t len =
sizeof(score);
654 clone_variant_data_t *clone_data = NULL;
656 get_clone_variant_data(clone_data, rsc);
660 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
667 for (gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
675 set_role_slave(child_rsc, TRUE);
678 chosen = child_rsc->
fns->
location(child_rsc, &list, FALSE);
679 if (pcmk__list_of_multiple(list)) {
685 if (chosen == NULL) {
689 next_role = child_rsc->
fns->
state(child_rsc, FALSE);
701 child_rsc->
priority = promotion_score(child_rsc, chosen, -1);
714 crm_err(
"Unknown resource role: %d for %s", next_role, child_rsc->
id));
717 apply_master_location(child_rsc, child_rsc->
rsc_location, chosen);
718 apply_master_location(child_rsc, rsc->
rsc_location, chosen);
720 for (gIter2 = child_rsc->
rsc_cons; gIter2 != NULL; gIter2 = gIter2->next) {
723 if (cons->
score == 0) {
739 promotion_order(rsc, data_set);
743 for (gIter = rsc->
children; gIter != NULL; gIter = gIter->next) {
747 chosen = child_rsc->
fns->
location(child_rsc, NULL, FALSE);
750 printf(
"%s promotion score on %s: %s\n",
765 pe_rsc_trace(rsc,
"Not supposed to promote child: %s", child_rsc->
id);
767 }
else if ((promoted < clone_data->promoted_max)
769 chosen = can_be_master(child_rsc);
774 if (chosen == NULL) {
775 set_role_slave(child_rsc, FALSE);
781 crm_notice(
"Resource %s cannot be elevated from %s to %s: no-quorum-policy=freeze",
783 set_role_slave(child_rsc, FALSE);
790 set_role_master(child_rsc);
794 pe_rsc_info(rsc,
"%s: Promoted %d instances of a possible %d to master",
795 rsc->
id, promoted, clone_data->promoted_max);
806 gboolean any_promoting = FALSE;
807 gboolean any_demoting = FALSE;
811 clone_variant_data_t *clone_data = NULL;
813 get_clone_variant_data(clone_data, rsc);
817 for (; gIter != NULL; gIter = gIter->next) {
818 gboolean child_promoting = FALSE;
819 gboolean child_demoting = FALSE;
824 check_promotable_actions(child_rsc, &child_demoting, &child_promoting);
826 any_demoting = any_demoting || child_demoting;
827 any_promoting = any_promoting || child_promoting;
828 pe_rsc_trace(rsc,
"Created actions for %s: %d %d", child_rsc->
id, child_promoting,
838 rsc, NULL, last_promote_rsc, data_set);
840 if (clone_data->promote_notify == NULL) {
841 clone_data->promote_notify =
850 child_demoting_constraints(clone_data,
pe_order_optional, rsc, NULL, last_demote_rsc, data_set);
852 if (clone_data->demote_notify == NULL) {
853 clone_data->demote_notify =
856 if (clone_data->promote_notify) {
860 order_actions(clone_data->stop_notify->post_done, clone_data->promote_notify->pre,
862 order_actions(clone_data->start_notify->post_done, clone_data->promote_notify->pre,
864 order_actions(clone_data->demote_notify->post_done, clone_data->promote_notify->pre,
866 order_actions(clone_data->demote_notify->post_done, clone_data->start_notify->pre,
868 order_actions(clone_data->demote_notify->post_done, clone_data->stop_notify->pre,
876 for (; gIter != NULL; gIter = gIter->next) {
914 clone_variant_data_t *clone_data = NULL;
916 get_clone_variant_data(clone_data, rsc);
920 for (; gIter != NULL; gIter = gIter->next) {
927 rsc, child_rsc, last_rsc, data_set);
930 rsc, child_rsc, last_rsc, data_set);
932 last_rsc = child_rsc;
937 node_hash_update_one(GHashTable * hash,
pe_node_t * other,
const char *attr,
int score)
941 const char *value = NULL;
946 }
else if (attr == NULL) {
951 g_hash_table_iter_init(&iter, hash);
952 while (g_hash_table_iter_next(&iter, NULL, (
void **)&node)) {
969 if (constraint->
score == 0) {
975 for (gIter = rsc_rh->
children; gIter != NULL; gIter = gIter->next) {
981 if (chosen != NULL && next_role == constraint->
role_rh) {
988 rhs = g_list_prepend(rhs, chosen);
1008 pe_rsc_trace(rsc_lh,
"%s can't be promoted %s", rsc_lh->
id, constraint->
id);
1011 }
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)
enum rsc_role_e(* state)(const pe_resource_t *, gboolean)
void apply_master_prefs(pe_resource_t *rsc)
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)
gint sort_clone_instance(gconstpointer a, gconstpointer b, gpointer data_set)
int char2score(const char *score)
char * score2char_stack(int score, char *buf, size_t len)
void(* rsc_colocation_lh)(pe_resource_t *, pe_resource_t *, rsc_colocation_t *, pe_working_set_t *)
resource_object_functions_t * fns
GHashTable *(* merge_weights)(pe_resource_t *, const char *, GHashTable *, const char *, float, enum pe_weights)
#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)
#define clear_bit(word, bit)
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)
void promotable_constraints(pe_resource_t *rsc, pe_working_set_t *data_set)
#define pe_rsc_provisional
const char * role2text(enum rsc_role_e role)
#define set_bit(word, bit)
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)
const char * node_attribute
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...)
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_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)
void promotable_colocation_rh(pe_resource_t *lh_rsc, pe_resource_t *rh_rsc, rsc_colocation_t *constraint, pe_working_set_t *data_set)
int pe__add_scores(int score1, int score2)
#define crm_err(fmt, args...)
void node_list_exclude(GHashTable *list, GListPtr list2, gboolean merge_scores)
enum pe_action_flags flags
pe_node_t *(* location)(const pe_resource_t *, GList **, int)
#define order_start_start(rsc1, rsc2, type)
#define pe_rsc_trace(rsc, fmt, args...)
#define safe_str_eq(a, b)
pe_node_t * pcmk__set_instance_roles(pe_resource_t *rsc, pe_working_set_t *data_set)
char * crm_strdup_printf(char const *format,...) __attribute__((__format__(__printf__
#define crm_info(fmt, args...)
match resource active on specified node
enum crm_ais_msg_types type
#define pe_rsc_info(rsc, fmt, args...)
GHashTable * allowed_nodes