mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Merge pull request #92892 from Huang-Wei/rm-DisablePreemption
Remove DisablePreemption field from KubeSchedulerConfiguration
This commit is contained in:
commit
21953d15ea
@ -321,7 +321,6 @@ func Setup(ctx context.Context, opts *options.Options, outOfTreeRegistryOptions
|
||||
ctx.Done(),
|
||||
scheduler.WithProfiles(cc.ComponentConfig.Profiles...),
|
||||
scheduler.WithAlgorithmSource(cc.ComponentConfig.AlgorithmSource),
|
||||
scheduler.WithPreemptionDisabled(cc.ComponentConfig.DisablePreemption),
|
||||
scheduler.WithPercentageOfNodesToScore(cc.ComponentConfig.PercentageOfNodesToScore),
|
||||
scheduler.WithFrameworkOutOfTreeRegistry(outOfTreeRegistry),
|
||||
scheduler.WithPodMaxBackoffSeconds(cc.ComponentConfig.PodMaxBackoffSeconds),
|
||||
|
@ -475,7 +475,6 @@ clientConnection:
|
||||
contentType: ""
|
||||
kubeconfig: ""
|
||||
qps: 0
|
||||
disablePreemption: false
|
||||
enableContentionProfiling: false
|
||||
enableProfiling: false
|
||||
healthzBindAddress: ""
|
||||
|
@ -77,9 +77,6 @@ type KubeSchedulerConfiguration struct {
|
||||
// TODO: We might wanna make this a substruct like Debugging componentbaseconfig.DebuggingConfiguration
|
||||
componentbaseconfig.DebuggingConfiguration
|
||||
|
||||
// DisablePreemption disables the pod preemption feature.
|
||||
DisablePreemption bool
|
||||
|
||||
// PercentageOfNodesToScore is the percentage of all nodes that once found feasible
|
||||
// for running a pod, the scheduler stops its search for more feasible nodes in
|
||||
// the cluster. This helps improve scheduler's performance. Scheduler always tries to find
|
||||
|
@ -103,11 +103,6 @@ func SetDefaults_KubeSchedulerConfiguration(obj *v1beta1.KubeSchedulerConfigurat
|
||||
}
|
||||
}
|
||||
|
||||
if obj.DisablePreemption == nil {
|
||||
disablePreemption := false
|
||||
obj.DisablePreemption = &disablePreemption
|
||||
}
|
||||
|
||||
if obj.PercentageOfNodesToScore == nil {
|
||||
percentageOfNodesToScore := int32(config.DefaultPercentageOfNodesToScore)
|
||||
obj.PercentageOfNodesToScore = &percentageOfNodesToScore
|
||||
|
@ -65,7 +65,6 @@ func TestSchedulerDefaults(t *testing.T) {
|
||||
Burst: 100,
|
||||
ContentType: "application/vnd.kubernetes.protobuf",
|
||||
},
|
||||
DisablePreemption: pointer.BoolPtr(false),
|
||||
PercentageOfNodesToScore: pointer.Int32Ptr(0),
|
||||
PodInitialBackoffSeconds: pointer.Int64Ptr(1),
|
||||
PodMaxBackoffSeconds: pointer.Int64Ptr(10),
|
||||
@ -106,7 +105,6 @@ func TestSchedulerDefaults(t *testing.T) {
|
||||
Burst: 100,
|
||||
ContentType: "application/vnd.kubernetes.protobuf",
|
||||
},
|
||||
DisablePreemption: pointer.BoolPtr(false),
|
||||
PercentageOfNodesToScore: pointer.Int32Ptr(0),
|
||||
PodInitialBackoffSeconds: pointer.Int64Ptr(1),
|
||||
PodMaxBackoffSeconds: pointer.Int64Ptr(10),
|
||||
@ -162,7 +160,6 @@ func TestSchedulerDefaults(t *testing.T) {
|
||||
Burst: 100,
|
||||
ContentType: "application/vnd.kubernetes.protobuf",
|
||||
},
|
||||
DisablePreemption: pointer.BoolPtr(false),
|
||||
PercentageOfNodesToScore: pointer.Int32Ptr(0),
|
||||
PodInitialBackoffSeconds: pointer.Int64Ptr(1),
|
||||
PodMaxBackoffSeconds: pointer.Int64Ptr(10),
|
||||
@ -212,7 +209,6 @@ func TestSchedulerDefaults(t *testing.T) {
|
||||
Burst: 100,
|
||||
ContentType: "application/vnd.kubernetes.protobuf",
|
||||
},
|
||||
DisablePreemption: pointer.BoolPtr(false),
|
||||
PercentageOfNodesToScore: pointer.Int32Ptr(0),
|
||||
PodInitialBackoffSeconds: pointer.Int64Ptr(1),
|
||||
PodMaxBackoffSeconds: pointer.Int64Ptr(10),
|
||||
@ -248,7 +244,6 @@ func TestSchedulerDefaults(t *testing.T) {
|
||||
Burst: 100,
|
||||
ContentType: "application/vnd.kubernetes.protobuf",
|
||||
},
|
||||
DisablePreemption: pointer.BoolPtr(false),
|
||||
PercentageOfNodesToScore: pointer.Int32Ptr(0),
|
||||
PodInitialBackoffSeconds: pointer.Int64Ptr(1),
|
||||
PodMaxBackoffSeconds: pointer.Int64Ptr(10),
|
||||
|
@ -305,9 +305,6 @@ func autoConvert_v1beta1_KubeSchedulerConfiguration_To_config_KubeSchedulerConfi
|
||||
if err := v1alpha1.Convert_v1alpha1_DebuggingConfiguration_To_config_DebuggingConfiguration(&in.DebuggingConfiguration, &out.DebuggingConfiguration, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := metav1.Convert_Pointer_bool_To_bool(&in.DisablePreemption, &out.DisablePreemption, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := metav1.Convert_Pointer_int32_To_int32(&in.PercentageOfNodesToScore, &out.PercentageOfNodesToScore, s); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -349,9 +346,6 @@ func autoConvert_config_KubeSchedulerConfiguration_To_v1beta1_KubeSchedulerConfi
|
||||
if err := v1alpha1.Convert_config_DebuggingConfiguration_To_v1alpha1_DebuggingConfiguration(&in.DebuggingConfiguration, &out.DebuggingConfiguration, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := metav1.Convert_bool_To_Pointer_bool(&in.DisablePreemption, &out.DisablePreemption, s); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := metav1.Convert_int32_To_Pointer_int32(&in.PercentageOfNodesToScore, &out.PercentageOfNodesToScore, s); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -76,9 +76,6 @@ type Scheduler struct {
|
||||
// Close this to shut down the scheduler.
|
||||
StopEverything <-chan struct{}
|
||||
|
||||
// Disable pod preemption or not.
|
||||
DisablePreemption bool
|
||||
|
||||
// SchedulingQueue holds pods to be scheduled
|
||||
SchedulingQueue internalqueue.SchedulingQueue
|
||||
|
||||
@ -97,7 +94,6 @@ func (sched *Scheduler) Cache() internalcache.Cache {
|
||||
|
||||
type schedulerOptions struct {
|
||||
schedulerAlgorithmSource schedulerapi.SchedulerAlgorithmSource
|
||||
disablePreemption bool
|
||||
percentageOfNodesToScore int32
|
||||
podInitialBackoffSeconds int64
|
||||
podMaxBackoffSeconds int64
|
||||
@ -126,13 +122,6 @@ func WithAlgorithmSource(source schedulerapi.SchedulerAlgorithmSource) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// WithPreemptionDisabled sets disablePreemption for Scheduler, the default value is false
|
||||
func WithPreemptionDisabled(disablePreemption bool) Option {
|
||||
return func(o *schedulerOptions) {
|
||||
o.disablePreemption = disablePreemption
|
||||
}
|
||||
}
|
||||
|
||||
// WithPercentageOfNodesToScore sets percentageOfNodesToScore for Scheduler, the default value is 50
|
||||
func WithPercentageOfNodesToScore(percentageOfNodesToScore int32) Option {
|
||||
return func(o *schedulerOptions) {
|
||||
@ -187,7 +176,6 @@ var defaultSchedulerOptions = schedulerOptions{
|
||||
schedulerAlgorithmSource: schedulerapi.SchedulerAlgorithmSource{
|
||||
Provider: defaultAlgorithmSourceProviderName(),
|
||||
},
|
||||
disablePreemption: false,
|
||||
percentageOfNodesToScore: schedulerapi.DefaultPercentageOfNodesToScore,
|
||||
podInitialBackoffSeconds: int64(internalqueue.DefaultPodInitialBackoffDuration.Seconds()),
|
||||
podMaxBackoffSeconds: int64(internalqueue.DefaultPodMaxBackoffDuration.Seconds()),
|
||||
@ -227,7 +215,6 @@ func New(client clientset.Interface,
|
||||
podInformer: podInformer,
|
||||
schedulerCache: schedulerCache,
|
||||
StopEverything: stopEverything,
|
||||
disablePreemption: options.disablePreemption,
|
||||
percentageOfNodesToScore: options.percentageOfNodesToScore,
|
||||
podInitialBackoffSeconds: options.podInitialBackoffSeconds,
|
||||
podMaxBackoffSeconds: options.podMaxBackoffSeconds,
|
||||
@ -276,7 +263,6 @@ func New(client clientset.Interface,
|
||||
return nil, fmt.Errorf("unsupported algorithm source: %v", source)
|
||||
}
|
||||
// Additional tweaks to the config produced by the configurator.
|
||||
sched.DisablePreemption = options.disablePreemption
|
||||
sched.StopEverything = stopEverything
|
||||
sched.client = client
|
||||
sched.scheduledPodsHasSynced = podInformer.Informer().HasSynced
|
||||
@ -481,9 +467,8 @@ func (sched *Scheduler) scheduleOne(ctx context.Context) {
|
||||
// into the resources that were preempted, but this is harmless.
|
||||
nominatedNode := ""
|
||||
if fitError, ok := err.(*core.FitError); ok {
|
||||
if sched.DisablePreemption || !prof.HasPostFilterPlugins() {
|
||||
klog.V(3).Infof("Pod priority feature is not enabled or preemption is disabled by scheduler configuration." +
|
||||
" No preemption is performed.")
|
||||
if !prof.HasPostFilterPlugins() {
|
||||
klog.V(3).Infof("No PostFilter plugins are registered, so no preemption will be performed.")
|
||||
} else {
|
||||
// Run PostFilter plugins to try to make the pod schedulable in a future scheduling cycle.
|
||||
result, status := prof.RunPostFilterPlugins(ctx, state, pod, fitError.FilteredNodesStatuses)
|
||||
|
@ -61,9 +61,6 @@ type KubeSchedulerConfiguration struct {
|
||||
// TODO: We might wanna make this a substruct like Debugging componentbaseconfigv1alpha1.DebuggingConfiguration
|
||||
componentbaseconfigv1alpha1.DebuggingConfiguration `json:",inline"`
|
||||
|
||||
// DisablePreemption disables the pod preemption feature.
|
||||
DisablePreemption *bool `json:"disablePreemption,omitempty"`
|
||||
|
||||
// PercentageOfNodesToScore is the percentage of all nodes that once found feasible
|
||||
// for running a pod, the scheduler stops its search for more feasible nodes in
|
||||
// the cluster. This helps improve scheduler's performance. Scheduler always tries to find
|
||||
|
@ -100,11 +100,6 @@ func (in *KubeSchedulerConfiguration) DeepCopyInto(out *KubeSchedulerConfigurati
|
||||
**out = **in
|
||||
}
|
||||
in.DebuggingConfiguration.DeepCopyInto(&out.DebuggingConfiguration)
|
||||
if in.DisablePreemption != nil {
|
||||
in, out := &in.DisablePreemption, &out.DisablePreemption
|
||||
*out = new(bool)
|
||||
**out = **in
|
||||
}
|
||||
if in.PercentageOfNodesToScore != nil {
|
||||
in, out := &in.PercentageOfNodesToScore, &out.PercentageOfNodesToScore
|
||||
*out = new(int32)
|
||||
|
@ -85,6 +85,8 @@ go_library(
|
||||
"//pkg/api/v1/pod:go_default_library",
|
||||
"//pkg/controller/disruption:go_default_library",
|
||||
"//pkg/scheduler:go_default_library",
|
||||
"//pkg/scheduler/apis/config:go_default_library",
|
||||
"//pkg/scheduler/framework/plugins/defaultpreemption:go_default_library",
|
||||
"//pkg/scheduler/testing:go_default_library",
|
||||
"//staging/src/k8s.io/api/core/v1:go_default_library",
|
||||
"//staging/src/k8s.io/api/policy/v1beta1:go_default_library",
|
||||
|
@ -148,7 +148,7 @@ func TestPreemption(t *testing.T) {
|
||||
},
|
||||
}
|
||||
testCtx := testutils.InitTestSchedulerWithOptions(t,
|
||||
testutils.InitTestMaster(t, "preemptiom", nil),
|
||||
testutils.InitTestMaster(t, "preemption", nil),
|
||||
false, nil, time.Second,
|
||||
scheduler.WithProfiles(prof),
|
||||
scheduler.WithFrameworkOutOfTreeRegistry(registry))
|
||||
|
@ -39,6 +39,8 @@ import (
|
||||
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
|
||||
"k8s.io/kubernetes/pkg/controller/disruption"
|
||||
"k8s.io/kubernetes/pkg/scheduler"
|
||||
schedulerconfig "k8s.io/kubernetes/pkg/scheduler/apis/config"
|
||||
"k8s.io/kubernetes/pkg/scheduler/framework/plugins/defaultpreemption"
|
||||
st "k8s.io/kubernetes/pkg/scheduler/testing"
|
||||
testutils "k8s.io/kubernetes/test/integration/util"
|
||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||
@ -88,9 +90,19 @@ func initTest(t *testing.T, nsPrefix string, opts ...scheduler.Option) *testutil
|
||||
// initTestDisablePreemption initializes a test environment and creates master and scheduler with default
|
||||
// configuration but with pod preemption disabled.
|
||||
func initTestDisablePreemption(t *testing.T, nsPrefix string) *testutils.TestContext {
|
||||
prof := schedulerconfig.KubeSchedulerProfile{
|
||||
SchedulerName: v1.DefaultSchedulerName,
|
||||
Plugins: &schedulerconfig.Plugins{
|
||||
PostFilter: &schedulerconfig.PluginSet{
|
||||
Disabled: []schedulerconfig.Plugin{
|
||||
{Name: defaultpreemption.Name},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
testCtx := testutils.InitTestSchedulerWithOptions(
|
||||
t, testutils.InitTestMaster(t, nsPrefix, nil), true, nil,
|
||||
time.Second, scheduler.WithPreemptionDisabled(true))
|
||||
time.Second, scheduler.WithProfiles(prof))
|
||||
testutils.SyncInformerFactory(testCtx)
|
||||
go testCtx.Scheduler.Run(testCtx.Ctx)
|
||||
return testCtx
|
||||
|
Loading…
Reference in New Issue
Block a user