diff --git a/pkg/operator/ceph/cluster/controller.go b/pkg/operator/ceph/cluster/controller.go index 233782308..e3e92d3cb 100644 --- a/pkg/operator/ceph/cluster/controller.go +++ b/pkg/operator/ceph/cluster/controller.go @@ -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 diff --git a/pkg/operator/ceph/operator.go b/pkg/operator/ceph/operator.go index 2674c41ab..45a88ce0c 100644 --- a/pkg/operator/ceph/operator.go +++ b/pkg/operator/ceph/operator.go @@ -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