Skip to content

Commit

Permalink
manager: add featuregate to remove the restriction of parent quota su…
Browse files Browse the repository at this point in the history
…bmit pods (#1929)

Signed-off-by: xulinfei.xlf <xulinfei.xlf@alibaba-inc.com>
Co-authored-by: xulinfei.xlf <xulinfei.xlf@alibaba-inc.com>
  • Loading branch information
xulinfei1996 and xulinfei.xlf committed Mar 12, 2024
1 parent c64c01e commit 3bf7ba8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pkg/features/features.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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 (
Expand Down
1 change: 1 addition & 0 deletions pkg/features/scheduler_features.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
5 changes: 5 additions & 0 deletions pkg/webhook/elasticquota/pod_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions pkg/webhook/elasticquota/quota_topology_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3bf7ba8

Please sign in to comment.