Skip to content

Commit b3c4c90

Browse files
authored
Merge pull request kubernetes#86673 from ahg-g/ahg1-provider
Define algorithm providers in terms of plugins
2 parents 30090d0 + b535ed3 commit b3c4c90

35 files changed

+1263
-1791
lines changed

cmd/kube-scheduler/app/options/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ go_library(
1515
"//pkg/client/leaderelectionconfig:go_default_library",
1616
"//pkg/master/ports:go_default_library",
1717
"//pkg/scheduler:go_default_library",
18+
"//pkg/scheduler/algorithmprovider:go_default_library",
1819
"//pkg/scheduler/apis/config:go_default_library",
1920
"//pkg/scheduler/apis/config/scheme:go_default_library",
2021
"//pkg/scheduler/apis/config/v1alpha1:go_default_library",

cmd/kube-scheduler/app/options/deprecated.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
"github.com/spf13/pflag"
2323

2424
"k8s.io/apimachinery/pkg/util/validation/field"
25-
"k8s.io/kubernetes/pkg/scheduler"
25+
"k8s.io/kubernetes/pkg/scheduler/algorithmprovider"
2626
kubeschedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
2727
)
2828

@@ -44,7 +44,7 @@ func (o *DeprecatedOptions) AddFlags(fs *pflag.FlagSet, cfg *kubeschedulerconfig
4444
return
4545
}
4646

47-
fs.StringVar(&o.AlgorithmProvider, "algorithm-provider", o.AlgorithmProvider, "DEPRECATED: the scheduling algorithm provider to use, one of: "+scheduler.ListAlgorithmProviders())
47+
fs.StringVar(&o.AlgorithmProvider, "algorithm-provider", o.AlgorithmProvider, "DEPRECATED: the scheduling algorithm provider to use, one of: "+algorithmprovider.ListAlgorithmProviders())
4848
fs.StringVar(&o.PolicyConfigFile, "policy-config-file", o.PolicyConfigFile, "DEPRECATED: file with scheduler policy configuration. This file is used if policy ConfigMap is not provided or --use-legacy-policy-config=true")
4949
usage := fmt.Sprintf("DEPRECATED: name of the ConfigMap object that contains scheduler's policy configuration. It must exist in the system namespace before scheduler initialization if --use-legacy-policy-config=false. The config must be provided as the value of an element in 'Data' map with the key='%v'", kubeschedulerconfig.SchedulerPolicyConfigMapKey)
5050
fs.StringVar(&o.PolicyConfigMapName, "policy-configmap", o.PolicyConfigMapName, usage)

