Skip to content

Commit 44389b5

Browse files
committed
Create MAX_CONCURRENT_RECONCILES env var
1 parent 7c74ba5 commit 44389b5

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed

deploy/cw-bundle.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,8 @@ spec:
811811
fieldPath: metadata.name
812812
- name: OPERATOR_NAME
813813
value: percona-xtradb-cluster-operator
814+
- name: MAX_CONCURRENT_RECONCILES
815+
value: "20"
814816
image: percona/percona-xtradb-cluster-operator:1.10.0
815817
imagePullPolicy: Always
816818
resources:

deploy/cw-operator.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ spec:
3636
fieldPath: metadata.name
3737
- name: OPERATOR_NAME
3838
value: percona-xtradb-cluster-operator
39+
- name: MAX_CONCURRENT_RECONCILES
40+
value: "20"
3941
image: percona/percona-xtradb-cluster-operator:1.10.0
4042
imagePullPolicy: Always
4143
resources:

deploy/operator.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ spec:
3939
fieldPath: metadata.name
4040
- name: OPERATOR_NAME
4141
value: percona-xtradb-cluster-operator
42+
- name: MAX_CONCURRENT_RECONCILES
43+
value: "20"
4244
image: perconalab/percona-xtradb-cluster-operator:main
4345
imagePullPolicy: Always
4446
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)