mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	Update RegisterMandatoryFitPredicate to avoid double register.
This commit is contained in:
		@@ -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 = make(map[string]bool)
 | 
				
			||||||
	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[name] = true
 | 
				
			||||||
	return name
 | 
						return name
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -321,12 +322,14 @@ 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, mandatory := range mandatoryFitPredicates {
 | 
				
			||||||
		if _, found := predicates[name]; !found {
 | 
							if mandatory {
 | 
				
			||||||
 | 
								if factory, found := fitPredicateMap[name]; found {
 | 
				
			||||||
				predicates[name] = factory(args)
 | 
									predicates[name] = factory(args)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return predicates, nil
 | 
						return predicates, nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user