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

Make max reconciles configurable #213

Merged
merged 3 commits into from
Oct 7, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CHANGELOG
=========

## HEAD (Unreleased)
(None)
- Make max reconciles configurable. Users can now set `MAX_CONCURRENT_RECONCILES` to limit concurrent reconciles (defaults to 10). [#213](https://github.com/pulumi/pulumi-kubernetes-operator/pull/213/)

## 0.0.21 (2021-10-04)
- Fix clean up logic on reconcile [#203](https://github.com/pulumi/pulumi-kubernetes-operator/pull/203)
Expand Down
15 changes: 13 additions & 2 deletions pkg/controller/stack/stack_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -53,8 +54,8 @@ var (
)

const (
pulumiFinalizer = "finalizer.stack.pulumi.com"
maxConcurrentReconciles = 10 // arbitrary value greater than default of 1
pulumiFinalizer = "finalizer.stack.pulumi.com"
defaultMaxConcurrentReconciles = 10
)

// Add creates a new Stack Controller and adds it to the Manager. The Manager will set fields on the Controller
Expand All @@ -76,6 +77,16 @@ func newReconciler(mgr manager.Manager) reconcile.Reconciler {

// add adds a new Controller to mgr with r as the reconcile.Reconciler
func add(mgr manager.Manager, r reconcile.Reconciler) error {
var err error
maxConcurrentReconciles := 10
maxConcurrentReconcilesStr, set := os.LookupEnv("MAX_CONCURRENT_RECONCILES")
if set {
maxConcurrentReconciles, err = strconv.Atoi(maxConcurrentReconcilesStr)
if err != nil {
return err
}
}

// Create a new controller
c, err := controller.New("stack-controller", mgr, controller.Options{
Reconciler: r,
Expand Down