From 65302166c963b25f00c89e63936a10c69048297b Mon Sep 17 00:00:00 2001 From: Ken Gaillot Date: Feb 05 2021 06:23:22 +0000 Subject: Feature: scheduler: implement new critical and influence options The feature set is bumped because critical is a resource meta-attribute and thus not dependent on schema version, and we don't want it to flip back and forth between being respected or not. critical just sets a resource-wide default for influence, so only influence is actually used in scheduling. It's a little tricky deciding when to consider influence. The basic idea is that when a colocation constraint "A with B" has no influence, A's location preferences should not influence B's location. But the colocation still matters for things like where A is allowed to run. Thus we only consider it when cycling through a resource's ->rsc_cons_lhs to add the dependents' preferences. --- diff --git a/include/crm/crm.h b/include/crm/crm.h index 4bbf46a..3f22c4b 100644 --- a/include/crm/crm.h +++ b/include/crm/crm.h @@ -1,5 +1,5 @@ /* - * Copyright 2004-2020 the Pacemaker project contributors + * Copyright 2004-2021 the Pacemaker project contributors * * The version control history for this file may have further details. * @@ -51,7 +51,7 @@ extern "C" { * >=3.0.13: Fail counts include operation name and interval * >=3.2.0: DC supports PCMK_LRM_OP_INVALID and PCMK_LRM_OP_NOT_CONNECTED */ -# define CRM_FEATURE_SET "3.6.4" +# define CRM_FEATURE_SET "3.7.0" # define EOS '\0' # define DIMOF(a) ((int) (sizeof(a)/sizeof(a[0])) ) diff --git a/lib/pacemaker/pcmk_sched_clone.c b/lib/pacemaker/pcmk_sched_clone.c index 3cfc06c..dd6ff48 100644 --- a/lib/pacemaker/pcmk_sched_clone.c +++ b/lib/pacemaker/pcmk_sched_clone.c @@ -251,6 +251,9 @@ sort_clone_instance(gconstpointer a, gconstpointer b, gpointer data_set) for (gIter = resource1->parent->rsc_cons_lhs; gIter; gIter = gIter->next) { pcmk__colocation_t *constraint = (pcmk__colocation_t *) gIter->data; + if (!pcmk__colocation_has_influence(constraint, resource1)) { + continue; + } crm_trace("Applying %s to %s", constraint->id, resource1->id); hash1 = pcmk__native_merge_weights(constraint->rsc_lh, @@ -277,6 +280,9 @@ sort_clone_instance(gconstpointer a, gconstpointer b, gpointer data_set) for (gIter = resource2->parent->rsc_cons_lhs; gIter; gIter = gIter->next) { pcmk__colocation_t *constraint = (pcmk__colocation_t *) gIter->data; + if (!pcmk__colocation_has_influence(constraint, resource2)) { + continue; + } crm_trace("Applying %s to %s", constraint->id, resource2->id); hash2 = pcmk__native_merge_weights(constraint->rsc_lh, @@ -504,6 +510,9 @@ append_parent_colocation(pe_resource_t * rsc, pe_resource_t * child, gboolean al for (; gIter != NULL; gIter = gIter->next) { pcmk__colocation_t *cons = (pcmk__colocation_t *) gIter->data; + if (!pcmk__colocation_has_influence(cons, child)) { + continue; + } if (all || cons->score < 0) { child->rsc_cons_lhs = g_list_prepend(child->rsc_cons_lhs, cons); } @@ -643,6 +652,9 @@ 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_has_influence(constraint, NULL)) { + continue; + } rsc->allowed_nodes = constraint->rsc_lh->cmds->merge_weights(constraint->rsc_lh, rsc->id, rsc->allowed_nodes, constraint->node_attribute, diff --git a/lib/pacemaker/pcmk_sched_native.c b/lib/pacemaker/pcmk_sched_native.c index 6da3d17..6abada2 100644 --- a/lib/pacemaker/pcmk_sched_native.c +++ b/lib/pacemaker/pcmk_sched_native.c @@ -440,6 +440,8 @@ pcmk__native_merge_weights(pe_resource_t *rsc, const char *rhs, if (pcmk_is_set(flags, pe_weights_forward)) { other = constraint->rsc_rh; + } else if (!pcmk__colocation_has_influence(constraint, NULL)) { + continue; } else { other = constraint->rsc_lh; } @@ -556,6 +558,9 @@ 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_has_influence(constraint, NULL)) { + continue; + } pe_rsc_trace(rsc, "Merging score of '%s' constraint (%s with %s)", constraint->id, constraint->rsc_lh->id, constraint->rsc_rh->id); diff --git a/lib/pacemaker/pcmk_sched_promotable.c b/lib/pacemaker/pcmk_sched_promotable.c index 0b4f826..40d07e9 100644 --- a/lib/pacemaker/pcmk_sched_promotable.c +++ b/lib/pacemaker/pcmk_sched_promotable.c @@ -341,6 +341,10 @@ 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_has_influence(constraint, NULL)) { + continue; + } + /* (re-)adds location preferences of resource that wish to be * colocated with the master instance */