From 95b2e606797aeea4c28c2a07d5aff9c983dd68df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Han?= Date: Thu, 2 Jun 2022 17:48:24 +0200 Subject: [PATCH] csi: do not block the reconcile if all clusters are not ready MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If some clusters don't have their monitors up and running, we don't have a clusterInfo (internal detail struct). We don't want to block the csi controller reconcile if all the clusters are not ready. So let's proceed with the elements that are ready and reconcile again to see if others have made progress. Signed-off-by: Sébastien Han --- pkg/operator/ceph/csi/controller.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pkg/operator/ceph/csi/controller.go b/pkg/operator/ceph/csi/controller.go index 322b29098..48eb2ba86 100644 --- a/pkg/operator/ceph/csi/controller.go +++ b/pkg/operator/ceph/csi/controller.go @@ -116,6 +116,9 @@ func (r *ReconcileCSI) Reconcile(context context.Context, request reconcile.Requ } func (r *ReconcileCSI) reconcile(request reconcile.Request) (reconcile.Result, error) { + // reconcileResult is used to communicate the result of the reconciliation back to the caller + var reconcileResult reconcile.Result + serverVersion, err := r.context.Clientset.Discovery().ServerVersion() if err != nil { return opcontroller.ImmediateRetryResult, errors.Wrap(err, "failed to get server version") @@ -150,6 +153,7 @@ func (r *ReconcileCSI) reconcile(request reconcile.Request) (reconcile.Result, e return reconcile.Result{}, nil } + for i, cluster := range cephClusters.Items { if !cluster.DeletionTimestamp.IsZero() { logger.Debugf("ceph cluster %q is being deleting, no need to reconcile the csi driver", request.NamespacedName) @@ -170,9 +174,11 @@ func (r *ReconcileCSI) reconcile(request reconcile.Request) (reconcile.Result, e // This avoids a requeue with exponential backoff and allows the controller to reconcile // more quickly when the cluster is ready. if errors.Is(err, opcontroller.ClusterInfoNoClusterNoSecret) { - return opcontroller.WaitForRequeueIfCephClusterNotReady, nil + logger.Infof("cluster info for cluster %q is not ready yet, will retry in %s, proceeding with ready clusters", cluster.Name, opcontroller.WaitForRequeueIfCephClusterNotReady.RequeueAfter.String()) + reconcileResult = opcontroller.WaitForRequeueIfCephClusterNotReady + continue } - return opcontroller.ImmediateRetryResult, errors.Wrapf(err, "failed to populate cluster info for cluster %q", cluster.Name) + return opcontroller.ImmediateRetryResult, errors.Wrapf(err, "failed to load cluster info for cluster %q", cluster.Name) } logger.Debugf("cluster %q is running on multus, deploying the ceph-csi plugin holder", cluster.Name) @@ -234,5 +240,5 @@ func (r *ReconcileCSI) reconcile(request reconcile.Request) (reconcile.Result, e return opcontroller.ImmediateRetryResult, errors.Wrap(err, "failed to configure ceph csi") } - return reconcile.Result{}, nil + return reconcileResult, nil }