Skip to content

Commit

Permalink
[kueue] Setup provision admission check controller
Browse files Browse the repository at this point in the history
  • Loading branch information
trasc committed Oct 20, 2023
1 parent e64279d commit 2b9df93
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions cmd/kueue/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/util/validation/field"
utilfeature "k8s.io/apiserver/pkg/util/feature"
autoscaling "k8s.io/autoscaler/cluster-autoscaler/provisioningrequest/apis/autoscaling.x-k8s.io/v1beta1"
"k8s.io/client-go/discovery"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
Expand All @@ -48,10 +49,12 @@ import (
"sigs.k8s.io/kueue/pkg/cache"
"sigs.k8s.io/kueue/pkg/config"
"sigs.k8s.io/kueue/pkg/constants"
"sigs.k8s.io/kueue/pkg/controller/admissionchecks/provisioning"
"sigs.k8s.io/kueue/pkg/controller/core"
"sigs.k8s.io/kueue/pkg/controller/core/indexer"
"sigs.k8s.io/kueue/pkg/controller/jobframework"
"sigs.k8s.io/kueue/pkg/controller/jobs/noop"
"sigs.k8s.io/kueue/pkg/features"
"sigs.k8s.io/kueue/pkg/metrics"
"sigs.k8s.io/kueue/pkg/queue"
"sigs.k8s.io/kueue/pkg/scheduler"
Expand All @@ -78,6 +81,7 @@ func init() {

utilruntime.Must(kueue.AddToScheme(scheme))
utilruntime.Must(configapi.AddToScheme(scheme))
utilruntime.Must(autoscaling.AddToScheme(scheme))
// Add any additional framework integration types.
utilruntime.Must(
jobframework.ForEachIntegration(func(_ string, cb jobframework.IntegrationCallbacks) error {
Expand All @@ -87,6 +91,7 @@ func init() {
return nil
}),
)

// +kubebuilder:scaffold:scheme
}

Expand Down Expand Up @@ -185,6 +190,16 @@ func setupIndexes(ctx context.Context, mgr ctrl.Manager, cfg *configapi.Configur
return err
}

// setup provision admission check controller indexes
if features.Enabled(features.ProvisioningACC) {
if !provisioning.ServerSupportsProvisioningRequest(mgr) {
setupLog.Error(nil, "Provisioning Requests are not supported, skipped admission check controller setup")
} else if err := provisioning.SetupIndexer(ctx, mgr.GetFieldIndexer()); err != nil {
setupLog.Error(err, "Could not setup provisioning indexer")
os.Exit(1)
}
}

err = jobframework.ForEachIntegration(func(name string, cb jobframework.IntegrationCallbacks) error {
if isFrameworkEnabled(cfg, name) {
if err := cb.SetupIndexes(ctx, mgr.GetFieldIndexer()); err != nil {
Expand All @@ -207,6 +222,16 @@ func setupControllers(mgr ctrl.Manager, cCache *cache.Cache, queues *queue.Manag
setupLog.Error(err, "Unable to create controller", "controller", failedCtrl)
os.Exit(1)
}

// setup provision admission check controller
if features.Enabled(features.ProvisioningACC) && provisioning.ServerSupportsProvisioningRequest(mgr) {
// A info message is added in setupIndexes if autoscaling is not supported by the cluster
if err := provisioning.NewController(mgr.GetClient()).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "Could not setup provisioning controller")
os.Exit(1)
}
}

manageJobsWithoutQueueName := cfg.ManageJobsWithoutQueueName

if failedWebhook, err := webhooks.Setup(mgr); err != nil {
Expand Down

0 comments on commit 2b9df93

Please sign in to comment.