Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix comment and optimize code #38084

Merged
merged 1 commit into from
Jan 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type Topologies struct {
}

// NodesHaveSameTopologyKey checks if nodeA and nodeB have same label value with given topologyKey as label key.
// If the topologyKey is nil/empty, check if the two nodes have any of the default topologyKeys, and have same corresponding label value.
// If the topologyKey is empty, check if the two nodes have any of the default topologyKeys, and have same corresponding label value.
func (tps *Topologies) NodesHaveSameTopologyKey(nodeA, nodeB *v1.Node, topologyKey string) bool {
if len(topologyKey) == 0 {
// assumes this is allowed only for PreferredDuringScheduling pod anti-affinity (ensured by api/validation)
Expand Down
23 changes: 11 additions & 12 deletions plugin/pkg/scheduler/factory/plugins.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ var (
predicateMetadataProducer MetadataProducerFactory

// get equivalence pod function
getEquivalencePodFunc algorithm.GetEquivalencePodFunc = nil
getEquivalencePodFunc algorithm.GetEquivalencePodFunc
)

const (
Expand Down Expand Up @@ -110,7 +110,7 @@ func RegisterFitPredicateFactory(name string, predicateFactory FitPredicateFacto
return name
}

// Registers a custom fit predicate with the algorithm registry.
// RegisterCustomFitPredicate registers a custom fit predicate with the algorithm registry.
// Returns the name, with which the predicate was registered.
func RegisterCustomFitPredicate(policy schedulerapi.PredicatePolicy) string {
var predicateFactory FitPredicateFactory
Expand Down Expand Up @@ -154,7 +154,7 @@ func RegisterCustomFitPredicate(policy schedulerapi.PredicatePolicy) string {
return RegisterFitPredicateFactory(policy.Name, predicateFactory)
}

// This check is useful for testing providers.
// IsFitPredicateRegistered is useful for testing providers.
func IsFitPredicateRegistered(name string) bool {
schedulerFactoryMutex.Lock()
defer schedulerFactoryMutex.Unlock()
Expand Down Expand Up @@ -187,7 +187,7 @@ func RegisterPriorityFunction(name string, function algorithm.PriorityFunction,
})
}

// Registers a priority function with the algorithm registry. Returns the name,
// RegisterPriorityFunction2 registers a priority function with the algorithm registry. Returns the name,
// with which the function was registered.
// FIXME: Rename to PriorityFunctionFactory.
func RegisterPriorityFunction2(
Expand All @@ -211,7 +211,7 @@ func RegisterPriorityConfigFactory(name string, pcf PriorityConfigFactory) strin
return name
}

// Registers a custom priority function with the algorithm registry.
// RegisterCustomPriorityFunction registers a custom priority function with the algorithm registry.
// Returns the name, with which the priority function was registered.
func RegisterCustomPriorityFunction(policy schedulerapi.PriorityPolicy) string {
var pcf *PriorityConfigFactory
Expand Down Expand Up @@ -242,12 +242,12 @@ func RegisterCustomPriorityFunction(policy schedulerapi.PriorityPolicy) string {
Weight: policy.Weight,
}
}
} else if existing_pcf, ok := priorityFunctionMap[policy.Name]; ok {
} else if existingPcf, ok := priorityFunctionMap[policy.Name]; ok {
glog.V(2).Infof("Priority type %s already registered, reusing.", policy.Name)
// set/update the weight based on the policy
pcf = &PriorityConfigFactory{
Function: existing_pcf.Function,
MapReduceFunction: existing_pcf.MapReduceFunction,
Function: existingPcf.Function,
MapReduceFunction: existingPcf.MapReduceFunction,
Weight: policy.Weight,
}
}
Expand All @@ -263,15 +263,15 @@ func RegisterGetEquivalencePodFunction(equivalenceFunc algorithm.GetEquivalenceP
getEquivalencePodFunc = equivalenceFunc
}

// This check is useful for testing providers.
// IsPriorityFunctionRegistered is useful for testing providers.
func IsPriorityFunctionRegistered(name string) bool {
schedulerFactoryMutex.Lock()
defer schedulerFactoryMutex.Unlock()
_, ok := priorityFunctionMap[name]
return ok
}

// Registers a new algorithm provider with the algorithm registry. This should
// RegisterAlgorithmProvider registers a new algorithm provider with the algorithm registry. This should
// be called from the init function in a provider plugin.
func RegisterAlgorithmProvider(name string, predicateKeys, priorityKeys sets.String) string {
schedulerFactoryMutex.Lock()
Expand All @@ -284,12 +284,11 @@ func RegisterAlgorithmProvider(name string, predicateKeys, priorityKeys sets.Str
return name
}

// This function should not be used to modify providers. It is publicly visible for testing.
// GetAlgorithmProvider should not be used to modify providers. It is publicly visible for testing.
func GetAlgorithmProvider(name string) (*AlgorithmProviderConfig, error) {
schedulerFactoryMutex.Lock()
defer schedulerFactoryMutex.Unlock()

var provider AlgorithmProviderConfig
provider, ok := algorithmProviderMap[name]
if !ok {
return nil, fmt.Errorf("plugin %q has not been registered", name)
Expand Down