diff --git a/operator/cmd/main.go b/operator/cmd/main.go index 01a82a7d..d3870749 100644 --- a/operator/cmd/main.go +++ b/operator/cmd/main.go @@ -23,6 +23,7 @@ import ( "net" "net/http" "os" + "strconv" // Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.) // to ensure that exec-entrypoint and run can make use of them. @@ -34,6 +35,7 @@ import ( utilruntime "k8s.io/apimachinery/pkg/util/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/config" "sigs.k8s.io/controller-runtime/pkg/healthz" "sigs.k8s.io/controller-runtime/pkg/log/zap" "sigs.k8s.io/controller-runtime/pkg/metrics/filters" @@ -145,9 +147,17 @@ func main() { metricsServerOptions.FilterProvider = filters.WithAuthenticationAndAuthorization } + controllerOpts := config.Controller{ + MaxConcurrentReconciles: 25, + } + if s, ok := os.LookupEnv("MAX_CONCURRENT_RECONCILES"); ok { + controllerOpts.MaxConcurrentReconciles, _ = strconv.Atoi(s) + } + mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{ Scheme: scheme, Metrics: metricsServerOptions, + Controller: controllerOpts, WebhookServer: webhookServer, HealthProbeBindAddress: probeAddr, LeaderElection: enableLeaderElection, diff --git a/operator/internal/controller/pulumi/stack_controller.go b/operator/internal/controller/pulumi/stack_controller.go index 5ffa7f18..7b46418c 100644 --- a/operator/internal/controller/pulumi/stack_controller.go +++ b/operator/internal/controller/pulumi/stack_controller.go @@ -26,7 +26,6 @@ import ( "os" "path" "slices" - "strconv" "strings" "sync" "time" @@ -70,10 +69,9 @@ var ( ) const ( - pulumiFinalizer = "finalizer.stack.pulumi.com" - defaultMaxConcurrentReconciles = 10 - programRefIndexFieldName = ".spec.programRef.name" // this is an arbitrary string, named for the field it indexes - fluxSourceIndexFieldName = ".spec.fluxSource.sourceRef" // an arbitrary name, named for the field it indexes + pulumiFinalizer = "finalizer.stack.pulumi.com" + programRefIndexFieldName = ".spec.programRef.name" // this is an arbitrary string, named for the field it indexes + fluxSourceIndexFieldName = ".spec.fluxSource.sourceRef" // an arbitrary name, named for the field it indexes ) const ( @@ -89,14 +87,6 @@ func (r *StackReconciler) SetupWithManager(mgr ctrl.Manager) error { blder := ctrl.NewControllerManagedBy(mgr).Named("stack-controller") opts := controller.Options{} - opts.MaxConcurrentReconciles = defaultMaxConcurrentReconciles - if maxConcurrentReconcilesStr, ok := os.LookupEnv("MAX_CONCURRENT_RECONCILES"); ok { - opts.MaxConcurrentReconciles, err = strconv.Atoi(maxConcurrentReconcilesStr) - if err != nil { - return err - } - } - // Filter for update events where an object's metadata.generation is changed (no spec change!), // or the "force reconcile" annotation is used (and not marked as handled). predicates := []predicate.Predicate{