diff --git a/include/pcmki/pcmki_sched_utils.h b/include/pcmki/pcmki_sched_utils.h index bed64da..f6ac263 100644 --- a/include/pcmki/pcmki_sched_utils.h +++ b/include/pcmki/pcmki_sched_utils.h @@ -72,9 +72,6 @@ enum filter_colocation_res { extern enum filter_colocation_res filter_colocation_constraint(pe_resource_t * rsc_lh, pe_resource_t * rsc_rh, pcmk__colocation_t *constraint, gboolean preview); -bool pcmk__colocation_applies(pe_resource_t *rsc, - pcmk__colocation_t *colocation, - bool promoted_only); extern int compare_capacity(const pe_node_t * node1, const pe_node_t * node2); extern void calculate_utilization(GHashTable * current_utilization, diff --git a/lib/pacemaker/pcmk_sched_clone.c b/lib/pacemaker/pcmk_sched_clone.c index 5a06151..9485a98 100644 --- a/lib/pacemaker/pcmk_sched_clone.c +++ b/lib/pacemaker/pcmk_sched_clone.c @@ -658,12 +658,14 @@ pcmk__clone_allocate(pe_resource_t *rsc, pe_node_t *prefer, for (GListPtr gIter = rsc->rsc_cons_lhs; gIter != NULL; gIter = gIter->next) { pcmk__colocation_t *constraint = (pcmk__colocation_t *) gIter->data; - if (pcmk__colocation_applies(rsc, constraint, false)) { - rsc->allowed_nodes = constraint->rsc_lh->cmds->merge_weights(constraint->rsc_lh, - rsc->id, rsc->allowed_nodes, constraint->node_attribute, - constraint->score / (float) INFINITY, - pe_weights_rollback|pe_weights_positive); + if (constraint->score == 0) { + continue; } + rsc->allowed_nodes = + constraint->rsc_lh->cmds->merge_weights(constraint->rsc_lh, rsc->id, rsc->allowed_nodes, + constraint->node_attribute, + (float)constraint->score / INFINITY, + (pe_weights_rollback | pe_weights_positive)); } pe__show_node_weights(!show_scores, rsc, __func__, rsc->allowed_nodes); diff --git a/lib/pacemaker/pcmk_sched_group.c b/lib/pacemaker/pcmk_sched_group.c index 03df5e2..336a6f9 100644 --- a/lib/pacemaker/pcmk_sched_group.c +++ b/lib/pacemaker/pcmk_sched_group.c @@ -520,13 +520,13 @@ pcmk__group_merge_weights(pe_resource_t *rsc, const char *rhs, for (; gIter != NULL; gIter = gIter->next) { pcmk__colocation_t *constraint = (pcmk__colocation_t *) gIter->data; - if (pcmk__colocation_applies(rsc, constraint, false)) { - nodes = pcmk__native_merge_weights(constraint->rsc_lh, rsc->id, - nodes, - constraint->node_attribute, - constraint->score / (float) INFINITY, - flags); + if (constraint->score == 0) { + continue; } + nodes = pcmk__native_merge_weights(constraint->rsc_lh, rsc->id, nodes, + constraint->node_attribute, + constraint->score / (float) INFINITY, + flags); } pe__clear_resource_flags(rsc, pe_rsc_merging); diff --git a/lib/pacemaker/pcmk_sched_native.c b/lib/pacemaker/pcmk_sched_native.c index 6675b23..d532f31 100644 --- a/lib/pacemaker/pcmk_sched_native.c +++ b/lib/pacemaker/pcmk_sched_native.c @@ -564,11 +564,17 @@ pcmk__native_allocate(pe_resource_t *rsc, pe_node_t *prefer, for (gIter = rsc->rsc_cons_lhs; gIter != NULL; gIter = gIter->next) { pcmk__colocation_t *constraint = (pcmk__colocation_t *) gIter->data; - if (pcmk__colocation_applies(rsc, constraint, false)) { - rsc->allowed_nodes = constraint->rsc_lh->cmds->merge_weights(constraint->rsc_lh, - rsc->id, rsc->allowed_nodes, constraint->node_attribute, - constraint->score / (float) INFINITY, pe_weights_rollback); + if (constraint->score == 0) { + continue; } + pe_rsc_trace(rsc, "Merging score of '%s' constraint (%s with %s)", + constraint->id, constraint->rsc_lh->id, + constraint->rsc_rh->id); + rsc->allowed_nodes = + constraint->rsc_lh->cmds->merge_weights(constraint->rsc_lh, rsc->id, rsc->allowed_nodes, + constraint->node_attribute, + (float)constraint->score / INFINITY, + pe_weights_rollback); } if (rsc->next_role == RSC_ROLE_STOPPED) { diff --git a/lib/pacemaker/pcmk_sched_promotable.c b/lib/pacemaker/pcmk_sched_promotable.c index a0eeaad..9a5474a 100644 --- a/lib/pacemaker/pcmk_sched_promotable.c +++ b/lib/pacemaker/pcmk_sched_promotable.c @@ -345,14 +345,23 @@ promotion_order(pe_resource_t *rsc, pe_working_set_t *data_set) for (; gIter != NULL; gIter = gIter->next) { pcmk__colocation_t *constraint = (pcmk__colocation_t *) gIter->data; - if (pcmk__colocation_applies(rsc, constraint, true)) { - /* (Re-)add location preferences of resource that wishes to be - * colocated with the promoted instance. - */ - rsc->allowed_nodes = constraint->rsc_lh->cmds->merge_weights(constraint->rsc_lh, - rsc->id, rsc->allowed_nodes, constraint->node_attribute, - constraint->score / (float) INFINITY, - pe_weights_rollback|pe_weights_positive); + if (constraint->score == 0) { + continue; + } + + /* (re-)adds location preferences of resource that wish to be + * colocated with the master instance + */ + if (constraint->role_rh == RSC_ROLE_MASTER) { + pe_rsc_trace(rsc, "LHS: %s with %s: %d", constraint->rsc_lh->id, constraint->rsc_rh->id, + constraint->score); + rsc->allowed_nodes = + constraint->rsc_lh->cmds->merge_weights(constraint->rsc_lh, rsc->id, + rsc->allowed_nodes, + constraint->node_attribute, + (float)constraint->score / INFINITY, + (pe_weights_rollback | + pe_weights_positive)); } } diff --git a/lib/pacemaker/pcmk_sched_utils.c b/lib/pacemaker/pcmk_sched_utils.c index aba417a..eaaf526 100644 --- a/lib/pacemaker/pcmk_sched_utils.c +++ b/lib/pacemaker/pcmk_sched_utils.c @@ -765,34 +765,3 @@ pcmk__create_history_xml(xmlNode *parent, lrmd_event_data_t *op, free(key); return xml_op; } - -/*! - * \internal - * \brief Check whether a colocation constraint should apply - * - * \param[in] rsc Resource of interest (for logging) - * \param[in] colocation Colocation constraint to check - * \param[in] promoted_only If true, constraint applies if right-hand is promoted - */ -bool -pcmk__colocation_applies(pe_resource_t *rsc, pcmk__colocation_t *colocation, - bool promoted_only) -{ - CRM_CHECK((rsc != NULL) && (colocation != NULL), return false); - - if (colocation->score == 0) { - pe_rsc_trace(rsc, "Ignoring colocation constraint %s: 0 score", - colocation->id); - return false; - } - if (promoted_only && (colocation->role_rh != RSC_ROLE_MASTER)) { - pe_rsc_trace(rsc, "Ignoring colocation constraint %s: role", - colocation->id); - return false; - } - pe_rsc_trace(rsc, "Applying colocation constraint %s: %s with %s%s (%d)", - colocation->id, colocation->rsc_lh->id, - (promoted_only? "promoted " : ""), - colocation->rsc_rh->id, colocation->score); - return true; -}