From 4794b4690f33b1bbd9ce66eab457fd9c176e9c36 Mon Sep 17 00:00:00 2001 From: Joseph Date: Fri, 19 Jan 2024 15:26:02 +0800 Subject: [PATCH] scheduler: improve plugin args (#1857) Signed-off-by: Joseph --- pkg/scheduler/apis/config/types.go | 15 ++--- pkg/scheduler/apis/config/v1beta2/types.go | 3 +- .../config/v1beta2/zz_generated.conversion.go | 56 ++++++++++++++----- .../validation/validation_pluginargs.go | 8 +-- .../apis/config/zz_generated.deepcopy.go | 55 ++++-------------- .../coscheduling/controller/podgroup_test.go | 2 +- .../plugins/coscheduling/core/core_test.go | 2 +- .../plugins/coscheduling/core/gang.go | 7 +-- .../coscheduling/core/gang_cache_test.go | 6 +- .../plugins/coscheduling/plugin_controller.go | 2 +- pkg/scheduler/plugins/elasticquota/plugin.go | 2 +- .../plugins/elasticquota/plugin_test.go | 2 +- .../elasticquota/quota_overuse_revoke.go | 4 +- .../elasticquota/quota_overuse_revoke_test.go | 3 +- 14 files changed, 78 insertions(+), 89 deletions(-) diff --git a/pkg/scheduler/apis/config/types.go b/pkg/scheduler/apis/config/types.go index a90d17c64..2793d7949 100644 --- a/pkg/scheduler/apis/config/types.go +++ b/pkg/scheduler/apis/config/types.go @@ -157,7 +157,7 @@ type ReservationArgs struct { metav1.TypeMeta // EnablePreemption indicates whether to enable preemption for reservations. - EnablePreemption *bool + EnablePreemption bool } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -167,10 +167,10 @@ type ElasticQuotaArgs struct { metav1.TypeMeta // DelayEvictTime is the duration to handle the jitter of used and runtime - DelayEvictTime *metav1.Duration + DelayEvictTime metav1.Duration // RevokePodInterval is the interval to check quotaGroup's used and runtime - RevokePodInterval *metav1.Duration + RevokePodInterval metav1.Duration // DefaultQuotaGroupMax limit the maxQuota of DefaultQuotaGroup DefaultQuotaGroupMax corev1.ResourceList @@ -182,10 +182,10 @@ type ElasticQuotaArgs struct { QuotaGroupNamespace string // MonitorAllQuotas monitor the quotaGroups' used and runtime Quota to revoke pods - MonitorAllQuotas *bool + MonitorAllQuotas bool // EnableCheckParentQuota check parentQuotaGroups' used and runtime Quota in PreFilter - EnableCheckParentQuota *bool + EnableCheckParentQuota bool // EnableRuntimeQuota if true, use max instead of runtime for all checks. EnableRuntimeQuota bool @@ -199,10 +199,10 @@ type CoschedulingArgs struct { // DefaultTimeout is the default gang's waiting time in Permit stage // default is 600 seconds - DefaultTimeout *metav1.Duration + DefaultTimeout metav1.Duration // Workers number of controller // default is 1 - ControllerWorkers *int64 + ControllerWorkers int64 // Skip check schedule cycle // default is false SkipCheckScheduleCycle bool @@ -215,6 +215,7 @@ type DeviceShareArgs struct { metav1.TypeMeta // Allocator indicates the expected allocator to use + // Deprecated: Adapting to different allocators is no longer supported. Allocator string // ScoringStrategy selects the device resource scoring strategy. ScoringStrategy *ScoringStrategy diff --git a/pkg/scheduler/apis/config/v1beta2/types.go b/pkg/scheduler/apis/config/v1beta2/types.go index 50e3ba038..f529fb540 100644 --- a/pkg/scheduler/apis/config/v1beta2/types.go +++ b/pkg/scheduler/apis/config/v1beta2/types.go @@ -183,7 +183,7 @@ type ElasticQuotaArgs struct { EnableCheckParentQuota *bool `json:"enableCheckParentQuota,omitempty"` // EnableRuntimeQuota if false, use max instead of runtime for all checks. - EnableRuntimeQuota *bool + EnableRuntimeQuota *bool `json:"enableRuntimeQuota,omitempty"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -210,6 +210,7 @@ type DeviceShareArgs struct { metav1.TypeMeta // Allocator indicates the expected allocator to use + // Deprecated: Adapting to different allocators is no longer supported. Allocator string `json:"allocator,omitempty"` // ScoringStrategy selects the device resource scoring strategy. ScoringStrategy *ScoringStrategy `json:"scoringStrategy,omitempty"` diff --git a/pkg/scheduler/apis/config/v1beta2/zz_generated.conversion.go b/pkg/scheduler/apis/config/v1beta2/zz_generated.conversion.go index f1218cb66..e96fd50b5 100644 --- a/pkg/scheduler/apis/config/v1beta2/zz_generated.conversion.go +++ b/pkg/scheduler/apis/config/v1beta2/zz_generated.conversion.go @@ -125,8 +125,12 @@ func RegisterConversions(s *runtime.Scheme) error { } func autoConvert_v1beta2_CoschedulingArgs_To_config_CoschedulingArgs(in *CoschedulingArgs, out *config.CoschedulingArgs, s conversion.Scope) error { - out.DefaultTimeout = (*v1.Duration)(unsafe.Pointer(in.DefaultTimeout)) - out.ControllerWorkers = (*int64)(unsafe.Pointer(in.ControllerWorkers)) + if err := v1.Convert_Pointer_v1_Duration_To_v1_Duration(&in.DefaultTimeout, &out.DefaultTimeout, s); err != nil { + return err + } + if err := v1.Convert_Pointer_int64_To_int64(&in.ControllerWorkers, &out.ControllerWorkers, s); err != nil { + return err + } if err := v1.Convert_Pointer_bool_To_bool(&in.SkipCheckScheduleCycle, &out.SkipCheckScheduleCycle, s); err != nil { return err } @@ -139,8 +143,12 @@ func Convert_v1beta2_CoschedulingArgs_To_config_CoschedulingArgs(in *Coschedulin } func autoConvert_config_CoschedulingArgs_To_v1beta2_CoschedulingArgs(in *config.CoschedulingArgs, out *CoschedulingArgs, s conversion.Scope) error { - out.DefaultTimeout = (*v1.Duration)(unsafe.Pointer(in.DefaultTimeout)) - out.ControllerWorkers = (*int64)(unsafe.Pointer(in.ControllerWorkers)) + if err := v1.Convert_v1_Duration_To_Pointer_v1_Duration(&in.DefaultTimeout, &out.DefaultTimeout, s); err != nil { + return err + } + if err := v1.Convert_int64_To_Pointer_int64(&in.ControllerWorkers, &out.ControllerWorkers, s); err != nil { + return err + } if err := v1.Convert_bool_To_Pointer_bool(&in.SkipCheckScheduleCycle, &out.SkipCheckScheduleCycle, s); err != nil { return err } @@ -175,13 +183,21 @@ func Convert_config_DeviceShareArgs_To_v1beta2_DeviceShareArgs(in *config.Device } func autoConvert_v1beta2_ElasticQuotaArgs_To_config_ElasticQuotaArgs(in *ElasticQuotaArgs, out *config.ElasticQuotaArgs, s conversion.Scope) error { - out.DelayEvictTime = (*v1.Duration)(unsafe.Pointer(in.DelayEvictTime)) - out.RevokePodInterval = (*v1.Duration)(unsafe.Pointer(in.RevokePodInterval)) + if err := v1.Convert_Pointer_v1_Duration_To_v1_Duration(&in.DelayEvictTime, &out.DelayEvictTime, s); err != nil { + return err + } + if err := v1.Convert_Pointer_v1_Duration_To_v1_Duration(&in.RevokePodInterval, &out.RevokePodInterval, s); err != nil { + return err + } out.DefaultQuotaGroupMax = *(*corev1.ResourceList)(unsafe.Pointer(&in.DefaultQuotaGroupMax)) out.SystemQuotaGroupMax = *(*corev1.ResourceList)(unsafe.Pointer(&in.SystemQuotaGroupMax)) out.QuotaGroupNamespace = in.QuotaGroupNamespace - out.MonitorAllQuotas = (*bool)(unsafe.Pointer(in.MonitorAllQuotas)) - out.EnableCheckParentQuota = (*bool)(unsafe.Pointer(in.EnableCheckParentQuota)) + if err := v1.Convert_Pointer_bool_To_bool(&in.MonitorAllQuotas, &out.MonitorAllQuotas, s); err != nil { + return err + } + if err := v1.Convert_Pointer_bool_To_bool(&in.EnableCheckParentQuota, &out.EnableCheckParentQuota, s); err != nil { + return err + } if err := v1.Convert_Pointer_bool_To_bool(&in.EnableRuntimeQuota, &out.EnableRuntimeQuota, s); err != nil { return err } @@ -194,13 +210,21 @@ func Convert_v1beta2_ElasticQuotaArgs_To_config_ElasticQuotaArgs(in *ElasticQuot } func autoConvert_config_ElasticQuotaArgs_To_v1beta2_ElasticQuotaArgs(in *config.ElasticQuotaArgs, out *ElasticQuotaArgs, s conversion.Scope) error { - out.DelayEvictTime = (*v1.Duration)(unsafe.Pointer(in.DelayEvictTime)) - out.RevokePodInterval = (*v1.Duration)(unsafe.Pointer(in.RevokePodInterval)) + if err := v1.Convert_v1_Duration_To_Pointer_v1_Duration(&in.DelayEvictTime, &out.DelayEvictTime, s); err != nil { + return err + } + if err := v1.Convert_v1_Duration_To_Pointer_v1_Duration(&in.RevokePodInterval, &out.RevokePodInterval, s); err != nil { + return err + } out.DefaultQuotaGroupMax = *(*corev1.ResourceList)(unsafe.Pointer(&in.DefaultQuotaGroupMax)) out.SystemQuotaGroupMax = *(*corev1.ResourceList)(unsafe.Pointer(&in.SystemQuotaGroupMax)) out.QuotaGroupNamespace = in.QuotaGroupNamespace - out.MonitorAllQuotas = (*bool)(unsafe.Pointer(in.MonitorAllQuotas)) - out.EnableCheckParentQuota = (*bool)(unsafe.Pointer(in.EnableCheckParentQuota)) + if err := v1.Convert_bool_To_Pointer_bool(&in.MonitorAllQuotas, &out.MonitorAllQuotas, s); err != nil { + return err + } + if err := v1.Convert_bool_To_Pointer_bool(&in.EnableCheckParentQuota, &out.EnableCheckParentQuota, s); err != nil { + return err + } if err := v1.Convert_bool_To_Pointer_bool(&in.EnableRuntimeQuota, &out.EnableRuntimeQuota, s); err != nil { return err } @@ -328,7 +352,9 @@ func Convert_config_NodeNUMAResourceArgs_To_v1beta2_NodeNUMAResourceArgs(in *con } func autoConvert_v1beta2_ReservationArgs_To_config_ReservationArgs(in *ReservationArgs, out *config.ReservationArgs, s conversion.Scope) error { - out.EnablePreemption = (*bool)(unsafe.Pointer(in.EnablePreemption)) + if err := v1.Convert_Pointer_bool_To_bool(&in.EnablePreemption, &out.EnablePreemption, s); err != nil { + return err + } return nil } @@ -338,7 +364,9 @@ func Convert_v1beta2_ReservationArgs_To_config_ReservationArgs(in *ReservationAr } func autoConvert_config_ReservationArgs_To_v1beta2_ReservationArgs(in *config.ReservationArgs, out *ReservationArgs, s conversion.Scope) error { - out.EnablePreemption = (*bool)(unsafe.Pointer(in.EnablePreemption)) + if err := v1.Convert_bool_To_Pointer_bool(&in.EnablePreemption, &out.EnablePreemption, s); err != nil { + return err + } return nil } diff --git a/pkg/scheduler/apis/config/validation/validation_pluginargs.go b/pkg/scheduler/apis/config/validation/validation_pluginargs.go index 13f733246..30bc3284a 100644 --- a/pkg/scheduler/apis/config/validation/validation_pluginargs.go +++ b/pkg/scheduler/apis/config/validation/validation_pluginargs.go @@ -109,11 +109,11 @@ func ValidateElasticQuotaArgs(elasticArgs *config.ElasticQuotaArgs) error { } } - if elasticArgs.DelayEvictTime != nil && elasticArgs.DelayEvictTime.Duration < 0 { + if elasticArgs.DelayEvictTime.Duration < 0 { return fmt.Errorf("elasticQuotaArgs error, DelayEvictTime should be a positive value") } - if elasticArgs.RevokePodInterval != nil && elasticArgs.RevokePodInterval.Duration < 0 { + if elasticArgs.RevokePodInterval.Duration < 0 { return fmt.Errorf("elasticQuotaArgs error, RevokePodCycle should be a positive value") } @@ -121,10 +121,10 @@ func ValidateElasticQuotaArgs(elasticArgs *config.ElasticQuotaArgs) error { } func ValidateCoschedulingArgs(coeSchedulingArgs *config.CoschedulingArgs) error { - if coeSchedulingArgs.DefaultTimeout != nil && coeSchedulingArgs.DefaultTimeout.Duration < 0 { + if coeSchedulingArgs.DefaultTimeout.Duration < 0 { return fmt.Errorf("coeSchedulingArgs DefaultTimeoutSeconds invalid") } - if coeSchedulingArgs.ControllerWorkers != nil && *coeSchedulingArgs.ControllerWorkers < 1 { + if coeSchedulingArgs.ControllerWorkers < 1 { return fmt.Errorf("coeSchedulingArgs ControllerWorkers invalid") } return nil diff --git a/pkg/scheduler/apis/config/zz_generated.deepcopy.go b/pkg/scheduler/apis/config/zz_generated.deepcopy.go index b0cdf0303..d83136de2 100644 --- a/pkg/scheduler/apis/config/zz_generated.deepcopy.go +++ b/pkg/scheduler/apis/config/zz_generated.deepcopy.go @@ -22,8 +22,7 @@ limitations under the License. package config import ( - corev1 "k8s.io/api/core/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + v1 "k8s.io/api/core/v1" runtime "k8s.io/apimachinery/pkg/runtime" apisconfig "k8s.io/kubernetes/pkg/scheduler/apis/config" ) @@ -32,16 +31,7 @@ import ( func (in *CoschedulingArgs) DeepCopyInto(out *CoschedulingArgs) { *out = *in out.TypeMeta = in.TypeMeta - if in.DefaultTimeout != nil { - in, out := &in.DefaultTimeout, &out.DefaultTimeout - *out = new(v1.Duration) - **out = **in - } - if in.ControllerWorkers != nil { - in, out := &in.ControllerWorkers, &out.ControllerWorkers - *out = new(int64) - **out = **in - } + out.DefaultTimeout = in.DefaultTimeout return } @@ -97,40 +87,22 @@ func (in *DeviceShareArgs) DeepCopyObject() runtime.Object { func (in *ElasticQuotaArgs) DeepCopyInto(out *ElasticQuotaArgs) { *out = *in out.TypeMeta = in.TypeMeta - if in.DelayEvictTime != nil { - in, out := &in.DelayEvictTime, &out.DelayEvictTime - *out = new(v1.Duration) - **out = **in - } - if in.RevokePodInterval != nil { - in, out := &in.RevokePodInterval, &out.RevokePodInterval - *out = new(v1.Duration) - **out = **in - } + out.DelayEvictTime = in.DelayEvictTime + out.RevokePodInterval = in.RevokePodInterval if in.DefaultQuotaGroupMax != nil { in, out := &in.DefaultQuotaGroupMax, &out.DefaultQuotaGroupMax - *out = make(corev1.ResourceList, len(*in)) + *out = make(v1.ResourceList, len(*in)) for key, val := range *in { (*out)[key] = val.DeepCopy() } } if in.SystemQuotaGroupMax != nil { in, out := &in.SystemQuotaGroupMax, &out.SystemQuotaGroupMax - *out = make(corev1.ResourceList, len(*in)) + *out = make(v1.ResourceList, len(*in)) for key, val := range *in { (*out)[key] = val.DeepCopy() } } - if in.MonitorAllQuotas != nil { - in, out := &in.MonitorAllQuotas, &out.MonitorAllQuotas - *out = new(bool) - **out = **in - } - if in.EnableCheckParentQuota != nil { - in, out := &in.EnableCheckParentQuota, &out.EnableCheckParentQuota - *out = new(bool) - **out = **in - } return } @@ -157,7 +129,7 @@ func (in *LoadAwareSchedulingAggregatedArgs) DeepCopyInto(out *LoadAwareScheduli *out = *in if in.UsageThresholds != nil { in, out := &in.UsageThresholds, &out.UsageThresholds - *out = make(map[corev1.ResourceName]int64, len(*in)) + *out = make(map[v1.ResourceName]int64, len(*in)) for key, val := range *in { (*out)[key] = val } @@ -193,28 +165,28 @@ func (in *LoadAwareSchedulingArgs) DeepCopyInto(out *LoadAwareSchedulingArgs) { } if in.ResourceWeights != nil { in, out := &in.ResourceWeights, &out.ResourceWeights - *out = make(map[corev1.ResourceName]int64, len(*in)) + *out = make(map[v1.ResourceName]int64, len(*in)) for key, val := range *in { (*out)[key] = val } } if in.UsageThresholds != nil { in, out := &in.UsageThresholds, &out.UsageThresholds - *out = make(map[corev1.ResourceName]int64, len(*in)) + *out = make(map[v1.ResourceName]int64, len(*in)) for key, val := range *in { (*out)[key] = val } } if in.ProdUsageThresholds != nil { in, out := &in.ProdUsageThresholds, &out.ProdUsageThresholds - *out = make(map[corev1.ResourceName]int64, len(*in)) + *out = make(map[v1.ResourceName]int64, len(*in)) for key, val := range *in { (*out)[key] = val } } if in.EstimatedScalingFactors != nil { in, out := &in.EstimatedScalingFactors, &out.EstimatedScalingFactors - *out = make(map[corev1.ResourceName]int64, len(*in)) + *out = make(map[v1.ResourceName]int64, len(*in)) for key, val := range *in { (*out)[key] = val } @@ -284,11 +256,6 @@ func (in *NodeNUMAResourceArgs) DeepCopyObject() runtime.Object { func (in *ReservationArgs) DeepCopyInto(out *ReservationArgs) { *out = *in out.TypeMeta = in.TypeMeta - if in.EnablePreemption != nil { - in, out := &in.EnablePreemption, &out.EnablePreemption - *out = new(bool) - **out = **in - } return } diff --git a/pkg/scheduler/plugins/coscheduling/controller/podgroup_test.go b/pkg/scheduler/plugins/coscheduling/controller/podgroup_test.go index 1222b360d..0200d4909 100644 --- a/pkg/scheduler/plugins/coscheduling/controller/podgroup_test.go +++ b/pkg/scheduler/plugins/coscheduling/controller/podgroup_test.go @@ -282,7 +282,7 @@ func setUp(ctx context.Context, podNames []string, pgName string, podPhase v1.Po koordClient := koordfake.NewSimpleClientset() koordInformerFactory := koordinformers.NewSharedInformerFactory(koordClient, 0) - args := &config.CoschedulingArgs{DefaultTimeout: &metav1.Duration{Duration: time.Second}} + args := &config.CoschedulingArgs{DefaultTimeout: metav1.Duration{Duration: time.Second}} pgMgr := core.NewPodGroupManager(args, pgClient, pgInformerFactory, informerFactory, koordInformerFactory) ctrl := NewPodGroupController(pgInformer, podInformer, pgClient, pgMgr, 1) return ctrl, kubeClient, pgClient diff --git a/pkg/scheduler/plugins/coscheduling/core/core_test.go b/pkg/scheduler/plugins/coscheduling/core/core_test.go index 640311366..7978cb113 100644 --- a/pkg/scheduler/plugins/coscheduling/core/core_test.go +++ b/pkg/scheduler/plugins/coscheduling/core/core_test.go @@ -58,7 +58,7 @@ func NewManagerForTest() *Mgr { koordClient := koordfake.NewSimpleClientset() koordInformerFactory := koordinformers.NewSharedInformerFactory(koordClient, 0) - args := &config.CoschedulingArgs{DefaultTimeout: &metav1.Duration{Duration: 300 * time.Second}} + args := &config.CoschedulingArgs{DefaultTimeout: metav1.Duration{Duration: 300 * time.Second}} pgManager := NewPodGroupManager(args, pgClient, pgInformerFactory, informerFactory, koordInformerFactory) return &Mgr{ diff --git a/pkg/scheduler/plugins/coscheduling/core/gang.go b/pkg/scheduler/plugins/coscheduling/core/gang.go index d5fbd8c97..c4e535624 100644 --- a/pkg/scheduler/plugins/coscheduling/core/gang.go +++ b/pkg/scheduler/plugins/coscheduling/core/gang.go @@ -154,12 +154,7 @@ func (gang *Gang) tryInitByPodConfig(pod *v1.Pod, args *config.CoschedulingArgs) if err != nil || waitTime <= 0 { klog.Errorf("pod's annotation GangWaitTimeAnnotation illegal, gangName: %v, value: %v", gang.Name, pod.Annotations[extension.AnnotationGangWaitTime]) - if args.DefaultTimeout != nil { - waitTime = args.DefaultTimeout.Duration - } else { - klog.Errorf("gangArgs DefaultTimeoutSeconds is nil") - waitTime = 0 - } + waitTime = args.DefaultTimeout.Duration } gang.WaitTime = waitTime diff --git a/pkg/scheduler/plugins/coscheduling/core/gang_cache_test.go b/pkg/scheduler/plugins/coscheduling/core/gang_cache_test.go index 2ea689629..bd2326b1e 100644 --- a/pkg/scheduler/plugins/coscheduling/core/gang_cache_test.go +++ b/pkg/scheduler/plugins/coscheduling/core/gang_cache_test.go @@ -808,7 +808,7 @@ func TestGangCache_OnPodDelete(t *testing.T) { pgInformerFactory := pgformers.NewSharedInformerFactory(pgClient, 0) pgInformer := pgInformerFactory.Scheduling().V1alpha1().PodGroups() pglister := pgInformer.Lister() - gangCache := NewGangCache(&config.CoschedulingArgs{DefaultTimeout: &metav1.Duration{Duration: time.Second}}, nil, pglister, pgClient) + gangCache := NewGangCache(&config.CoschedulingArgs{DefaultTimeout: metav1.Duration{Duration: time.Second}}, nil, pglister, pgClient) for _, pg := range tt.podGroups { err := retry.OnError( retry.DefaultRetry, @@ -963,7 +963,7 @@ func TestGangCache_OnPodGroupAdd(t *testing.T) { }() timeNowFn = fakeTimeNowFn pgClient := fakepgclientset.NewSimpleClientset() - gangCache := NewGangCache(&config.CoschedulingArgs{DefaultTimeout: &metav1.Duration{Duration: time.Second}}, nil, nil, pgClient) + gangCache := NewGangCache(&config.CoschedulingArgs{DefaultTimeout: metav1.Duration{Duration: time.Second}}, nil, nil, pgClient) for _, pg := range tt.pgs { gangCache.onPodGroupAdd(pg) } @@ -1093,7 +1093,7 @@ func TestGangCache_onPodGroupUpdate(t *testing.T) { pgInformerFactory := pgformers.NewSharedInformerFactory(pgClient, 0) pgInformer := pgInformerFactory.Scheduling().V1alpha1().PodGroups() pglister := pgInformer.Lister() - cache := NewGangCache(&config.CoschedulingArgs{DefaultTimeout: &metav1.Duration{Duration: time.Second}}, nil, pglister, pgClient) + cache := NewGangCache(&config.CoschedulingArgs{DefaultTimeout: metav1.Duration{Duration: time.Second}}, nil, pglister, pgClient) // init gang podGroup := &v1alpha1.PodGroup{ diff --git a/pkg/scheduler/plugins/coscheduling/plugin_controller.go b/pkg/scheduler/plugins/coscheduling/plugin_controller.go index 74c658b3e..1a6f96465 100644 --- a/pkg/scheduler/plugins/coscheduling/plugin_controller.go +++ b/pkg/scheduler/plugins/coscheduling/plugin_controller.go @@ -33,7 +33,7 @@ func (cs *Coscheduling) NewControllers() ([]frameworkext.Controller, error) { if cs.args == nil { controllerWorkers = 1 } else { - controllerWorkers = int(*cs.args.ControllerWorkers) + controllerWorkers = int(cs.args.ControllerWorkers) } podGroupController := controller.NewPodGroupController(cs.pgInformer, podInformer, cs.pgClient, pgMgr, controllerWorkers) return []frameworkext.Controller{podGroupController}, nil diff --git a/pkg/scheduler/plugins/elasticquota/plugin.go b/pkg/scheduler/plugins/elasticquota/plugin.go index 5502debdb..3f4805361 100644 --- a/pkg/scheduler/plugins/elasticquota/plugin.go +++ b/pkg/scheduler/plugins/elasticquota/plugin.go @@ -248,7 +248,7 @@ func (g *Plugin) PreFilter(ctx context.Context, cycleState *framework.CycleState } } - if *g.pluginArgs.EnableCheckParentQuota { + if g.pluginArgs.EnableCheckParentQuota { return nil, g.checkQuotaRecursive(quotaName, []string{quotaName}, podRequest) } diff --git a/pkg/scheduler/plugins/elasticquota/plugin_test.go b/pkg/scheduler/plugins/elasticquota/plugin_test.go index 05e53b1d0..40ddb830b 100644 --- a/pkg/scheduler/plugins/elasticquota/plugin_test.go +++ b/pkg/scheduler/plugins/elasticquota/plugin_test.go @@ -748,7 +748,7 @@ func TestPlugin_PreFilter_CheckParent(t *testing.T) { p, err := suit.proxyNew(suit.elasticQuotaArgs, suit.Handle) assert.Nil(t, err) gp := p.(*Plugin) - gp.pluginArgs.EnableCheckParentQuota = pointer.Bool(true) + gp.pluginArgs.EnableCheckParentQuota = true gp.OnQuotaAdd(tt.parQuotaInfo) gp.OnQuotaAdd(tt.quotaInfo) qi := gp.groupQuotaManager.GetQuotaInfoByName(tt.quotaInfo.Name) diff --git a/pkg/scheduler/plugins/elasticquota/quota_overuse_revoke.go b/pkg/scheduler/plugins/elasticquota/quota_overuse_revoke.go index f644bf3e1..8c26601f3 100644 --- a/pkg/scheduler/plugins/elasticquota/quota_overuse_revoke.go +++ b/pkg/scheduler/plugins/elasticquota/quota_overuse_revoke.go @@ -163,9 +163,7 @@ func NewQuotaOverUsedRevokeController(plugin *Plugin) *QuotaOverUsedRevokeContro revokePodCycle: plugin.pluginArgs.RevokePodInterval.Duration, monitors: make(map[string]*QuotaOverUsedGroupMonitor), } - if plugin.pluginArgs.MonitorAllQuotas != nil { - controller.monitorAllQuotas = *plugin.pluginArgs.MonitorAllQuotas - } + controller.monitorAllQuotas = plugin.pluginArgs.MonitorAllQuotas controller.enableRuntimeQuota = plugin.pluginArgs.EnableRuntimeQuota return controller diff --git a/pkg/scheduler/plugins/elasticquota/quota_overuse_revoke_test.go b/pkg/scheduler/plugins/elasticquota/quota_overuse_revoke_test.go index eac0c52c9..c4d15264b 100644 --- a/pkg/scheduler/plugins/elasticquota/quota_overuse_revoke_test.go +++ b/pkg/scheduler/plugins/elasticquota/quota_overuse_revoke_test.go @@ -144,9 +144,8 @@ func TestQuotaOverUsedRevokeController_GetToMonitorQuotas(t *testing.T) { suit := newPluginTestSuit(t, nil) p, _ := suit.proxyNew(suit.elasticQuotaArgs, suit.Handle) plugin := p.(*Plugin) - monitorAllQuotas := true plugin.pluginArgs.DelayEvictTime.Duration = 0 * time.Second - plugin.pluginArgs.MonitorAllQuotas = &monitorAllQuotas + plugin.pluginArgs.MonitorAllQuotas = true gqm := plugin.groupQuotaManager gqm.UpdateClusterTotalResource(createResourceList(10850060000, 0))