Skip to content

Commit 21953d1

Browse files
authored
Merge pull request kubernetes#92892 from Huang-Wei/rm-DisablePreemption
Remove DisablePreemption field from KubeSchedulerConfiguration
2 parents bc60bda + d65a978 commit 21953d1

File tree

12 files changed

+18
-48
lines changed

12 files changed

+18
-48
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/apis/config/v1beta1/zz_generated.conversion.go

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

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

Lines changed: 0 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/integration/scheduler/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ go_library(
8585
"//pkg/api/v1/pod:go_default_library",
8686
"//pkg/controller/disruption:go_default_library",
8787
"//pkg/scheduler:go_default_library",
88+
"//pkg/scheduler/apis/config:go_default_library",
89+
"//pkg/scheduler/framework/plugins/defaultpreemption:go_default_library",
8890
"//pkg/scheduler/testing:go_default_library",
8991
"//staging/src/k8s.io/api/core/v1:go_default_library",
9092
"//staging/src/k8s.io/api/policy/v1beta1:go_default_library",

0 commit comments

Comments
 (0)