Skip to content

Commit

Permalink
Update the "max reconciles" for each controller to 25 (#724)
Browse files Browse the repository at this point in the history
<!--Thanks for your contribution. See [CONTRIBUTING](CONTRIBUTING.md)
    for Pulumi's contribution guidelines.

    Help us merge your changes more quickly by adding more details such
    as labels, milestones, and reviewers.-->

### Proposed changes

<!--Give us a brief description of what you've done and what it solves.
-->

Use 25 by default to facilitate the blocking operations in the auto API,
and support the `MAX_CONCURRENT_RECONCILES` environment variable.

### Related issues (optional)

<!--Refer to related PRs or issues: #1234, or 'Fixes #1234' or 'Closes
#1234'.
Or link to full URLs to issues or pull requests in other GitHub
repositories. -->
  • Loading branch information
EronWright authored Oct 18, 2024
1 parent 3556a4d commit 542be71
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
10 changes: 10 additions & 0 deletions operator/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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"
Expand Down Expand Up @@ -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,
Expand Down
16 changes: 3 additions & 13 deletions operator/internal/controller/pulumi/stack_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"os"
"path"
"slices"
"strconv"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -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 (
Expand All @@ -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{
Expand Down

0 comments on commit 542be71

Please sign in to comment.