Skip to content

Commit 4b26ef2

Browse files
committed
Remove DisablePreemption field from SchedulerConfig v1beta1
DisablePreemption field can be removed as it can be deduced from PostFilterPlugins.
1 parent bc60bda commit 4b26ef2

File tree

9 files changed

+16
-37
lines changed

9 files changed

+16
-37
lines changed

cmd/kube-scheduler/app/server.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ func Setup(ctx context.Context, opts *options.Options, outOfTreeRegistryOptions
321321
ctx.Done(),
322322
scheduler.WithProfiles(cc.ComponentConfig.Profiles...),
323323
scheduler.WithAlgorithmSource(cc.ComponentConfig.AlgorithmSource),
324-
scheduler.WithPreemptionDisabled(cc.ComponentConfig.DisablePreemption),
325324
scheduler.WithPercentageOfNodesToScore(cc.ComponentConfig.PercentageOfNodesToScore),
326325
scheduler.WithFrameworkOutOfTreeRegistry(outOfTreeRegistry),
327326
scheduler.WithPodMaxBackoffSeconds(cc.ComponentConfig.PodMaxBackoffSeconds),

pkg/scheduler/apis/config/scheme/scheme_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,6 @@ clientConnection:
475475
contentType: ""
476476
kubeconfig: ""
477477
qps: 0
478-
disablePreemption: false
479478
enableContentionProfiling: false
480479
enableProfiling: false
481480
healthzBindAddress: ""

pkg/scheduler/apis/config/types.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ type KubeSchedulerConfiguration struct {
7777
// TODO: We might wanna make this a substruct like Debugging componentbaseconfig.DebuggingConfiguration
7878
componentbaseconfig.DebuggingConfiguration
7979

80-
// DisablePreemption disables the pod preemption feature.
81-
DisablePreemption bool
82-
8380
// PercentageOfNodesToScore is the percentage of all nodes that once found feasible
8481
// for running a pod, the scheduler stops its search for more feasible nodes in
8582
// the cluster. This helps improve scheduler's performance. Scheduler always tries to find

pkg/scheduler/apis/config/v1beta1/defaults.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,6 @@ func SetDefaults_KubeSchedulerConfiguration(obj *v1beta1.KubeSchedulerConfigurat
103103
}
104104
}
105105

106-
if obj.DisablePreemption == nil {
107-
disablePreemption := false
108-
obj.DisablePreemption = &disablePreemption
109-
}
110-
111106
if obj.PercentageOfNodesToScore == nil {
112107
percentageOfNodesToScore := int32(config.DefaultPercentageOfNodesToScore)
113108
obj.PercentageOfNodesToScore = &percentageOfNodesToScore

pkg/scheduler/apis/config/v1beta1/defaults_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ func TestSchedulerDefaults(t *testing.T) {
6565
Burst: 100,
6666
ContentType: "application/vnd.kubernetes.protobuf",
6767
},
68-
DisablePreemption: pointer.BoolPtr(false),
6968
PercentageOfNodesToScore: pointer.Int32Ptr(0),
7069
PodInitialBackoffSeconds: pointer.Int64Ptr(1),
7170
PodMaxBackoffSeconds: pointer.Int64Ptr(10),
@@ -106,7 +105,6 @@ func TestSchedulerDefaults(t *testing.T) {
106105
Burst: 100,
107106
ContentType: "application/vnd.kubernetes.protobuf",
108107
},
109-
DisablePreemption: pointer.BoolPtr(false),
110108
PercentageOfNodesToScore: pointer.Int32Ptr(0),
111109
PodInitialBackoffSeconds: pointer.Int64Ptr(1),
112110
PodMaxBackoffSeconds: pointer.Int64Ptr(10),
@@ -162,7 +160,6 @@ func TestSchedulerDefaults(t *testing.T) {
162160
Burst: 100,
163161
ContentType: "application/vnd.kubernetes.protobuf",
164162
},
165-
DisablePreemption: pointer.BoolPtr(false),
166163
PercentageOfNodesToScore: pointer.Int32Ptr(0),
167164
PodInitialBackoffSeconds: pointer.Int64Ptr(1),
168165
PodMaxBackoffSeconds: pointer.Int64Ptr(10),
@@ -212,7 +209,6 @@ func TestSchedulerDefaults(t *testing.T) {
212209
Burst: 100,
213210
ContentType: "application/vnd.kubernetes.protobuf",
214211
},
215-
DisablePreemption: pointer.BoolPtr(false),
216212
PercentageOfNodesToScore: pointer.Int32Ptr(0),
217213
PodInitialBackoffSeconds: pointer.Int64Ptr(1),
218214
PodMaxBackoffSeconds: pointer.Int64Ptr(10),
@@ -248,7 +244,6 @@ func TestSchedulerDefaults(t *testing.T) {
248244
Burst: 100,
249245
ContentType: "application/vnd.kubernetes.protobuf",
250246
},
251-
DisablePreemption: pointer.BoolPtr(false),
252247
PercentageOfNodesToScore: pointer.Int32Ptr(0),
253248
PodInitialBackoffSeconds: pointer.Int64Ptr(1),
254249
PodMaxBackoffSeconds: pointer.Int64Ptr(10),

pkg/scheduler/scheduler.go

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,6 @@ type Scheduler struct {
7676
// Close this to shut down the scheduler.
7777
StopEverything <-chan struct{}
7878

79-
// Disable pod preemption or not.
80-
DisablePreemption bool
81-
8279
// SchedulingQueue holds pods to be scheduled
8380
SchedulingQueue internalqueue.SchedulingQueue
8481

@@ -97,7 +94,6 @@ func (sched *Scheduler) Cache() internalcache.Cache {
9794

9895
type schedulerOptions struct {
9996
schedulerAlgorithmSource schedulerapi.SchedulerAlgorithmSource
100-
disablePreemption bool
10197
percentageOfNodesToScore int32
10298
podInitialBackoffSeconds int64
10399
podMaxBackoffSeconds int64
@@ -126,13 +122,6 @@ func WithAlgorithmSource(source schedulerapi.SchedulerAlgorithmSource) Option {
126122
}
127123
}
128124

129-
// WithPreemptionDisabled sets disablePreemption for Scheduler, the default value is false
130-
func WithPreemptionDisabled(disablePreemption bool) Option {
131-
return func(o *schedulerOptions) {
132-
o.disablePreemption = disablePreemption
133-
}
134-
}
135-
136125
// WithPercentageOfNodesToScore sets percentageOfNodesToScore for Scheduler, the default value is 50
137126
func WithPercentageOfNodesToScore(percentageOfNodesToScore int32) Option {
138127
return func(o *schedulerOptions) {
@@ -187,7 +176,6 @@ var defaultSchedulerOptions = schedulerOptions{
187176
schedulerAlgorithmSource: schedulerapi.SchedulerAlgorithmSource{
188177
Provider: defaultAlgorithmSourceProviderName(),
189178
},
190-
disablePreemption: false,
191179
percentageOfNodesToScore: schedulerapi.DefaultPercentageOfNodesToScore,
192180
podInitialBackoffSeconds: int64(internalqueue.DefaultPodInitialBackoffDuration.Seconds()),
193181
podMaxBackoffSeconds: int64(internalqueue.DefaultPodMaxBackoffDuration.Seconds()),
@@ -227,7 +215,6 @@ func New(client clientset.Interface,
227215
podInformer: podInformer,
228216
schedulerCache: schedulerCache,
229217
StopEverything: stopEverything,
230-
disablePreemption: options.disablePreemption,
231218
percentageOfNodesToScore: options.percentageOfNodesToScore,
232219
podInitialBackoffSeconds: options.podInitialBackoffSeconds,
233220
podMaxBackoffSeconds: options.podMaxBackoffSeconds,
@@ -276,7 +263,6 @@ func New(client clientset.Interface,
276263
return nil, fmt.Errorf("unsupported algorithm source: %v", source)
277264
}
278265
// Additional tweaks to the config produced by the configurator.
279-
sched.DisablePreemption = options.disablePreemption
280266
sched.StopEverything = stopEverything
281267
sched.client = client
282268
sched.scheduledPodsHasSynced = podInformer.Informer().HasSynced
@@ -481,9 +467,8 @@ func (sched *Scheduler) scheduleOne(ctx context.Context) {
481467
// into the resources that were preempted, but this is harmless.
482468
nominatedNode := ""
483469
if fitError, ok := err.(*core.FitError); ok {
484-
if sched.DisablePreemption || !prof.HasPostFilterPlugins() {
485-
klog.V(3).Infof("Pod priority feature is not enabled or preemption is disabled by scheduler configuration." +
486-
" No preemption is performed.")
470+
if !prof.HasPostFilterPlugins() {
471+
klog.V(3).Infof("No PostFilter plugins are registered, so no preemption will be performed.")
487472
} else {
488473
// Run PostFilter plugins to try to make the pod schedulable in a future scheduling cycle.
489474
result, status := prof.RunPostFilterPlugins(ctx, state, pod, fitError.FilteredNodesStatuses)

staging/src/k8s.io/kube-scheduler/config/v1beta1/types.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ type KubeSchedulerConfiguration struct {
6161
// TODO: We might wanna make this a substruct like Debugging componentbaseconfigv1alpha1.DebuggingConfiguration
6262
componentbaseconfigv1alpha1.DebuggingConfiguration `json:",inline"`
6363

64-
// DisablePreemption disables the pod preemption feature.
65-
DisablePreemption *bool `json:"disablePreemption,omitempty"`
66-
6764
// PercentageOfNodesToScore is the percentage of all nodes that once found feasible
6865
// for running a pod, the scheduler stops its search for more feasible nodes in
6966
// the cluster. This helps improve scheduler's performance. Scheduler always tries to find

test/integration/scheduler/preemption_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func TestPreemption(t *testing.T) {
148148
},
149149
}
150150
testCtx := testutils.InitTestSchedulerWithOptions(t,
151-
testutils.InitTestMaster(t, "preemptiom", nil),
151+
testutils.InitTestMaster(t, "preemption", nil),
152152
false, nil, time.Second,
153153
scheduler.WithProfiles(prof),
154154
scheduler.WithFrameworkOutOfTreeRegistry(registry))

test/integration/scheduler/util.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ import (
3939
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
4040
"k8s.io/kubernetes/pkg/controller/disruption"
4141
"k8s.io/kubernetes/pkg/scheduler"
42+
schedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
43+
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/defaultpreemption"
4244
st "k8s.io/kubernetes/pkg/scheduler/testing"
4345
testutils "k8s.io/kubernetes/test/integration/util"
4446
imageutils "k8s.io/kubernetes/test/utils/image"
@@ -88,9 +90,19 @@ func initTest(t *testing.T, nsPrefix string, opts ...scheduler.Option) *testutil
8890
// initTestDisablePreemption initializes a test environment and creates master and scheduler with default
8991
// configuration but with pod preemption disabled.
9092
func initTestDisablePreemption(t *testing.T, nsPrefix string) *testutils.TestContext {
93+
prof := schedulerconfig.KubeSchedulerProfile{
94+
SchedulerName: v1.DefaultSchedulerName,
95+
Plugins: &schedulerconfig.Plugins{
96+
PostFilter: &schedulerconfig.PluginSet{
97+
Disabled: []schedulerconfig.Plugin{
98+
{Name: defaultpreemption.Name},
99+
},
100+
},
101+
},
102+
}
91103
testCtx := testutils.InitTestSchedulerWithOptions(
92104
t, testutils.InitTestMaster(t, nsPrefix, nil), true, nil,
93-
time.Second, scheduler.WithPreemptionDisabled(true))
105+
time.Second, scheduler.WithProfiles(prof))
94106
testutils.SyncInformerFactory(testCtx)
95107
go testCtx.Scheduler.Run(testCtx.Ctx)
96108
return testCtx

0 commit comments

Comments
 (0)