Skip to content

Manual cherry pick of #4870 add feature gate to control cohort controller #4913

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

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
13 changes: 9 additions & 4 deletions pkg/controller/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
configapi "sigs.k8s.io/kueue/apis/config/v1beta1"
"sigs.k8s.io/kueue/pkg/cache"
"sigs.k8s.io/kueue/pkg/constants"
"sigs.k8s.io/kueue/pkg/features"
"sigs.k8s.io/kueue/pkg/queue"
)

Expand Down Expand Up @@ -52,9 +53,13 @@ func SetupControllers(mgr ctrl.Manager, qManager *queue.Manager, cc *cache.Cache
fairSharingEnabled = cfg.FairSharing.Enable
}

cohortRec := NewCohortReconciler(mgr.GetClient(), cc, qManager, CohortReconcilerWithFairSharing(fairSharingEnabled))
if err := cohortRec.SetupWithManager(mgr, cfg); err != nil {
return "Cohort", err
watchers := []ClusterQueueUpdateWatcher{rfRec, acRec}
if features.Enabled(features.HierarchialCohorts) {
cohortRec := NewCohortReconciler(mgr.GetClient(), cc, qManager, CohortReconcilerWithFairSharing(fairSharingEnabled))
if err := cohortRec.SetupWithManager(mgr, cfg); err != nil {
return "Cohort", err
}
watchers = append(watchers, cohortRec)
}

cqRec := NewClusterQueueReconciler(
Expand All @@ -65,7 +70,7 @@ func SetupControllers(mgr ctrl.Manager, qManager *queue.Manager, cc *cache.Cache
WithReportResourceMetrics(cfg.Metrics.EnableClusterQueueResources),
WithQueueVisibilityClusterQueuesMaxCount(queueVisibilityClusterQueuesMaxCount(cfg)),
WithFairSharing(fairSharingEnabled),
WithWatchers(rfRec, acRec, cohortRec),
WithWatchers(watchers...),
)
if err := mgr.Add(cqRec); err != nil {
return "Unable to add ClusterQueue to manager", err
Expand Down
9 changes: 9 additions & 0 deletions pkg/features/kube_features.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ const (
//
// Enable to set use LeastAlloactedFit algorithm for TAS
TASProfileMixed featuregate.Feature = "TASProfileMixed"

// owner: @kannon92
// kep: https://github.com/kubernetes-sigs/kueue/tree/main/keps/79-hierarchical-cohorts
//
// Enable hierarchical cohorts controller
HierarchialCohorts featuregate.Feature = "HierarchialCohorts"
)

func init() {
Expand Down Expand Up @@ -252,6 +258,9 @@ var defaultVersionedFeatureGates = map[featuregate.Feature]featuregate.Versioned
TASProfileMixed: {
{Version: version.MustParse("0.11"), Default: false, PreRelease: featuregate.Deprecated},
},
HierarchialCohorts: {
{Version: version.MustParse("0.11"), Default: true, PreRelease: featuregate.Beta},
},
}

func SetFeatureGateDuringTest(tb testing.TB, f featuregate.Feature, value bool) {
Expand Down