mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
refactor(scheduling): remove priorities package
This commit is contained in:
parent
da9fdc933b
commit
2c3c6721ce
@ -14,7 +14,6 @@ go_library(
|
|||||||
"//pkg/features:go_default_library",
|
"//pkg/features:go_default_library",
|
||||||
"//pkg/scheduler/algorithm:go_default_library",
|
"//pkg/scheduler/algorithm:go_default_library",
|
||||||
"//pkg/scheduler/algorithm/predicates:go_default_library",
|
"//pkg/scheduler/algorithm/predicates:go_default_library",
|
||||||
"//pkg/scheduler/algorithm/priorities:go_default_library",
|
|
||||||
"//pkg/scheduler/algorithmprovider:go_default_library",
|
"//pkg/scheduler/algorithmprovider:go_default_library",
|
||||||
"//pkg/scheduler/apis/config:go_default_library",
|
"//pkg/scheduler/apis/config:go_default_library",
|
||||||
"//pkg/scheduler/apis/config/scheme:go_default_library",
|
"//pkg/scheduler/apis/config/scheme:go_default_library",
|
||||||
@ -67,7 +66,6 @@ go_test(
|
|||||||
"//pkg/features:go_default_library",
|
"//pkg/features:go_default_library",
|
||||||
"//pkg/scheduler/algorithm:go_default_library",
|
"//pkg/scheduler/algorithm:go_default_library",
|
||||||
"//pkg/scheduler/algorithm/predicates:go_default_library",
|
"//pkg/scheduler/algorithm/predicates:go_default_library",
|
||||||
"//pkg/scheduler/algorithm/priorities:go_default_library",
|
|
||||||
"//pkg/scheduler/apis/config:go_default_library",
|
"//pkg/scheduler/apis/config:go_default_library",
|
||||||
"//pkg/scheduler/apis/config/scheme:go_default_library",
|
"//pkg/scheduler/apis/config/scheme:go_default_library",
|
||||||
"//pkg/scheduler/apis/extender/v1:go_default_library",
|
"//pkg/scheduler/apis/extender/v1:go_default_library",
|
||||||
|
@ -1,29 +1,5 @@
|
|||||||
package(default_visibility = ["//visibility:public"])
|
package(default_visibility = ["//visibility:public"])
|
||||||
|
|
||||||
load(
|
|
||||||
"@io_bazel_rules_go//go:def.bzl",
|
|
||||||
"go_library",
|
|
||||||
)
|
|
||||||
|
|
||||||
go_library(
|
|
||||||
name = "go_default_library",
|
|
||||||
srcs = [
|
|
||||||
"metadata.go",
|
|
||||||
"priorities.go",
|
|
||||||
"reduce.go",
|
|
||||||
"types.go",
|
|
||||||
],
|
|
||||||
importpath = "k8s.io/kubernetes/pkg/scheduler/algorithm/priorities",
|
|
||||||
deps = [
|
|
||||||
"//pkg/scheduler/framework/v1alpha1:go_default_library",
|
|
||||||
"//pkg/scheduler/listers:go_default_library",
|
|
||||||
"//pkg/scheduler/nodeinfo:go_default_library",
|
|
||||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/listers/apps/v1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/client-go/listers/core/v1:go_default_library",
|
|
||||||
],
|
|
||||||
)
|
|
||||||
|
|
||||||
filegroup(
|
filegroup(
|
||||||
name = "package-srcs",
|
name = "package-srcs",
|
||||||
srcs = glob(["**"]),
|
srcs = glob(["**"]),
|
||||||
|
@ -1,64 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2016 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package priorities
|
|
||||||
|
|
||||||
import (
|
|
||||||
v1 "k8s.io/api/core/v1"
|
|
||||||
appslisters "k8s.io/client-go/listers/apps/v1"
|
|
||||||
corelisters "k8s.io/client-go/listers/core/v1"
|
|
||||||
schedulerlisters "k8s.io/kubernetes/pkg/scheduler/listers"
|
|
||||||
)
|
|
||||||
|
|
||||||
// MetadataFactory is a factory to produce PriorityMetadata.
|
|
||||||
type MetadataFactory struct {
|
|
||||||
serviceLister corelisters.ServiceLister
|
|
||||||
controllerLister corelisters.ReplicationControllerLister
|
|
||||||
replicaSetLister appslisters.ReplicaSetLister
|
|
||||||
statefulSetLister appslisters.StatefulSetLister
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewMetadataFactory creates a MetadataFactory.
|
|
||||||
func NewMetadataFactory(
|
|
||||||
serviceLister corelisters.ServiceLister,
|
|
||||||
controllerLister corelisters.ReplicationControllerLister,
|
|
||||||
replicaSetLister appslisters.ReplicaSetLister,
|
|
||||||
statefulSetLister appslisters.StatefulSetLister,
|
|
||||||
) MetadataProducer {
|
|
||||||
factory := &MetadataFactory{
|
|
||||||
serviceLister: serviceLister,
|
|
||||||
controllerLister: controllerLister,
|
|
||||||
replicaSetLister: replicaSetLister,
|
|
||||||
statefulSetLister: statefulSetLister,
|
|
||||||
}
|
|
||||||
return factory.PriorityMetadata
|
|
||||||
}
|
|
||||||
|
|
||||||
// priorityMetadata is a type that is passed as metadata for priority functions
|
|
||||||
type priorityMetadata struct{}
|
|
||||||
|
|
||||||
// PriorityMetadata is a MetadataProducer. Node info can be nil.
|
|
||||||
func (pmf *MetadataFactory) PriorityMetadata(
|
|
||||||
pod *v1.Pod,
|
|
||||||
filteredNodes []*v1.Node,
|
|
||||||
sharedLister schedulerlisters.SharedLister,
|
|
||||||
) interface{} {
|
|
||||||
// If we cannot compute metadata, just return nil
|
|
||||||
if pod == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return &priorityMetadata{}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2018 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package priorities
|
|
||||||
|
|
||||||
const (
|
|
||||||
// EqualPriority defines the name of prioritizer function that gives an equal weight of one to all nodes.
|
|
||||||
EqualPriority = "EqualPriority"
|
|
||||||
// MostRequestedPriority defines the name of prioritizer function that gives used nodes higher priority.
|
|
||||||
MostRequestedPriority = "MostRequestedPriority"
|
|
||||||
// RequestedToCapacityRatioPriority defines the name of RequestedToCapacityRatioPriority.
|
|
||||||
RequestedToCapacityRatioPriority = "RequestedToCapacityRatioPriority"
|
|
||||||
// SelectorSpreadPriority defines the name of prioritizer function that spreads pods by minimizing
|
|
||||||
// the number of pods (belonging to the same service or replication controller) on the same node.
|
|
||||||
SelectorSpreadPriority = "SelectorSpreadPriority"
|
|
||||||
// ServiceSpreadingPriority is largely replaced by "SelectorSpreadPriority".
|
|
||||||
ServiceSpreadingPriority = "ServiceSpreadingPriority"
|
|
||||||
// InterPodAffinityPriority defines the name of prioritizer function that decides which pods should or
|
|
||||||
// should not be placed in the same topological domain as some other pods.
|
|
||||||
InterPodAffinityPriority = "InterPodAffinityPriority"
|
|
||||||
// LeastRequestedPriority defines the name of prioritizer function that prioritize nodes by least
|
|
||||||
// requested utilization.
|
|
||||||
LeastRequestedPriority = "LeastRequestedPriority"
|
|
||||||
// BalancedResourceAllocation defines the name of prioritizer function that prioritizes nodes
|
|
||||||
// to help achieve balanced resource usage.
|
|
||||||
BalancedResourceAllocation = "BalancedResourceAllocation"
|
|
||||||
// NodePreferAvoidPodsPriority defines the name of prioritizer function that priorities nodes according to
|
|
||||||
// the node annotation "scheduler.alpha.kubernetes.io/preferAvoidPods".
|
|
||||||
NodePreferAvoidPodsPriority = "NodePreferAvoidPodsPriority"
|
|
||||||
// NodeAffinityPriority defines the name of prioritizer function that prioritizes nodes which have labels
|
|
||||||
// matching NodeAffinity.
|
|
||||||
NodeAffinityPriority = "NodeAffinityPriority"
|
|
||||||
// TaintTolerationPriority defines the name of prioritizer function that prioritizes nodes that marked
|
|
||||||
// with taint which pod can tolerate.
|
|
||||||
TaintTolerationPriority = "TaintTolerationPriority"
|
|
||||||
// ImageLocalityPriority defines the name of prioritizer function that prioritizes nodes that have images
|
|
||||||
// requested by the pod present.
|
|
||||||
ImageLocalityPriority = "ImageLocalityPriority"
|
|
||||||
// ResourceLimitsPriority defines the nodes of prioritizer function ResourceLimitsPriority.
|
|
||||||
ResourceLimitsPriority = "ResourceLimitsPriority"
|
|
||||||
// EvenPodsSpreadPriority defines the name of prioritizer function that prioritizes nodes
|
|
||||||
// which have pods and labels matching the incoming pod's topologySpreadConstraints.
|
|
||||||
EvenPodsSpreadPriority = "EvenPodsSpreadPriority"
|
|
||||||
)
|
|
@ -1,63 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2017 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package priorities
|
|
||||||
|
|
||||||
import (
|
|
||||||
"k8s.io/api/core/v1"
|
|
||||||
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
|
|
||||||
schedulerlisters "k8s.io/kubernetes/pkg/scheduler/listers"
|
|
||||||
)
|
|
||||||
|
|
||||||
// NormalizeReduce generates a PriorityReduceFunction that can normalize the result
|
|
||||||
// scores to [0, maxPriority]. If reverse is set to true, it reverses the scores by
|
|
||||||
// subtracting it from maxPriority.
|
|
||||||
func NormalizeReduce(maxPriority int64, reverse bool) PriorityReduceFunction {
|
|
||||||
return func(
|
|
||||||
_ *v1.Pod,
|
|
||||||
_ interface{},
|
|
||||||
_ schedulerlisters.SharedLister,
|
|
||||||
result framework.NodeScoreList) error {
|
|
||||||
|
|
||||||
var maxCount int64
|
|
||||||
for i := range result {
|
|
||||||
if result[i].Score > maxCount {
|
|
||||||
maxCount = result[i].Score
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if maxCount == 0 {
|
|
||||||
if reverse {
|
|
||||||
for i := range result {
|
|
||||||
result[i].Score = maxPriority
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := range result {
|
|
||||||
score := result[i].Score
|
|
||||||
|
|
||||||
score = maxPriority * score / maxCount
|
|
||||||
if reverse {
|
|
||||||
score = maxPriority - score
|
|
||||||
}
|
|
||||||
|
|
||||||
result[i].Score = score
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2018 The Kubernetes Authors.
|
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
you may not use this file except in compliance with the License.
|
|
||||||
You may obtain a copy of the License at
|
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
See the License for the specific language governing permissions and
|
|
||||||
limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package priorities
|
|
||||||
|
|
||||||
import (
|
|
||||||
v1 "k8s.io/api/core/v1"
|
|
||||||
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
|
|
||||||
schedulerlisters "k8s.io/kubernetes/pkg/scheduler/listers"
|
|
||||||
schedulernodeinfo "k8s.io/kubernetes/pkg/scheduler/nodeinfo"
|
|
||||||
)
|
|
||||||
|
|
||||||
// PriorityMapFunction is a function that computes per-node results for a given node.
|
|
||||||
// TODO: Figure out the exact API of this method.
|
|
||||||
// TODO: Change interface{} to a specific type.
|
|
||||||
type PriorityMapFunction func(pod *v1.Pod, meta interface{}, nodeInfo *schedulernodeinfo.NodeInfo) (framework.NodeScore, error)
|
|
||||||
|
|
||||||
// PriorityReduceFunction is a function that aggregated per-node results and computes
|
|
||||||
// final scores for all nodes.
|
|
||||||
// TODO: Figure out the exact API of this method.
|
|
||||||
// TODO: Change interface{} to a specific type.
|
|
||||||
type PriorityReduceFunction func(pod *v1.Pod, meta interface{}, sharedLister schedulerlisters.SharedLister, result framework.NodeScoreList) error
|
|
||||||
|
|
||||||
// MetadataProducer is a function that computes metadata for a given pod. This
|
|
||||||
// is now used for only for priority functions. For predicates please use PredicateMetadataProducer.
|
|
||||||
type MetadataProducer func(pod *v1.Pod, filteredNodes []*v1.Node, sharedLister schedulerlisters.SharedLister) interface{}
|
|
||||||
|
|
||||||
// PriorityConfig is a config used for a priority function.
|
|
||||||
type PriorityConfig struct {
|
|
||||||
Name string
|
|
||||||
Map PriorityMapFunction
|
|
||||||
Reduce PriorityReduceFunction
|
|
||||||
Weight int64
|
|
||||||
}
|
|
||||||
|
|
||||||
// EmptyMetadataProducer returns a no-op MetadataProducer type.
|
|
||||||
func EmptyMetadataProducer(pod *v1.Pod, filteredNodes []*v1.Node, sharedLister schedulerlisters.SharedLister) interface{} {
|
|
||||||
return nil
|
|
||||||
}
|
|
@ -11,10 +11,8 @@ go_library(
|
|||||||
deps = [
|
deps = [
|
||||||
"//pkg/api/v1/pod:go_default_library",
|
"//pkg/api/v1/pod:go_default_library",
|
||||||
"//pkg/scheduler/algorithm:go_default_library",
|
"//pkg/scheduler/algorithm:go_default_library",
|
||||||
"//pkg/scheduler/algorithm/priorities:go_default_library",
|
|
||||||
"//pkg/scheduler/apis/config:go_default_library",
|
"//pkg/scheduler/apis/config:go_default_library",
|
||||||
"//pkg/scheduler/apis/extender/v1:go_default_library",
|
"//pkg/scheduler/apis/extender/v1:go_default_library",
|
||||||
"//pkg/scheduler/framework/plugins/migration:go_default_library",
|
|
||||||
"//pkg/scheduler/framework/v1alpha1:go_default_library",
|
"//pkg/scheduler/framework/v1alpha1:go_default_library",
|
||||||
"//pkg/scheduler/internal/cache:go_default_library",
|
"//pkg/scheduler/internal/cache:go_default_library",
|
||||||
"//pkg/scheduler/internal/queue:go_default_library",
|
"//pkg/scheduler/internal/queue:go_default_library",
|
||||||
@ -50,7 +48,6 @@ go_test(
|
|||||||
"//pkg/api/v1/pod:go_default_library",
|
"//pkg/api/v1/pod:go_default_library",
|
||||||
"//pkg/scheduler/algorithm:go_default_library",
|
"//pkg/scheduler/algorithm:go_default_library",
|
||||||
"//pkg/scheduler/algorithm/predicates:go_default_library",
|
"//pkg/scheduler/algorithm/predicates:go_default_library",
|
||||||
"//pkg/scheduler/algorithm/priorities:go_default_library",
|
|
||||||
"//pkg/scheduler/algorithm/priorities/util:go_default_library",
|
"//pkg/scheduler/algorithm/priorities/util:go_default_library",
|
||||||
"//pkg/scheduler/apis/config:go_default_library",
|
"//pkg/scheduler/apis/config:go_default_library",
|
||||||
"//pkg/scheduler/apis/extender/v1:go_default_library",
|
"//pkg/scheduler/apis/extender/v1:go_default_library",
|
||||||
|
@ -34,7 +34,6 @@ import (
|
|||||||
clientsetfake "k8s.io/client-go/kubernetes/fake"
|
clientsetfake "k8s.io/client-go/kubernetes/fake"
|
||||||
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
|
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/algorithm"
|
"k8s.io/kubernetes/pkg/scheduler/algorithm"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/algorithm/priorities"
|
|
||||||
schedulerapi "k8s.io/kubernetes/pkg/scheduler/apis/config"
|
schedulerapi "k8s.io/kubernetes/pkg/scheduler/apis/config"
|
||||||
extenderv1 "k8s.io/kubernetes/pkg/scheduler/apis/extender/v1"
|
extenderv1 "k8s.io/kubernetes/pkg/scheduler/apis/extender/v1"
|
||||||
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
|
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
|
||||||
@ -581,7 +580,6 @@ func TestGenericSchedulerWithExtenders(t *testing.T) {
|
|||||||
scheduler := NewGenericScheduler(
|
scheduler := NewGenericScheduler(
|
||||||
cache,
|
cache,
|
||||||
queue,
|
queue,
|
||||||
priorities.EmptyMetadataProducer,
|
|
||||||
emptySnapshot,
|
emptySnapshot,
|
||||||
fwk,
|
fwk,
|
||||||
extenders,
|
extenders,
|
||||||
|
@ -38,9 +38,7 @@ import (
|
|||||||
"k8s.io/client-go/util/workqueue"
|
"k8s.io/client-go/util/workqueue"
|
||||||
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
|
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/algorithm"
|
"k8s.io/kubernetes/pkg/scheduler/algorithm"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/algorithm/priorities"
|
|
||||||
extenderv1 "k8s.io/kubernetes/pkg/scheduler/apis/extender/v1"
|
extenderv1 "k8s.io/kubernetes/pkg/scheduler/apis/extender/v1"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/migration"
|
|
||||||
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
|
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
|
||||||
internalcache "k8s.io/kubernetes/pkg/scheduler/internal/cache"
|
internalcache "k8s.io/kubernetes/pkg/scheduler/internal/cache"
|
||||||
internalqueue "k8s.io/kubernetes/pkg/scheduler/internal/queue"
|
internalqueue "k8s.io/kubernetes/pkg/scheduler/internal/queue"
|
||||||
@ -138,8 +136,6 @@ type ScheduleResult struct {
|
|||||||
type genericScheduler struct {
|
type genericScheduler struct {
|
||||||
cache internalcache.Cache
|
cache internalcache.Cache
|
||||||
schedulingQueue internalqueue.SchedulingQueue
|
schedulingQueue internalqueue.SchedulingQueue
|
||||||
priorityMetaProducer priorities.MetadataProducer
|
|
||||||
prioritizers []priorities.PriorityConfig
|
|
||||||
framework framework.Framework
|
framework framework.Framework
|
||||||
extenders []algorithm.SchedulerExtender
|
extenders []algorithm.SchedulerExtender
|
||||||
nodeInfoSnapshot *nodeinfosnapshot.Snapshot
|
nodeInfoSnapshot *nodeinfosnapshot.Snapshot
|
||||||
@ -231,8 +227,7 @@ func (g *genericScheduler) Schedule(ctx context.Context, state *framework.CycleS
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
metaPrioritiesInterface := g.priorityMetaProducer(pod, filteredNodes, g.nodeInfoSnapshot)
|
priorityList, err := g.prioritizeNodes(ctx, state, pod, filteredNodes)
|
||||||
priorityList, err := g.prioritizeNodes(ctx, state, pod, metaPrioritiesInterface, filteredNodes)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, err
|
return result, err
|
||||||
}
|
}
|
||||||
@ -252,12 +247,6 @@ func (g *genericScheduler) Schedule(ctx context.Context, state *framework.CycleS
|
|||||||
}, err
|
}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prioritizers returns a slice containing all the scheduler's priority
|
|
||||||
// functions and their config. It is exposed for testing only.
|
|
||||||
func (g *genericScheduler) Prioritizers() []priorities.PriorityConfig {
|
|
||||||
return g.prioritizers
|
|
||||||
}
|
|
||||||
|
|
||||||
func (g *genericScheduler) Extenders() []algorithm.SchedulerExtender {
|
func (g *genericScheduler) Extenders() []algorithm.SchedulerExtender {
|
||||||
return g.extenders
|
return g.extenders
|
||||||
}
|
}
|
||||||
@ -630,7 +619,6 @@ func (g *genericScheduler) prioritizeNodes(
|
|||||||
ctx context.Context,
|
ctx context.Context,
|
||||||
state *framework.CycleState,
|
state *framework.CycleState,
|
||||||
pod *v1.Pod,
|
pod *v1.Pod,
|
||||||
meta interface{},
|
|
||||||
nodes []*v1.Node,
|
nodes []*v1.Node,
|
||||||
) (framework.NodeScoreList, error) {
|
) (framework.NodeScoreList, error) {
|
||||||
// If no priority configs are provided, then all nodes will have a score of one.
|
// If no priority configs are provided, then all nodes will have a score of one.
|
||||||
@ -647,7 +635,6 @@ func (g *genericScheduler) prioritizeNodes(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run the Score plugins.
|
// Run the Score plugins.
|
||||||
state.Write(migration.PrioritiesStateKey, &migration.PrioritiesStateData{Reference: meta})
|
|
||||||
scoresMap, scoreStatus := g.framework.RunScorePlugins(ctx, state, pod, nodes)
|
scoresMap, scoreStatus := g.framework.RunScorePlugins(ctx, state, pod, nodes)
|
||||||
if !scoreStatus.IsSuccess() {
|
if !scoreStatus.IsSuccess() {
|
||||||
return framework.NodeScoreList{}, scoreStatus.AsError()
|
return framework.NodeScoreList{}, scoreStatus.AsError()
|
||||||
@ -1096,7 +1083,6 @@ func podPassesBasicChecks(pod *v1.Pod, pvcLister corelisters.PersistentVolumeCla
|
|||||||
func NewGenericScheduler(
|
func NewGenericScheduler(
|
||||||
cache internalcache.Cache,
|
cache internalcache.Cache,
|
||||||
podQueue internalqueue.SchedulingQueue,
|
podQueue internalqueue.SchedulingQueue,
|
||||||
priorityMetaProducer priorities.MetadataProducer,
|
|
||||||
nodeInfoSnapshot *nodeinfosnapshot.Snapshot,
|
nodeInfoSnapshot *nodeinfosnapshot.Snapshot,
|
||||||
framework framework.Framework,
|
framework framework.Framework,
|
||||||
extenders []algorithm.SchedulerExtender,
|
extenders []algorithm.SchedulerExtender,
|
||||||
@ -1109,7 +1095,6 @@ func NewGenericScheduler(
|
|||||||
return &genericScheduler{
|
return &genericScheduler{
|
||||||
cache: cache,
|
cache: cache,
|
||||||
schedulingQueue: podQueue,
|
schedulingQueue: podQueue,
|
||||||
priorityMetaProducer: priorityMetaProducer,
|
|
||||||
framework: framework,
|
framework: framework,
|
||||||
extenders: extenders,
|
extenders: extenders,
|
||||||
nodeInfoSnapshot: nodeInfoSnapshot,
|
nodeInfoSnapshot: nodeInfoSnapshot,
|
||||||
|
@ -38,7 +38,6 @@ import (
|
|||||||
clientsetfake "k8s.io/client-go/kubernetes/fake"
|
clientsetfake "k8s.io/client-go/kubernetes/fake"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/algorithm"
|
"k8s.io/kubernetes/pkg/scheduler/algorithm"
|
||||||
algorithmpredicates "k8s.io/kubernetes/pkg/scheduler/algorithm/predicates"
|
algorithmpredicates "k8s.io/kubernetes/pkg/scheduler/algorithm/predicates"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/algorithm/priorities"
|
|
||||||
priorityutil "k8s.io/kubernetes/pkg/scheduler/algorithm/priorities/util"
|
priorityutil "k8s.io/kubernetes/pkg/scheduler/algorithm/priorities/util"
|
||||||
schedulerapi "k8s.io/kubernetes/pkg/scheduler/apis/config"
|
schedulerapi "k8s.io/kubernetes/pkg/scheduler/apis/config"
|
||||||
extenderv1 "k8s.io/kubernetes/pkg/scheduler/apis/extender/v1"
|
extenderv1 "k8s.io/kubernetes/pkg/scheduler/apis/extender/v1"
|
||||||
@ -784,7 +783,6 @@ func TestGenericScheduler(t *testing.T) {
|
|||||||
scheduler := NewGenericScheduler(
|
scheduler := NewGenericScheduler(
|
||||||
cache,
|
cache,
|
||||||
internalqueue.NewSchedulingQueue(nil),
|
internalqueue.NewSchedulingQueue(nil),
|
||||||
priorities.EmptyMetadataProducer,
|
|
||||||
snapshot,
|
snapshot,
|
||||||
fwk,
|
fwk,
|
||||||
[]algorithm.SchedulerExtender{},
|
[]algorithm.SchedulerExtender{},
|
||||||
@ -828,7 +826,6 @@ func makeScheduler(nodes []*v1.Node, fns ...st.RegisterPluginFunc) *genericSched
|
|||||||
s := NewGenericScheduler(
|
s := NewGenericScheduler(
|
||||||
cache,
|
cache,
|
||||||
internalqueue.NewSchedulingQueue(nil),
|
internalqueue.NewSchedulingQueue(nil),
|
||||||
priorities.EmptyMetadataProducer,
|
|
||||||
emptySnapshot,
|
emptySnapshot,
|
||||||
fwk,
|
fwk,
|
||||||
nil, nil, nil, nil, false,
|
nil, nil, nil, nil, false,
|
||||||
@ -951,7 +948,6 @@ func TestFindFitPredicateCallCounts(t *testing.T) {
|
|||||||
scheduler := NewGenericScheduler(
|
scheduler := NewGenericScheduler(
|
||||||
cache,
|
cache,
|
||||||
queue,
|
queue,
|
||||||
priorities.EmptyMetadataProducer,
|
|
||||||
emptySnapshot,
|
emptySnapshot,
|
||||||
fwk,
|
fwk,
|
||||||
nil, nil, nil, nil, false,
|
nil, nil, nil, nil, false,
|
||||||
@ -1107,15 +1103,6 @@ func TestZeroRequest(t *testing.T) {
|
|||||||
|
|
||||||
snapshot := nodeinfosnapshot.NewSnapshot(nodeinfosnapshot.CreateNodeInfoMap(test.pods, test.nodes))
|
snapshot := nodeinfosnapshot.NewSnapshot(nodeinfosnapshot.CreateNodeInfoMap(test.pods, test.nodes))
|
||||||
|
|
||||||
metadataProducer := priorities.NewMetadataFactory(
|
|
||||||
informerFactory.Core().V1().Services().Lister(),
|
|
||||||
informerFactory.Core().V1().ReplicationControllers().Lister(),
|
|
||||||
informerFactory.Apps().V1().ReplicaSets().Lister(),
|
|
||||||
informerFactory.Apps().V1().StatefulSets().Lister(),
|
|
||||||
)
|
|
||||||
|
|
||||||
metadata := metadataProducer(test.pod, test.nodes, snapshot)
|
|
||||||
|
|
||||||
registry := framework.Registry{}
|
registry := framework.Registry{}
|
||||||
plugins := &schedulerapi.Plugins{
|
plugins := &schedulerapi.Plugins{
|
||||||
Filter: &schedulerapi.PluginSet{},
|
Filter: &schedulerapi.PluginSet{},
|
||||||
@ -1147,7 +1134,6 @@ func TestZeroRequest(t *testing.T) {
|
|||||||
scheduler := NewGenericScheduler(
|
scheduler := NewGenericScheduler(
|
||||||
nil,
|
nil,
|
||||||
nil,
|
nil,
|
||||||
metadataProducer,
|
|
||||||
emptySnapshot,
|
emptySnapshot,
|
||||||
fwk,
|
fwk,
|
||||||
[]algorithm.SchedulerExtender{},
|
[]algorithm.SchedulerExtender{},
|
||||||
@ -1170,7 +1156,6 @@ func TestZeroRequest(t *testing.T) {
|
|||||||
ctx,
|
ctx,
|
||||||
state,
|
state,
|
||||||
test.pod,
|
test.pod,
|
||||||
metadata,
|
|
||||||
test.nodes,
|
test.nodes,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1595,7 +1580,6 @@ func TestSelectNodesForPreemption(t *testing.T) {
|
|||||||
scheduler := NewGenericScheduler(
|
scheduler := NewGenericScheduler(
|
||||||
nil,
|
nil,
|
||||||
internalqueue.NewSchedulingQueue(nil),
|
internalqueue.NewSchedulingQueue(nil),
|
||||||
priorities.EmptyMetadataProducer,
|
|
||||||
snapshot,
|
snapshot,
|
||||||
fwk,
|
fwk,
|
||||||
[]algorithm.SchedulerExtender{},
|
[]algorithm.SchedulerExtender{},
|
||||||
@ -2329,7 +2313,6 @@ func TestPreempt(t *testing.T) {
|
|||||||
scheduler := NewGenericScheduler(
|
scheduler := NewGenericScheduler(
|
||||||
cache,
|
cache,
|
||||||
internalqueue.NewSchedulingQueue(nil),
|
internalqueue.NewSchedulingQueue(nil),
|
||||||
priorities.EmptyMetadataProducer,
|
|
||||||
snapshot,
|
snapshot,
|
||||||
fwk,
|
fwk,
|
||||||
extenders,
|
extenders,
|
||||||
|
@ -40,7 +40,6 @@ import (
|
|||||||
kubefeatures "k8s.io/kubernetes/pkg/features"
|
kubefeatures "k8s.io/kubernetes/pkg/features"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/algorithm"
|
"k8s.io/kubernetes/pkg/scheduler/algorithm"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/algorithm/predicates"
|
"k8s.io/kubernetes/pkg/scheduler/algorithm/predicates"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/algorithm/priorities"
|
|
||||||
"k8s.io/kubernetes/pkg/scheduler/algorithmprovider"
|
"k8s.io/kubernetes/pkg/scheduler/algorithmprovider"
|
||||||
schedulerapi "k8s.io/kubernetes/pkg/scheduler/apis/config"
|
schedulerapi "k8s.io/kubernetes/pkg/scheduler/apis/config"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/apis/config/validation"
|
"k8s.io/kubernetes/pkg/scheduler/apis/config/validation"
|
||||||
@ -146,12 +145,6 @@ func (c *Configurator) create(extenders []algorithm.SchedulerExtender) (*Schedul
|
|||||||
algo := core.NewGenericScheduler(
|
algo := core.NewGenericScheduler(
|
||||||
c.schedulerCache,
|
c.schedulerCache,
|
||||||
podQueue,
|
podQueue,
|
||||||
priorities.NewMetadataFactory(
|
|
||||||
c.informerFactory.Core().V1().Services().Lister(),
|
|
||||||
c.informerFactory.Core().V1().ReplicationControllers().Lister(),
|
|
||||||
c.informerFactory.Apps().V1().ReplicaSets().Lister(),
|
|
||||||
c.informerFactory.Apps().V1().StatefulSets().Lister(),
|
|
||||||
),
|
|
||||||
c.nodeInfoSnapshot,
|
c.nodeInfoSnapshot,
|
||||||
framework,
|
framework,
|
||||||
extenders,
|
extenders,
|
||||||
@ -228,7 +221,7 @@ func (c *Configurator) createFromConfig(policy schedulerapi.Policy) (*Scheduler,
|
|||||||
priorityKeys = lr.DefaultPriorities
|
priorityKeys = lr.DefaultPriorities
|
||||||
} else {
|
} else {
|
||||||
for _, priority := range policy.Priorities {
|
for _, priority := range policy.Priorities {
|
||||||
if priority.Name == priorities.EqualPriority {
|
if priority.Name == plugins.EqualPriority {
|
||||||
klog.V(2).Infof("Skip registering priority: %s", priority.Name)
|
klog.V(2).Infof("Skip registering priority: %s", priority.Name)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ go_library(
|
|||||||
deps = [
|
deps = [
|
||||||
"//pkg/features:go_default_library",
|
"//pkg/features:go_default_library",
|
||||||
"//pkg/scheduler/algorithm/predicates:go_default_library",
|
"//pkg/scheduler/algorithm/predicates:go_default_library",
|
||||||
"//pkg/scheduler/algorithm/priorities:go_default_library",
|
|
||||||
"//pkg/scheduler/apis/config:go_default_library",
|
"//pkg/scheduler/apis/config:go_default_library",
|
||||||
"//pkg/scheduler/framework/plugins/defaultpodtopologyspread:go_default_library",
|
"//pkg/scheduler/framework/plugins/defaultpodtopologyspread:go_default_library",
|
||||||
"//pkg/scheduler/framework/plugins/imagelocality:go_default_library",
|
"//pkg/scheduler/framework/plugins/imagelocality:go_default_library",
|
||||||
|
@ -26,7 +26,6 @@ import (
|
|||||||
"k8s.io/klog"
|
"k8s.io/klog"
|
||||||
"k8s.io/kubernetes/pkg/features"
|
"k8s.io/kubernetes/pkg/features"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/algorithm/predicates"
|
"k8s.io/kubernetes/pkg/scheduler/algorithm/predicates"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/algorithm/priorities"
|
|
||||||
"k8s.io/kubernetes/pkg/scheduler/apis/config"
|
"k8s.io/kubernetes/pkg/scheduler/apis/config"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/defaultpodtopologyspread"
|
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/defaultpodtopologyspread"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/imagelocality"
|
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/imagelocality"
|
||||||
@ -47,6 +46,46 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/volumezone"
|
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/volumezone"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// EqualPriority defines the name of prioritizer function that gives an equal weight of one to all nodes.
|
||||||
|
EqualPriority = "EqualPriority"
|
||||||
|
// MostRequestedPriority defines the name of prioritizer function that gives used nodes higher priority.
|
||||||
|
MostRequestedPriority = "MostRequestedPriority"
|
||||||
|
// RequestedToCapacityRatioPriority defines the name of RequestedToCapacityRatioPriority.
|
||||||
|
RequestedToCapacityRatioPriority = "RequestedToCapacityRatioPriority"
|
||||||
|
// SelectorSpreadPriority defines the name of prioritizer function that spreads pods by minimizing
|
||||||
|
// the number of pods (belonging to the same service or replication controller) on the same node.
|
||||||
|
SelectorSpreadPriority = "SelectorSpreadPriority"
|
||||||
|
// ServiceSpreadingPriority is largely replaced by "SelectorSpreadPriority".
|
||||||
|
ServiceSpreadingPriority = "ServiceSpreadingPriority"
|
||||||
|
// InterPodAffinityPriority defines the name of prioritizer function that decides which pods should or
|
||||||
|
// should not be placed in the same topological domain as some other pods.
|
||||||
|
InterPodAffinityPriority = "InterPodAffinityPriority"
|
||||||
|
// LeastRequestedPriority defines the name of prioritizer function that prioritize nodes by least
|
||||||
|
// requested utilization.
|
||||||
|
LeastRequestedPriority = "LeastRequestedPriority"
|
||||||
|
// BalancedResourceAllocation defines the name of prioritizer function that prioritizes nodes
|
||||||
|
// to help achieve balanced resource usage.
|
||||||
|
BalancedResourceAllocation = "BalancedResourceAllocation"
|
||||||
|
// NodePreferAvoidPodsPriority defines the name of prioritizer function that priorities nodes according to
|
||||||
|
// the node annotation "scheduler.alpha.kubernetes.io/preferAvoidPods".
|
||||||
|
NodePreferAvoidPodsPriority = "NodePreferAvoidPodsPriority"
|
||||||
|
// NodeAffinityPriority defines the name of prioritizer function that prioritizes nodes which have labels
|
||||||
|
// matching NodeAffinity.
|
||||||
|
NodeAffinityPriority = "NodeAffinityPriority"
|
||||||
|
// TaintTolerationPriority defines the name of prioritizer function that prioritizes nodes that marked
|
||||||
|
// with taint which pod can tolerate.
|
||||||
|
TaintTolerationPriority = "TaintTolerationPriority"
|
||||||
|
// ImageLocalityPriority defines the name of prioritizer function that prioritizes nodes that have images
|
||||||
|
// requested by the pod present.
|
||||||
|
ImageLocalityPriority = "ImageLocalityPriority"
|
||||||
|
// ResourceLimitsPriority defines the nodes of prioritizer function ResourceLimitsPriority.
|
||||||
|
ResourceLimitsPriority = "ResourceLimitsPriority"
|
||||||
|
// EvenPodsSpreadPriority defines the name of prioritizer function that prioritizes nodes
|
||||||
|
// which have pods and labels matching the incoming pod's topologySpreadConstraints.
|
||||||
|
EvenPodsSpreadPriority = "EvenPodsSpreadPriority"
|
||||||
|
)
|
||||||
|
|
||||||
// LegacyRegistry is used to store current state of registered predicates and priorities.
|
// LegacyRegistry is used to store current state of registered predicates and priorities.
|
||||||
type LegacyRegistry struct {
|
type LegacyRegistry struct {
|
||||||
// maps that associate predicates/priorities with framework plugin configurations.
|
// maps that associate predicates/priorities with framework plugin configurations.
|
||||||
@ -109,14 +148,14 @@ func NewLegacyRegistry() *LegacyRegistry {
|
|||||||
|
|
||||||
// Used as the default set of predicates if Policy was specified, but priorities was nil.
|
// Used as the default set of predicates if Policy was specified, but priorities was nil.
|
||||||
DefaultPriorities: map[string]int64{
|
DefaultPriorities: map[string]int64{
|
||||||
priorities.SelectorSpreadPriority: 1,
|
SelectorSpreadPriority: 1,
|
||||||
priorities.InterPodAffinityPriority: 1,
|
InterPodAffinityPriority: 1,
|
||||||
priorities.LeastRequestedPriority: 1,
|
LeastRequestedPriority: 1,
|
||||||
priorities.BalancedResourceAllocation: 1,
|
BalancedResourceAllocation: 1,
|
||||||
priorities.NodePreferAvoidPodsPriority: 10000,
|
NodePreferAvoidPodsPriority: 10000,
|
||||||
priorities.NodeAffinityPriority: 1,
|
NodeAffinityPriority: 1,
|
||||||
priorities.TaintTolerationPriority: 1,
|
TaintTolerationPriority: 1,
|
||||||
priorities.ImageLocalityPriority: 1,
|
ImageLocalityPriority: 1,
|
||||||
},
|
},
|
||||||
|
|
||||||
PredicateToConfigProducer: make(map[string]ConfigProducer),
|
PredicateToConfigProducer: make(map[string]ConfigProducer),
|
||||||
@ -229,51 +268,51 @@ func NewLegacyRegistry() *LegacyRegistry {
|
|||||||
})
|
})
|
||||||
|
|
||||||
// Register Priorities.
|
// Register Priorities.
|
||||||
registry.registerPriorityConfigProducer(priorities.SelectorSpreadPriority,
|
registry.registerPriorityConfigProducer(SelectorSpreadPriority,
|
||||||
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
||||||
plugins.Score = appendToPluginSet(plugins.Score, defaultpodtopologyspread.Name, &args.Weight)
|
plugins.Score = appendToPluginSet(plugins.Score, defaultpodtopologyspread.Name, &args.Weight)
|
||||||
plugins.PostFilter = appendToPluginSet(plugins.PostFilter, defaultpodtopologyspread.Name, nil)
|
plugins.PostFilter = appendToPluginSet(plugins.PostFilter, defaultpodtopologyspread.Name, nil)
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
registry.registerPriorityConfigProducer(priorities.TaintTolerationPriority,
|
registry.registerPriorityConfigProducer(TaintTolerationPriority,
|
||||||
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
||||||
plugins.PostFilter = appendToPluginSet(plugins.PostFilter, tainttoleration.Name, nil)
|
plugins.PostFilter = appendToPluginSet(plugins.PostFilter, tainttoleration.Name, nil)
|
||||||
plugins.Score = appendToPluginSet(plugins.Score, tainttoleration.Name, &args.Weight)
|
plugins.Score = appendToPluginSet(plugins.Score, tainttoleration.Name, &args.Weight)
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
registry.registerPriorityConfigProducer(priorities.NodeAffinityPriority,
|
registry.registerPriorityConfigProducer(NodeAffinityPriority,
|
||||||
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
||||||
plugins.Score = appendToPluginSet(plugins.Score, nodeaffinity.Name, &args.Weight)
|
plugins.Score = appendToPluginSet(plugins.Score, nodeaffinity.Name, &args.Weight)
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
registry.registerPriorityConfigProducer(priorities.ImageLocalityPriority,
|
registry.registerPriorityConfigProducer(ImageLocalityPriority,
|
||||||
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
||||||
plugins.Score = appendToPluginSet(plugins.Score, imagelocality.Name, &args.Weight)
|
plugins.Score = appendToPluginSet(plugins.Score, imagelocality.Name, &args.Weight)
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
registry.registerPriorityConfigProducer(priorities.InterPodAffinityPriority,
|
registry.registerPriorityConfigProducer(InterPodAffinityPriority,
|
||||||
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
||||||
plugins.PostFilter = appendToPluginSet(plugins.PostFilter, interpodaffinity.Name, nil)
|
plugins.PostFilter = appendToPluginSet(plugins.PostFilter, interpodaffinity.Name, nil)
|
||||||
plugins.Score = appendToPluginSet(plugins.Score, interpodaffinity.Name, &args.Weight)
|
plugins.Score = appendToPluginSet(plugins.Score, interpodaffinity.Name, &args.Weight)
|
||||||
pluginConfig = append(pluginConfig, makePluginConfig(interpodaffinity.Name, args.InterPodAffinityArgs))
|
pluginConfig = append(pluginConfig, makePluginConfig(interpodaffinity.Name, args.InterPodAffinityArgs))
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
registry.registerPriorityConfigProducer(priorities.NodePreferAvoidPodsPriority,
|
registry.registerPriorityConfigProducer(NodePreferAvoidPodsPriority,
|
||||||
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
||||||
plugins.Score = appendToPluginSet(plugins.Score, nodepreferavoidpods.Name, &args.Weight)
|
plugins.Score = appendToPluginSet(plugins.Score, nodepreferavoidpods.Name, &args.Weight)
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
registry.registerPriorityConfigProducer(priorities.MostRequestedPriority,
|
registry.registerPriorityConfigProducer(MostRequestedPriority,
|
||||||
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
||||||
plugins.Score = appendToPluginSet(plugins.Score, noderesources.MostAllocatedName, &args.Weight)
|
plugins.Score = appendToPluginSet(plugins.Score, noderesources.MostAllocatedName, &args.Weight)
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
registry.registerPriorityConfigProducer(priorities.BalancedResourceAllocation,
|
registry.registerPriorityConfigProducer(BalancedResourceAllocation,
|
||||||
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
||||||
plugins.Score = appendToPluginSet(plugins.Score, noderesources.BalancedAllocationName, &args.Weight)
|
plugins.Score = appendToPluginSet(plugins.Score, noderesources.BalancedAllocationName, &args.Weight)
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
registry.registerPriorityConfigProducer(priorities.LeastRequestedPriority,
|
registry.registerPriorityConfigProducer(LeastRequestedPriority,
|
||||||
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
||||||
plugins.Score = appendToPluginSet(plugins.Score, noderesources.LeastAllocatedName, &args.Weight)
|
plugins.Score = appendToPluginSet(plugins.Score, noderesources.LeastAllocatedName, &args.Weight)
|
||||||
return
|
return
|
||||||
@ -320,26 +359,26 @@ func NewLegacyRegistry() *LegacyRegistry {
|
|||||||
})
|
})
|
||||||
registry.DefaultPredicates.Insert(predicates.EvenPodsSpreadPred)
|
registry.DefaultPredicates.Insert(predicates.EvenPodsSpreadPred)
|
||||||
|
|
||||||
registry.registerPriorityConfigProducer(priorities.EvenPodsSpreadPriority,
|
registry.registerPriorityConfigProducer(EvenPodsSpreadPriority,
|
||||||
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
||||||
plugins.PostFilter = appendToPluginSet(plugins.PostFilter, podtopologyspread.Name, nil)
|
plugins.PostFilter = appendToPluginSet(plugins.PostFilter, podtopologyspread.Name, nil)
|
||||||
plugins.Score = appendToPluginSet(plugins.Score, podtopologyspread.Name, &args.Weight)
|
plugins.Score = appendToPluginSet(plugins.Score, podtopologyspread.Name, &args.Weight)
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
registry.DefaultPriorities[priorities.EvenPodsSpreadPriority] = 1
|
registry.DefaultPriorities[EvenPodsSpreadPriority] = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prioritizes nodes that satisfy pod's resource limits
|
// Prioritizes nodes that satisfy pod's resource limits
|
||||||
if utilfeature.DefaultFeatureGate.Enabled(features.ResourceLimitsPriorityFunction) {
|
if utilfeature.DefaultFeatureGate.Enabled(features.ResourceLimitsPriorityFunction) {
|
||||||
klog.Infof("Registering resourcelimits priority function")
|
klog.Infof("Registering resourcelimits priority function")
|
||||||
|
|
||||||
registry.registerPriorityConfigProducer(priorities.ResourceLimitsPriority,
|
registry.registerPriorityConfigProducer(ResourceLimitsPriority,
|
||||||
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
func(args ConfigProducerArgs) (plugins config.Plugins, pluginConfig []config.PluginConfig) {
|
||||||
plugins.PostFilter = appendToPluginSet(plugins.PostFilter, noderesources.ResourceLimitsName, nil)
|
plugins.PostFilter = appendToPluginSet(plugins.PostFilter, noderesources.ResourceLimitsName, nil)
|
||||||
plugins.Score = appendToPluginSet(plugins.Score, noderesources.ResourceLimitsName, &args.Weight)
|
plugins.Score = appendToPluginSet(plugins.Score, noderesources.ResourceLimitsName, &args.Weight)
|
||||||
return
|
return
|
||||||
})
|
})
|
||||||
registry.DefaultPriorities[priorities.ResourceLimitsPriority] = 1
|
registry.DefaultPriorities[ResourceLimitsPriority] = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
return registry
|
return registry
|
||||||
@ -448,9 +487,9 @@ func (lr *LegacyRegistry) ProcessPriorityPolicy(policy config.PriorityPolicy, co
|
|||||||
validatePriorityOrDie(policy)
|
validatePriorityOrDie(policy)
|
||||||
|
|
||||||
priorityName := policy.Name
|
priorityName := policy.Name
|
||||||
if policy.Name == priorities.ServiceSpreadingPriority {
|
if policy.Name == ServiceSpreadingPriority {
|
||||||
// For compatibility reasons, "ServiceSpreadingPriority" as a key is still supported.
|
// For compatibility reasons, "ServiceSpreadingPriority" as a key is still supported.
|
||||||
priorityName = priorities.SelectorSpreadPriority
|
priorityName = SelectorSpreadPriority
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := lr.PriorityToConfigProducer[priorityName]; ok {
|
if _, ok := lr.PriorityToConfigProducer[priorityName]; ok {
|
||||||
|
@ -22,13 +22,10 @@ go_test(
|
|||||||
srcs = ["service_affinity_test.go"],
|
srcs = ["service_affinity_test.go"],
|
||||||
embed = [":go_default_library"],
|
embed = [":go_default_library"],
|
||||||
deps = [
|
deps = [
|
||||||
"//pkg/scheduler/algorithm/priorities:go_default_library",
|
|
||||||
"//pkg/scheduler/framework/plugins/migration:go_default_library",
|
|
||||||
"//pkg/scheduler/framework/v1alpha1:go_default_library",
|
"//pkg/scheduler/framework/v1alpha1:go_default_library",
|
||||||
"//pkg/scheduler/listers/fake:go_default_library",
|
"//pkg/scheduler/listers/fake:go_default_library",
|
||||||
"//pkg/scheduler/nodeinfo:go_default_library",
|
"//pkg/scheduler/nodeinfo:go_default_library",
|
||||||
"//pkg/scheduler/nodeinfo/snapshot:go_default_library",
|
"//pkg/scheduler/nodeinfo/snapshot:go_default_library",
|
||||||
"//staging/src/k8s.io/api/apps/v1:go_default_library",
|
|
||||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||||
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||||
],
|
],
|
||||||
|
@ -22,11 +22,8 @@ import (
|
|||||||
"sort"
|
"sort"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
apps "k8s.io/api/apps/v1"
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/algorithm/priorities"
|
|
||||||
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/migration"
|
|
||||||
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
|
framework "k8s.io/kubernetes/pkg/scheduler/framework/v1alpha1"
|
||||||
fakelisters "k8s.io/kubernetes/pkg/scheduler/listers/fake"
|
fakelisters "k8s.io/kubernetes/pkg/scheduler/listers/fake"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/nodeinfo"
|
"k8s.io/kubernetes/pkg/scheduler/nodeinfo"
|
||||||
@ -382,11 +379,6 @@ func TestServiceAffinityScore(t *testing.T) {
|
|||||||
name: "three pods, two service pods, with rack label",
|
name: "three pods, two service pods, with rack label",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
// these local variables just make sure controllerLister\replicaSetLister\statefulSetLister not nil
|
|
||||||
// when construct metaDataProducer
|
|
||||||
sss := []*apps.StatefulSet{{Spec: apps.StatefulSetSpec{Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}}}}}
|
|
||||||
rcs := []*v1.ReplicationController{{Spec: v1.ReplicationControllerSpec{Selector: map[string]string{"foo": "bar"}}}}
|
|
||||||
rss := []*apps.ReplicaSet{{Spec: apps.ReplicaSetSpec{Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"foo": "bar"}}}}}
|
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
@ -401,14 +393,7 @@ func TestServiceAffinityScore(t *testing.T) {
|
|||||||
AntiAffinityLabelsPreference: test.labels,
|
AntiAffinityLabelsPreference: test.labels,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
metaDataProducer := priorities.NewMetadataFactory(
|
|
||||||
fakelisters.ServiceLister(test.services),
|
|
||||||
fakelisters.ControllerLister(rcs),
|
|
||||||
fakelisters.ReplicaSetLister(rss),
|
|
||||||
fakelisters.StatefulSetLister(sss))
|
|
||||||
metaData := metaDataProducer(test.pod, nodes, snapshot)
|
|
||||||
state := framework.NewCycleState()
|
state := framework.NewCycleState()
|
||||||
state.Write(migration.PrioritiesStateKey, &migration.PrioritiesStateData{Reference: metaData})
|
|
||||||
|
|
||||||
var gotList framework.NodeScoreList
|
var gotList framework.NodeScoreList
|
||||||
for _, n := range makeLabeledNodeList(test.nodes) {
|
for _, n := range makeLabeledNodeList(test.nodes) {
|
||||||
|
@ -45,7 +45,6 @@ import (
|
|||||||
volumescheduling "k8s.io/kubernetes/pkg/controller/volume/scheduling"
|
volumescheduling "k8s.io/kubernetes/pkg/controller/volume/scheduling"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/algorithm"
|
"k8s.io/kubernetes/pkg/scheduler/algorithm"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/algorithm/predicates"
|
"k8s.io/kubernetes/pkg/scheduler/algorithm/predicates"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/algorithm/priorities"
|
|
||||||
schedulerapi "k8s.io/kubernetes/pkg/scheduler/apis/config"
|
schedulerapi "k8s.io/kubernetes/pkg/scheduler/apis/config"
|
||||||
"k8s.io/kubernetes/pkg/scheduler/core"
|
"k8s.io/kubernetes/pkg/scheduler/core"
|
||||||
frameworkplugins "k8s.io/kubernetes/pkg/scheduler/framework/plugins"
|
frameworkplugins "k8s.io/kubernetes/pkg/scheduler/framework/plugins"
|
||||||
@ -674,7 +673,6 @@ func setupTestScheduler(queuedPodStore *clientcache.FIFO, scache internalcache.C
|
|||||||
algo := core.NewGenericScheduler(
|
algo := core.NewGenericScheduler(
|
||||||
scache,
|
scache,
|
||||||
internalqueue.NewSchedulingQueue(nil),
|
internalqueue.NewSchedulingQueue(nil),
|
||||||
priorities.EmptyMetadataProducer,
|
|
||||||
nodeinfosnapshot.NewEmptySnapshot(),
|
nodeinfosnapshot.NewEmptySnapshot(),
|
||||||
fwk,
|
fwk,
|
||||||
[]algorithm.SchedulerExtender{},
|
[]algorithm.SchedulerExtender{},
|
||||||
@ -729,7 +727,6 @@ func setupTestSchedulerLongBindingWithRetry(queuedPodStore *clientcache.FIFO, sc
|
|||||||
algo := core.NewGenericScheduler(
|
algo := core.NewGenericScheduler(
|
||||||
scache,
|
scache,
|
||||||
queue,
|
queue,
|
||||||
priorities.EmptyMetadataProducer,
|
|
||||||
nodeinfosnapshot.NewEmptySnapshot(),
|
nodeinfosnapshot.NewEmptySnapshot(),
|
||||||
fwk,
|
fwk,
|
||||||
[]algorithm.SchedulerExtender{},
|
[]algorithm.SchedulerExtender{},
|
||||||
|
Loading…
Reference in New Issue
Block a user