Skip to content

Commit d64e70d

Browse files
committed
Create MAX_CONCURRENT_RECONCILES env var
1 parent 08bc3d8 commit d64e70d

File tree

7 files changed

+1216
-1
lines changed

7 files changed

+1216
-1
lines changed

config/crd/bases/pxc.percona.com_perconaxtradbclusters.yaml

+296
Large diffs are not rendered by default.

deploy/bundle.yaml

+298
Large diffs are not rendered by default.

deploy/crd.yaml

+296
Large diffs are not rendered by default.

deploy/cw-bundle.yaml

+298
Large diffs are not rendered by default.

deploy/cw-operator.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ spec:
4242
value: percona-xtradb-cluster-operator
4343
- name: DISABLE_TELEMETRY
4444
value: "false"
45+
- name: MAX_CONCURRENT_RECONCILES
46+
value: "20"
4547
image: perconalab/percona-xtradb-cluster-operator:main
4648
imagePullPolicy: Always
4749
resources:

deploy/operator.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ spec:
4545
value: percona-xtradb-cluster-operator
4646
- name: DISABLE_TELEMETRY
4747
value: "false"
48+
- name: MAX_CONCURRENT_RECONCILES
49+
value: "20"
4850
image: perconalab/percona-xtradb-cluster-operator:main
4951
imagePullPolicy: Always
5052
livenessProbe:

pkg/controller/pxc/controller.go

+24-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import (
44
"context"
55
"encoding/base64"
66
"encoding/json"
7+
"os"
78
"reflect"
9+
"strconv"
810
"strings"
911
"sync"
1012
"sync/atomic"
@@ -81,10 +83,31 @@ func newReconciler(mgr manager.Manager) (reconcile.Reconciler, error) {
8183
}, nil
8284
}
8385

86+
const (
87+
MaxConcurrentReconcilesEnvVar = "MAX_CONCURRENT_RECONCILES"
88+
)
89+
90+
func getMaxConcurrentReconciles() (int, error) {
91+
s, found := os.LookupEnv(MaxConcurrentReconcilesEnvVar)
92+
if !found {
93+
return 0, errors.Errorf("%s must be set", MaxConcurrentReconcilesEnvVar)
94+
}
95+
96+
value, err := strconv.Atoi(s)
97+
if err != nil {
98+
return 0, errors.Wrapf(err, "%s must be int", MaxConcurrentReconcilesEnvVar)
99+
}
100+
return value, nil
101+
}
102+
84103
// add adds a new Controller to mgr with r as the reconcile.Reconciler
85104
func add(mgr manager.Manager, r reconcile.Reconciler) error {
105+
mcr, err := getMaxConcurrentReconciles()
106+
if err != nil {
107+
return err
108+
}
86109
// Create a new controller
87-
c, err := controller.New("perconaxtradbcluster-controller", mgr, controller.Options{MaxConcurrentReconciles: 20, Reconciler: r})
110+
c, err := controller.New("perconaxtradbcluster-controller", mgr, controller.Options{MaxConcurrentReconciles: mcr, Reconciler: r})
88111
if err != nil {
89112
return err
90113
}

0 commit comments

Comments
 (0)