From 23eb93d1c4b82c5caa13ca1a81fb94c6529c2ec6 Mon Sep 17 00:00:00 2001 From: "xulinfei.xlf" Date: Thu, 29 Feb 2024 15:04:25 +0800 Subject: [PATCH] manager: add featuregate to remove the restrinction of parent quota submit pods when disable runtime Signed-off-by: xulinfei.xlf --- pkg/features/features.go | 4 ++++ pkg/features/scheduler_features.go | 1 + pkg/webhook/elasticquota/pod_check.go | 5 +++++ pkg/webhook/elasticquota/quota_topology_test.go | 9 +++++++-- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/pkg/features/features.go b/pkg/features/features.go index 948a39e66..b13bf8a27 100644 --- a/pkg/features/features.go +++ b/pkg/features/features.go @@ -64,6 +64,9 @@ const ( // DisableDefaultQuota disable default quota. DisableDefaultQuota featuregate.Feature = "DisableDefaultQuota" + + // SupportParentQuotaSubmitPod enables parent Quota submit pod + SupportParentQuotaSubmitPod featuregate.Feature = "SupportParentQuotaSubmitPod" ) var defaultFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{ @@ -80,6 +83,7 @@ var defaultFeatureGates = map[featuregate.Feature]featuregate.FeatureSpec{ ElasticQuotaIgnorePodOverhead: {Default: false, PreRelease: featuregate.Alpha}, ElasticQuotaGuaranteeUsage: {Default: false, PreRelease: featuregate.Alpha}, DisableDefaultQuota: {Default: false, PreRelease: featuregate.Alpha}, + SupportParentQuotaSubmitPod: {Default: false, PreRelease: featuregate.Alpha}, } const ( diff --git a/pkg/features/scheduler_features.go b/pkg/features/scheduler_features.go index b7ae8448a..40fe3c1ae 100644 --- a/pkg/features/scheduler_features.go +++ b/pkg/features/scheduler_features.go @@ -69,6 +69,7 @@ var defaultSchedulerFeatureGates = map[featuregate.Feature]featuregate.FeatureSp ElasticQuotaIgnorePodOverhead: {Default: false, PreRelease: featuregate.Alpha}, ElasticQuotaGuaranteeUsage: {Default: false, PreRelease: featuregate.Alpha}, DisableDefaultQuota: {Default: false, PreRelease: featuregate.Alpha}, + SupportParentQuotaSubmitPod: {Default: false, PreRelease: featuregate.Alpha}, } func init() { diff --git a/pkg/webhook/elasticquota/pod_check.go b/pkg/webhook/elasticquota/pod_check.go index 7c6362436..c88e6705e 100644 --- a/pkg/webhook/elasticquota/pod_check.go +++ b/pkg/webhook/elasticquota/pod_check.go @@ -41,6 +41,11 @@ func (qt *quotaTopology) ValidateAddPod(pod *corev1.Pod) error { qt.lock.Lock() defer qt.lock.Unlock() + featureGate := utilfeature.DefaultFeatureGate + if featureGate.Enabled(features.SupportParentQuotaSubmitPod) { + return nil + } + quotaName := qt.getQuotaNameFromPodNoLock(pod) if quotaName == "" || quotaName == extension.DefaultQuotaName { return nil diff --git a/pkg/webhook/elasticquota/quota_topology_test.go b/pkg/webhook/elasticquota/quota_topology_test.go index d231cce8d..ac6bd8576 100644 --- a/pkg/webhook/elasticquota/quota_topology_test.go +++ b/pkg/webhook/elasticquota/quota_topology_test.go @@ -32,9 +32,9 @@ import ( "sigs.k8s.io/scheduler-plugins/pkg/apis/scheduling/v1alpha1" "github.com/koordinator-sh/koordinator/apis/extension" - //"github.com/koordinator-sh/koordinator/pkg/features" + koordfeatures "github.com/koordinator-sh/koordinator/pkg/features" utilclient "github.com/koordinator-sh/koordinator/pkg/util/client" - //utilfeature "github.com/koordinator-sh/koordinator/pkg/util/feature" + utilfeature "github.com/koordinator-sh/koordinator/pkg/util/feature" ) func newFakeQuotaTopology() *quotaTopology { @@ -768,6 +768,11 @@ func TestQuotaTopology_AddPod_UpdatePod(t *testing.T) { err = qt.ValidateUpdatePod(pod2, oldPod2) assert.NotNil(t, err) + defer utilfeature.SetFeatureGateDuringTest(t, utilfeature.DefaultMutableFeatureGate, koordfeatures.SupportParentQuotaSubmitPod, true)() + + err = qt.ValidateUpdatePod(pod2, oldPod2) + assert.Nil(t, err) + pod2.Labels[extension.LabelQuotaName] = "default" err = qt.ValidateUpdatePod(oldPod2, pod2) assert.Nil(t, err)