core: add workaround for ctx race after admin cephx rotation

Add a workaround for https://github.com/rook/rook/issues/18112.

This is not a proper fix but is a quick fix that will prevent the race
involving operator reload and `ClusterController`'s near-global
context.Context from allowing multiple simultaneous CephCluster
reconciles of the same cluster object.

There may be other ways in which a CephCluster reconcile could enter
this race, but this workaround should reliably resolve the entry after
admin cephx key rotation.

Possible entry after this workaround is in place could involve systems
where the rook-ceph-operator pod is running on a node with high CPU load
which might prevent an ongoing CephCluster reconcile from getting CPU
cycles needed to exit following context cancellation before the sleep
added in this workaround.

Signed-off-by: Blaine Gardner <blaine.gardner@ibm.com>
(cherry picked from commit 05ac850f7b)
This commit is contained in:
Blaine Gardner authored and Mergify committed 2026-08-07 20:58:16 +00:00
1 parent ffdecf0e23
commit 3927ef008f
2 files changed
+13

No files matched your search

+9
View File
@@ -320,6 +320,15 @@ func (r *ReconcileCephCluster) Reconcile(context context.Context, request reconc
}
func (r *ReconcileCephCluster) reconcile(request reconcile.Request) (reconcile.Result, cephv1.CephCluster, error) {
if err := r.opManagerContext.Err(); err != nil {
log.NamespacedInfo(request.Namespace, logger, "context cancelled before entering reconcile, exiting reconcile")
emptyCephCluster := cephv1.CephCluster{ObjectMeta: metav1.ObjectMeta{
Namespace: request.Namespace,
Name: request.Name,
}}
return reconcile.Result{}, emptyCephCluster, nil
}
// Pass the client context to the ClusterController
r.clusterController.client = r.client
+4
View File
@@ -113,6 +113,9 @@ func (o *Operator) Run() error {
// Stop the operator CRD manager
opManagerStop()
// Short sleep to quickly work around https://github.com/rook/rook/issues/18112
time.Sleep(5 * time.Second)
// Run the operator CRD manager again
o.runCRDManager()
@@ -140,6 +143,7 @@ func (o *Operator) runCRDManager() {
// Pass the parent context to the cluster controller so that the monitoring go routines can
// consume it to terminate gracefully
logger.Info("swapping clusterController context") // debug https://github.com/rook/rook/issues/18112
o.clusterController.OpManagerCtx = opManagerContext
// Run the operator CRD manager