pkg/scheduler/BUILD

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
33
go_library(
44
name = "go_default_library",
55
srcs = [
6-
"algorithm_factory.go",
76
"eventhandlers.go",
87
"factory.go",
98
"scheduler.go",
@@ -16,20 +15,18 @@ go_library(
1615
"//pkg/scheduler/algorithm:go_default_library",
1716
"//pkg/scheduler/algorithm/predicates:go_default_library",
1817
"//pkg/scheduler/algorithm/priorities:go_default_library",
18+
"//pkg/scheduler/algorithmprovider:go_default_library",
1919
"//pkg/scheduler/apis/config:go_default_library",
2020
"//pkg/scheduler/apis/config/scheme:go_default_library",
2121
"//pkg/scheduler/apis/config/validation:go_default_library",
2222
"//pkg/scheduler/core:go_default_library",
2323
"//pkg/scheduler/framework/plugins:go_default_library",
2424
"//pkg/scheduler/framework/plugins/interpodaffinity:go_default_library",
25-
"//pkg/scheduler/framework/plugins/nodelabel:go_default_library",
2625
"//pkg/scheduler/framework/plugins/noderesources:go_default_library",
27-
"//pkg/scheduler/framework/plugins/serviceaffinity:go_default_library",
2826
"//pkg/scheduler/framework/v1alpha1:go_default_library",
2927
"//pkg/scheduler/internal/cache:go_default_library",
3028
"//pkg/scheduler/internal/cache/debugger:go_default_library",
3129
"//pkg/scheduler/internal/queue:go_default_library",
32-
"//pkg/scheduler/listers:go_default_library",
3330
"//pkg/scheduler/metrics:go_default_library",
3431
"//pkg/scheduler/nodeinfo/snapshot:go_default_library",
3532
"//pkg/scheduler/volumebinder:go_default_library",
@@ -59,7 +56,6 @@ go_library(
5956
go_test(
6057
name = "go_default_test",
6158
srcs = [
62-
"algorithm_factory_test.go",
6359
"eventhandlers_test.go",
6460
"factory_test.go",
6561
"scheduler_test.go",
@@ -110,7 +106,6 @@ go_test(
110106
"//staging/src/k8s.io/client-go/testing:go_default_library",
111107
"//staging/src/k8s.io/client-go/tools/cache:go_default_library",
112108
"//staging/src/k8s.io/client-go/tools/events:go_default_library",
113-
"//vendor/github.com/stretchr/testify/assert:go_default_library",
114109
],
115110
)
116111

pkg/scheduler/algorithm/predicates/predicates.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -396,9 +396,3 @@ func podToleratesNodeTaints(pod *v1.Pod, nodeInfo *schedulernodeinfo.NodeInfo, f
396396
}
397397
return false, []PredicateFailureReason{ErrTaintsTolerationsNotMatch}, nil
398398
}
399-
400-
// EvenPodsSpreadPredicate is the legacy function using old path of metadata.
401-
// DEPRECATED
402-
func EvenPodsSpreadPredicate(pod *v1.Pod, meta Metadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool, []PredicateFailureReason, error) {
403-
return false, nil, fmt.Errorf("this function should never be called")
404-
}

pkg/scheduler/algorithm/priorities/metadata.go

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,10 @@ import (
2727

2828
// MetadataFactory is a factory to produce PriorityMetadata.
2929
type MetadataFactory struct {
30-
serviceLister corelisters.ServiceLister
31-
controllerLister corelisters.ReplicationControllerLister
32-
replicaSetLister appslisters.ReplicaSetLister
33-
statefulSetLister appslisters.StatefulSetLister
34-
hardPodAffinityWeight int32
30+
serviceLister corelisters.ServiceLister
31+
controllerLister corelisters.ReplicationControllerLister
32+
replicaSetLister appslisters.ReplicaSetLister
33+
statefulSetLister appslisters.StatefulSetLister
3534
}
3635

3736
// NewMetadataFactory creates a MetadataFactory.
@@ -40,14 +39,12 @@ func NewMetadataFactory(
4039
controllerLister corelisters.ReplicationControllerLister,
4140
replicaSetLister appslisters.ReplicaSetLister,
4241
statefulSetLister appslisters.StatefulSetLister,
43-
hardPodAffinityWeight int32,
4442
) MetadataProducer {
4543
factory := &MetadataFactory{
46-
serviceLister: serviceLister,
47-
controllerLister: controllerLister,
48-
replicaSetLister: replicaSetLister,
49-
statefulSetLister: statefulSetLister,
50-
hardPodAffinityWeight: hardPodAffinityWeight,
44+
serviceLister: serviceLister,
45+
controllerLister: controllerLister,
46+
replicaSetLister: replicaSetLister,
47+
statefulSetLister: statefulSetLister,
5148
}
5249
return factory.PriorityMetadata
5350
}

pkg/scheduler/algorithm/priorities/metadata_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ func TestPriorityMetadata(t *testing.T) {
155155
informerFactory.Core().V1().ReplicationControllers().Lister(),
156156
informerFactory.Apps().V1().ReplicaSets().Lister(),
157157
informerFactory.Apps().V1().StatefulSets().Lister(),
158-
1,
159158
)
160159
for _, test := range tests {
161160
t.Run(test.name, func(t *testing.T) {

pkg/scheduler/algorithm/priorities/selector_spreading_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,6 @@ func TestSelectorSpreadPriority(t *testing.T) {
352352
fakelisters.ControllerLister(test.rcs),
353353
fakelisters.ReplicaSetLister(test.rss),
354354
fakelisters.StatefulSetLister(test.sss),
355-
1,
356355
)
357356
metaData := metaDataProducer(test.pod, nodes, snapshot)
358357

@@ -590,7 +589,6 @@ func TestZoneSelectorSpreadPriority(t *testing.T) {
590589
fakelisters.ControllerLister(test.rcs),
591590
fakelisters.ReplicaSetLister(test.rss),
592591
fakelisters.StatefulSetLister(test.sss),
593-
1,
594592
)
595593
metaData := metaDataProducer(test.pod, nodes, snapshot)
596594
list, err := runMapReducePriority(selectorSpread.CalculateSpreadPriorityMap, selectorSpread.CalculateSpreadPriorityReduce, metaData, test.pod, snapshot, makeLabeledNodeList(labeledNodes))

0 commit comments

Comments
 (0)