mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #50581 from k82cn/k8s_50360_1
Automatic merge from submit-queue (batch tested with PRs 49342, 50581, 50777) Update RegisterMandatoryFitPredicate to avoid double register. **What this PR does / why we need it**: In https://github.com/kubernetes/kubernetes/pull/50362 , we introduced `RegisterMandatoryFitPredicate` to make some predicates always included by scheduler. This PRs is to improve it by avoiding double register: `RegisterFitPredicate` and `RegisterMandatoryFitPredicate` **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #50360 **Release note**: ```release-note None ```
This commit is contained in:
commit
acd5f22398
@ -176,7 +176,6 @@ func defaultPredicates() sets.String {
|
|||||||
factory.RegisterFitPredicate("CheckNodeDiskPressure", predicates.CheckNodeDiskPressurePredicate),
|
factory.RegisterFitPredicate("CheckNodeDiskPressure", predicates.CheckNodeDiskPressurePredicate),
|
||||||
|
|
||||||
// Fit is determied by node condtions: not ready, network unavailable and out of disk.
|
// Fit is determied by node condtions: not ready, network unavailable and out of disk.
|
||||||
factory.RegisterFitPredicate("CheckNodeCondition", predicates.CheckNodeConditionPredicate),
|
|
||||||
factory.RegisterMandatoryFitPredicate("CheckNodeCondition", predicates.CheckNodeConditionPredicate),
|
factory.RegisterMandatoryFitPredicate("CheckNodeCondition", predicates.CheckNodeConditionPredicate),
|
||||||
|
|
||||||
// Fit is determined by volume zone requirements.
|
// Fit is determined by volume zone requirements.
|
||||||
|
@ -73,7 +73,7 @@ var (
|
|||||||
|
|
||||||
// maps that hold registered algorithm types
|
// maps that hold registered algorithm types
|
||||||
fitPredicateMap = make(map[string]FitPredicateFactory)
|
fitPredicateMap = make(map[string]FitPredicateFactory)
|
||||||
mandatoryFitPredicateMap = make(map[string]FitPredicateFactory)
|
mandatoryFitPredicates = sets.NewString()
|
||||||
priorityFunctionMap = make(map[string]PriorityConfigFactory)
|
priorityFunctionMap = make(map[string]PriorityConfigFactory)
|
||||||
algorithmProviderMap = make(map[string]AlgorithmProviderConfig)
|
algorithmProviderMap = make(map[string]AlgorithmProviderConfig)
|
||||||
|
|
||||||
@ -107,7 +107,8 @@ func RegisterMandatoryFitPredicate(name string, predicate algorithm.FitPredicate
|
|||||||
schedulerFactoryMutex.Lock()
|
schedulerFactoryMutex.Lock()
|
||||||
defer schedulerFactoryMutex.Unlock()
|
defer schedulerFactoryMutex.Unlock()
|
||||||
validateAlgorithmNameOrDie(name)
|
validateAlgorithmNameOrDie(name)
|
||||||
mandatoryFitPredicateMap[name] = func(PluginFactoryArgs) algorithm.FitPredicate { return predicate }
|
fitPredicateMap[name] = func(PluginFactoryArgs) algorithm.FitPredicate { return predicate }
|
||||||
|
mandatoryFitPredicates.Insert(name)
|
||||||
return name
|
return name
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,9 +322,9 @@ func getFitPredicateFunctions(names sets.String, args PluginFactoryArgs) (map[st
|
|||||||
predicates[name] = factory(args)
|
predicates[name] = factory(args)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always include required fit predicates.
|
// Always include mandatory fit predicates.
|
||||||
for name, factory := range mandatoryFitPredicateMap {
|
for name := range mandatoryFitPredicates {
|
||||||
if _, found := predicates[name]; !found {
|
if factory, found := fitPredicateMap[name]; found {
|
||||||
predicates[name] = factory(args)
|
predicates[name] = factory(args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user