Skip to content

Commit

Permalink
Create MAX_CONCURRENT_RECONCILES env var
Browse files Browse the repository at this point in the history
  • Loading branch information
pooknull committed Apr 20, 2023
1 parent 08bc3d8 commit d64e70d
Show file tree
Hide file tree
Showing 7 changed files with 1,216 additions and 1 deletion.
296 changes: 296 additions & 0 deletions config/crd/bases/pxc.percona.com_perconaxtradbclusters.yaml

Large diffs are not rendered by default.

298 changes: 298 additions & 0 deletions deploy/bundle.yaml

Large diffs are not rendered by default.

296 changes: 296 additions & 0 deletions deploy/crd.yaml

Large diffs are not rendered by default.

298 changes: 298 additions & 0 deletions deploy/cw-bundle.yaml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions deploy/cw-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ spec:
value: percona-xtradb-cluster-operator
- name: DISABLE_TELEMETRY
value: "false"
- name: MAX_CONCURRENT_RECONCILES
value: "20"
image: perconalab/percona-xtradb-cluster-operator:main
imagePullPolicy: Always
resources:
Expand Down
2 changes: 2 additions & 0 deletions deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ spec:
value: percona-xtradb-cluster-operator
- name: DISABLE_TELEMETRY
value: "false"
- name: MAX_CONCURRENT_RECONCILES
value: "20"
image: perconalab/percona-xtradb-cluster-operator:main
imagePullPolicy: Always
livenessProbe:
Expand Down
25 changes: 24 additions & 1 deletion pkg/controller/pxc/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import (
"context"
"encoding/base64"
"encoding/json"
"os"
"reflect"
"strconv"
"strings"
"sync"
"sync/atomic"
Expand Down Expand Up @@ -81,10 +83,31 @@ func newReconciler(mgr manager.Manager) (reconcile.Reconciler, error) {
}, nil
}

const (
MaxConcurrentReconcilesEnvVar = "MAX_CONCURRENT_RECONCILES"
)

func getMaxConcurrentReconciles() (int, error) {
s, found := os.LookupEnv(MaxConcurrentReconcilesEnvVar)
if !found {
return 0, errors.Errorf("%s must be set", MaxConcurrentReconcilesEnvVar)
}

value, err := strconv.Atoi(s)
if err != nil {
return 0, errors.Wrapf(err, "%s must be int", MaxConcurrentReconcilesEnvVar)
}
return value, nil
}

// add adds a new Controller to mgr with r as the reconcile.Reconciler
func add(mgr manager.Manager, r reconcile.Reconciler) error {
mcr, err := getMaxConcurrentReconciles()
if err != nil {
return err
}
// Create a new controller
c, err := controller.New("perconaxtradbcluster-controller", mgr, controller.Options{MaxConcurrentReconciles: 20, Reconciler: r})
c, err := controller.New("perconaxtradbcluster-controller", mgr, controller.Options{MaxConcurrentReconciles: mcr, Reconciler: r})
if err != nil {
return err
}
Expand Down

0 comments on commit d64e70d

Please sign in to comment.