From b1ce9f226ef4513b628fbdadcb83c9cfd724adf2 Mon Sep 17 00:00:00 2001 From: Travis Nielsen Date: Fri, 7 Nov 2025 11:58:03 -0700 Subject: [PATCH] operator: allow setting concurrent cluster reconciles The cephcluster controller allows setting concurrent reconciles with a setting in the operator configmap. Signed-off-by: Travis Nielsen --- PendingReleaseNotes.md | 5 +++++ deploy/examples/operator.yaml | 8 ++++++++ pkg/operator/ceph/cluster/controller.go | 11 ++++++++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/PendingReleaseNotes.md b/PendingReleaseNotes.md index 8c6809fcd..11935be17 100644 --- a/PendingReleaseNotes.md +++ b/PendingReleaseNotes.md @@ -3,3 +3,8 @@ ## Breaking Changes ## Features + +- Experimental: Allow concurrent reconciles of the CephCluster CR when there multiple clusters + being managed by the same Rook operator. Concurrency is enabled by increasing + the operator setting `ROOK_RECONCILE_CONCURRENT_CLUSTERS` to a value greater + than `1`. diff --git a/deploy/examples/operator.yaml b/deploy/examples/operator.yaml index cdc196cd7..240f7c307 100644 --- a/deploy/examples/operator.yaml +++ b/deploy/examples/operator.yaml @@ -636,6 +636,14 @@ spec: - name: ROOK_CURRENT_NAMESPACE_ONLY value: "false" + # Experimental: The number of Ceph clusters to reconcile in parallel. + # The default is 1, which means each cluster is reconciled sequentially within the operator. + # When set to a value greater than 1, the operator can reconcile multiple clusters concurrently, + # and all logging will be interleaved in the same operator log. + # Changing this value requires restarting the operator pod. + - name: ROOK_RECONCILE_CONCURRENT_CLUSTERS + value: "1" + # Whether to start pods as privileged that mount a host path, which includes the Ceph mon, osd pods and csi provisioners(if logrotation is on). # Set this to true if SELinux is enabled (e.g. OpenShift) to workaround the anyuid issues. # For more details see https://github.com/rook/rook/issues/1314#issuecomment-355799641 diff --git a/pkg/operator/ceph/cluster/controller.go b/pkg/operator/ceph/cluster/controller.go index 0f240cc13..a0749fc68 100644 --- a/pkg/operator/ceph/cluster/controller.go +++ b/pkg/operator/ceph/cluster/controller.go @@ -20,6 +20,8 @@ package cluster import ( "context" "fmt" + "os" + "strconv" csiopv1 "github.com/ceph/ceph-csi-operator/api/v1" "github.com/coreos/pkg/capnslog" @@ -143,8 +145,15 @@ func watchOwnedCoreObject[T client.Object](c controller.Controller, mgr manager. } func add(opManagerContext context.Context, mgr manager.Manager, r reconcile.Reconciler, context *clusterd.Context, opConfig opcontroller.OperatorConfig) error { + concurrentClusters := os.Getenv("ROOK_RECONCILE_CONCURRENT_CLUSTERS") + concurrentReconciles := 1 + if i, err := strconv.Atoi(concurrentClusters); err == nil && i > 1 { + logger.Infof("Setting concurrent cluster reconciles to %d", i) + concurrentReconciles = i + } + // Create a new controller - c, err := controller.New(controllerName, mgr, controller.Options{Reconciler: r}) + c, err := controller.New(controllerName, mgr, controller.Options{Reconciler: r, MaxConcurrentReconciles: concurrentReconciles}) if err != nil { return err }