Skip to content

Commit f0c14f2

Browse files
authored
Merge pull request kubernetes#87751 from skilxn-go/Rename
[Scheduler Framework] Rename `PostFilter` plugin to `PreScore`
2 parents a11a8b8 + f5b7e3c commit f0c14f2

37 files changed

+604
-310
lines changed

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

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,23 @@ plugins:
227227
- name: baz
228228
pluginConfig:
229229
- name: foo
230+
`, configKubeconfig)), os.FileMode(0600)); err != nil {
231+
t.Fatal(err)
232+
}
233+
// v1alpha1 postfilter plugin config
234+
postfilterPluginConfigFile := filepath.Join(tmpDir, "v1alpha1_postfilter_plugin.yaml")
235+
if err := ioutil.WriteFile(postfilterPluginConfigFile, []byte(fmt.Sprintf(`
236+
apiVersion: kubescheduler.config.k8s.io/v1alpha1
237+
kind: KubeSchedulerConfiguration
238+
clientConnection:
239+
kubeconfig: "%s"
240+
plugins:
241+
postFilter:
242+
enabled:
243+
- name: foo
244+
- name: bar
245+
disabled:
246+
- name: baz
230247
`, configKubeconfig)), os.FileMode(0600)); err != nil {
231248
t.Fatal(err)
232249
}
@@ -554,6 +571,62 @@ pluginConfig:
554571
},
555572
},
556573
},
574+
{
575+
name: "v1alpha1 postfilter plugin config",
576+
options: &Options{
577+
ConfigFile: postfilterPluginConfigFile,
578+
},
579+
expectedUsername: "config",
580+
expectedConfig: kubeschedulerconfig.KubeSchedulerConfiguration{
581+
SchedulerName: "default-scheduler",
582+
AlgorithmSource: kubeschedulerconfig.SchedulerAlgorithmSource{Provider: &defaultSource},
583+
HardPodAffinitySymmetricWeight: 1,
584+
HealthzBindAddress: "0.0.0.0:10251",
585+
MetricsBindAddress: "0.0.0.0:10251",
586+
DebuggingConfiguration: componentbaseconfig.DebuggingConfiguration{
587+
EnableProfiling: true,
588+
EnableContentionProfiling: true,
589+
},
590+
LeaderElection: kubeschedulerconfig.KubeSchedulerLeaderElectionConfiguration{
591+
LeaderElectionConfiguration: componentbaseconfig.LeaderElectionConfiguration{
592+
LeaderElect: true,
593+
LeaseDuration: metav1.Duration{Duration: 15 * time.Second},
594+
RenewDeadline: metav1.Duration{Duration: 10 * time.Second},
595+
RetryPeriod: metav1.Duration{Duration: 2 * time.Second},
596+
ResourceLock: "endpointsleases",
597+
ResourceNamespace: "kube-system",
598+
ResourceName: "kube-scheduler",
599+
},
600+
},
601+
ClientConnection: componentbaseconfig.ClientConnectionConfiguration{
602+
Kubeconfig: configKubeconfig,
603+
QPS: 50,
604+
Burst: 100,
605+
ContentType: "application/vnd.kubernetes.protobuf",
606+
},
607+
PercentageOfNodesToScore: defaultPercentageOfNodesToScore,
608+
BindTimeoutSeconds: defaultBindTimeoutSeconds,
609+
PodInitialBackoffSeconds: defaultPodInitialBackoffSeconds,
610+
PodMaxBackoffSeconds: defaultPodMaxBackoffSeconds,
611+
Plugins: &kubeschedulerconfig.Plugins{
612+
PreScore: &kubeschedulerconfig.PluginSet{
613+
Enabled: []kubeschedulerconfig.Plugin{
614+
{
615+
Name: "foo",
616+
},
617+
{
618+
Name: "bar",
619+
},
620+
},
621+
Disabled: []kubeschedulerconfig.Plugin{
622+
{
623+
Name: "baz",
624+
},
625+
},
626+
},
627+
},
628+
},
629+
},
557630
{
558631
name: "no config",
559632
options: &Options{},

pkg/scheduler/algorithmprovider/registry.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func getDefaultConfig() *schedulerapi.Plugins {
106106
{Name: interpodaffinity.Name},
107107
},
108108
},
109-
PostFilter: &schedulerapi.PluginSet{
109+
PreScore: &schedulerapi.PluginSet{
110110
Enabled: []schedulerapi.Plugin{
111111
{Name: interpodaffinity.Name},
112112
{Name: defaultpodtopologyspread.Name},
@@ -151,7 +151,7 @@ func applyFeatureGates(config *schedulerapi.Plugins) {
151151
f := schedulerapi.Plugin{Name: podtopologyspread.Name}
152152
config.PreFilter.Enabled = append(config.PreFilter.Enabled, f)
153153
config.Filter.Enabled = append(config.Filter.Enabled, f)
154-
config.PostFilter.Enabled = append(config.PostFilter.Enabled, f)
154+
config.PreScore.Enabled = append(config.PreScore.Enabled, f)
155155
s := schedulerapi.Plugin{Name: podtopologyspread.Name, Weight: 1}
156156
config.Score.Enabled = append(config.Score.Enabled, s)
157157
}
@@ -160,7 +160,7 @@ func applyFeatureGates(config *schedulerapi.Plugins) {
160160
if utilfeature.DefaultFeatureGate.Enabled(features.ResourceLimitsPriorityFunction) {
161161
klog.Infof("Registering resourcelimits priority function")
162162
s := schedulerapi.Plugin{Name: noderesources.ResourceLimitsName}
163-
config.PostFilter.Enabled = append(config.PostFilter.Enabled, s)
163+
config.PreScore.Enabled = append(config.PreScore.Enabled, s)
164164
s = schedulerapi.Plugin{Name: noderesources.ResourceLimitsName, Weight: 1}
165165
config.Score.Enabled = append(config.Score.Enabled, s)
166166
}

pkg/scheduler/algorithmprovider/registry_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func TestClusterAutoscalerProvider(t *testing.T) {
7676
{Name: interpodaffinity.Name},
7777
},
7878
},
79-
PostFilter: &schedulerapi.PluginSet{
79+
PreScore: &schedulerapi.PluginSet{
8080
Enabled: []schedulerapi.Plugin{
8181
{Name: interpodaffinity.Name},
8282
{Name: defaultpodtopologyspread.Name},
@@ -149,7 +149,7 @@ func TestApplyFeatureGates(t *testing.T) {
149149
{Name: interpodaffinity.Name},
150150
},
151151
},
152-
PostFilter: &schedulerapi.PluginSet{
152+
PreScore: &schedulerapi.PluginSet{
153153
Enabled: []schedulerapi.Plugin{
154154
{Name: interpodaffinity.Name},
155155
{Name: defaultpodtopologyspread.Name},
@@ -211,7 +211,7 @@ func TestApplyFeatureGates(t *testing.T) {
211211
{Name: podtopologyspread.Name},
212212
},
213213
},
214-
PostFilter: &schedulerapi.PluginSet{
214+
PreScore: &schedulerapi.PluginSet{
215215
Enabled: []schedulerapi.Plugin{
216216
{Name: interpodaffinity.Name},
217217
{Name: defaultpodtopologyspread.Name},

pkg/scheduler/apis/config/testing/compatibility_test.go

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
135135
{Name: "NodeLabel"},
136136
{Name: "ServiceAffinity"},
137137
},
138-
"PostFilterPlugin": {{Name: "DefaultPodTopologySpread"}},
138+
"PreScorePlugin": {{Name: "DefaultPodTopologySpread"}},
139139
"ScorePlugin": {
140140
{Name: "NodeResourcesLeastAllocated", Weight: 1},
141141
{Name: "NodeLabel", Weight: 4},
@@ -190,7 +190,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
190190
{Name: "NodeLabel"},
191191
{Name: "ServiceAffinity"},
192192
},
193-
"PostFilterPlugin": {{Name: "DefaultPodTopologySpread"}},
193+
"PreScorePlugin": {{Name: "DefaultPodTopologySpread"}},
194194
"ScorePlugin": {
195195
{Name: "NodeResourcesBalancedAllocation", Weight: 2},
196196
{Name: "NodeResourcesLeastAllocated", Weight: 2},
@@ -253,7 +253,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
253253
{Name: "AzureDiskLimits"},
254254
{Name: "VolumeZone"},
255255
},
256-
"PostFilterPlugin": {{Name: "DefaultPodTopologySpread"}},
256+
"PreScorePlugin": {{Name: "DefaultPodTopologySpread"}},
257257
"ScorePlugin": {
258258
{Name: "NodeResourcesBalancedAllocation", Weight: 2},
259259
{Name: "ImageLocality", Weight: 2},
@@ -323,7 +323,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
323323
{Name: "VolumeZone"},
324324
{Name: "InterPodAffinity"},
325325
},
326-
"PostFilterPlugin": {
326+
"PreScorePlugin": {
327327
{Name: "InterPodAffinity"},
328328
{Name: "DefaultPodTopologySpread"},
329329
{Name: "TaintToleration"},
@@ -399,7 +399,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
399399
{Name: "VolumeZone"},
400400
{Name: "InterPodAffinity"},
401401
},
402-
"PostFilterPlugin": {
402+
"PreScorePlugin": {
403403
{Name: "InterPodAffinity"},
404404
{Name: "DefaultPodTopologySpread"},
405405
{Name: "TaintToleration"},
@@ -486,7 +486,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
486486
{Name: "VolumeZone"},
487487
{Name: "InterPodAffinity"},
488488
},
489-
"PostFilterPlugin": {
489+
"PreScorePlugin": {
490490
{Name: "InterPodAffinity"},
491491
{Name: "DefaultPodTopologySpread"},
492492
{Name: "TaintToleration"},
@@ -584,7 +584,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
584584
{Name: "VolumeZone"},
585585
{Name: "InterPodAffinity"},
586586
},
587-
"PostFilterPlugin": {
587+
"PreScorePlugin": {
588588
{Name: "InterPodAffinity"},
589589
{Name: "DefaultPodTopologySpread"},
590590
{Name: "TaintToleration"},
@@ -684,7 +684,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
684684
{Name: "VolumeZone"},
685685
{Name: "InterPodAffinity"},
686686
},
687-
"PostFilterPlugin": {
687+
"PreScorePlugin": {
688688
{Name: "InterPodAffinity"},
689689
{Name: "DefaultPodTopologySpread"},
690690
{Name: "TaintToleration"},
@@ -787,7 +787,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
787787
{Name: "VolumeZone"},
788788
{Name: "InterPodAffinity"},
789789
},
790-
"PostFilterPlugin": {
790+
"PreScorePlugin": {
791791
{Name: "InterPodAffinity"},
792792
{Name: "DefaultPodTopologySpread"},
793793
{Name: "TaintToleration"},
@@ -902,7 +902,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
902902
{Name: "VolumeZone"},
903903
{Name: "InterPodAffinity"},
904904
},
905-
"PostFilterPlugin": {
905+
"PreScorePlugin": {
906906
{Name: "InterPodAffinity"},
907907
{Name: "DefaultPodTopologySpread"},
908908
{Name: "TaintToleration"},
@@ -1020,7 +1020,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
10201020
{Name: "VolumeZone"},
10211021
{Name: "InterPodAffinity"},
10221022
},
1023-
"PostFilterPlugin": {
1023+
"PreScorePlugin": {
10241024
{Name: "InterPodAffinity"},
10251025
{Name: "DefaultPodTopologySpread"},
10261026
{Name: "TaintToleration"},
@@ -1138,7 +1138,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
11381138
{Name: "VolumeZone"},
11391139
{Name: "InterPodAffinity"},
11401140
},
1141-
"PostFilterPlugin": {
1141+
"PreScorePlugin": {
11421142
{Name: "InterPodAffinity"},
11431143
{Name: "DefaultPodTopologySpread"},
11441144
{Name: "TaintToleration"},
@@ -1260,7 +1260,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
12601260
{Name: "VolumeZone"},
12611261
{Name: "InterPodAffinity"},
12621262
},
1263-
"PostFilterPlugin": {
1263+
"PreScorePlugin": {
12641264
{Name: "InterPodAffinity"},
12651265
{Name: "DefaultPodTopologySpread"},
12661266
{Name: "TaintToleration"},
@@ -1318,7 +1318,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
13181318
{Name: "TaintToleration"},
13191319
{Name: "PodTopologySpread"},
13201320
},
1321-
"PostFilterPlugin": {
1321+
"PreScorePlugin": {
13221322
{Name: "PodTopologySpread"},
13231323
},
13241324
"ScorePlugin": {
@@ -1342,7 +1342,7 @@ func TestCompatibility_v1_Scheduler(t *testing.T) {
13421342
},
13431343
wantPlugins: map[string][]config.Plugin{
13441344
"QueueSortPlugin": {{Name: "PrioritySort"}},
1345-
"PostFilterPlugin": {
1345+
"PreScorePlugin": {
13461346
{Name: "NodeResourceLimits"},
13471347
},
13481348
"FilterPlugin": {
@@ -1440,7 +1440,7 @@ func TestAlgorithmProviderCompatibility(t *testing.T) {
14401440
{Name: "VolumeZone"},
14411441
{Name: "InterPodAffinity"},
14421442
},
1443-
"PostFilterPlugin": {
1443+
"PreScorePlugin": {
14441444
{Name: "InterPodAffinity"},
14451445
{Name: "DefaultPodTopologySpread"},
14461446
{Name: "TaintToleration"},
@@ -1500,7 +1500,7 @@ func TestAlgorithmProviderCompatibility(t *testing.T) {
15001500
{Name: "VolumeZone"},
15011501
{Name: "InterPodAffinity"},
15021502
},
1503-
"PostFilterPlugin": {
1503+
"PreScorePlugin": {
15041504
{Name: "InterPodAffinity"},
15051505
{Name: "DefaultPodTopologySpread"},
15061506
{Name: "TaintToleration"},
@@ -1550,5 +1550,4 @@ func TestAlgorithmProviderCompatibility(t *testing.T) {
15501550
}
15511551
})
15521552
}
1553-
15541553
}

pkg/scheduler/apis/config/types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,8 @@ type Plugins struct {
168168
// Filter is a list of plugins that should be invoked when filtering out nodes that cannot run the Pod.
169169
Filter *PluginSet
170170

171-
// PostFilter is a list of plugins that are invoked after filtering out infeasible nodes.
172-
PostFilter *PluginSet
171+
// PreScore is a list of plugins that are invoked before scoring.
172+
PreScore *PluginSet
173173

174174
// Score is a list of plugins that should be invoked when ranking nodes that have passed the filtering phase.
175175
Score *PluginSet
@@ -262,7 +262,7 @@ func (p *Plugins) Append(src *Plugins) {
262262
p.QueueSort = appendPluginSet(p.QueueSort, src.QueueSort)
263263
p.PreFilter = appendPluginSet(p.PreFilter, src.PreFilter)
264264
p.Filter = appendPluginSet(p.Filter, src.Filter)
265-
p.PostFilter = appendPluginSet(p.PostFilter, src.PostFilter)
265+
p.PreScore = appendPluginSet(p.PreScore, src.PreScore)
266266
p.Score = appendPluginSet(p.Score, src.Score)
267267
p.Reserve = appendPluginSet(p.Reserve, src.Reserve)
268268
p.Permit = appendPluginSet(p.Permit, src.Permit)
@@ -281,7 +281,7 @@ func (p *Plugins) Apply(customPlugins *Plugins) {
281281
p.QueueSort = mergePluginSets(p.QueueSort, customPlugins.QueueSort)
282282
p.PreFilter = mergePluginSets(p.PreFilter, customPlugins.PreFilter)
283283
p.Filter = mergePluginSets(p.Filter, customPlugins.Filter)
284-
p.PostFilter = mergePluginSets(p.PostFilter, customPlugins.PostFilter)
284+
p.PreScore = mergePluginSets(p.PreScore, customPlugins.PreScore)
285285
p.Score = mergePluginSets(p.Score, customPlugins.Score)
286286
p.Reserve = mergePluginSets(p.Reserve, customPlugins.Reserve)
287287
p.Permit = mergePluginSets(p.Permit, customPlugins.Permit)

0 commit comments

Comments
 (0)