Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manager: add featuregate to remove the restriction of parent quota submit pods #1929

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading