Skip to content

Commit

Permalink
Make max reconciles configurable (#213)
Browse files Browse the repository at this point in the history
* Make max reconciles configurable

* Changelog

* Add max concurrently environment variable to deployment template
  • Loading branch information
Vivek Lakshmanan authored Oct 7, 2021
1 parent 1c24f5d commit 774d29b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
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
2 changes: 2 additions & 0 deletions deploy/operator_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,6 @@ spec:
value: "pulumi-kubernetes-operator"
- name: GRACEFUL_SHUTDOWN_TIMEOUT_DURATION
value: 5m
- name: MAX_CONCURRENT_RECONCILES
- value: 10
terminationGracePeriodSeconds: 300 # Should be same or larger than GRACEFUL_SHUTDOWN_TIMEOUT_DURATION
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

0 comments on commit 774d29b

Please sign in to comment.