From 0d6d95525a9df324b17d299721b2d9764f9ffde1 Mon Sep 17 00:00:00 2001 From: Rewant Soni Date: Tue, 17 Dec 2024 14:01:05 +0530 Subject: [PATCH] addons: move the fetching of cephfsid only for non-provider mode Signed-off-by: Rewant Soni --- addons/agent_mirrorpeer_controller.go | 50 +++++++++++++-------------- controllers/mirrorpeer_controller.go | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/addons/agent_mirrorpeer_controller.go b/addons/agent_mirrorpeer_controller.go index ad574123..a85b2dce 100644 --- a/addons/agent_mirrorpeer_controller.go +++ b/addons/agent_mirrorpeer_controller.go @@ -148,17 +148,17 @@ func (r *MirrorPeerReconciler) Reconcile(ctx context.Context, req ctrl.Request) return ctrl.Result{}, err } - clusterFSIDs := make(map[string]string) - logger.Info("Fetching clusterFSIDs") - err = r.fetchClusterFSIDs(ctx, &mirrorPeer, clusterFSIDs) - if err != nil { - if errors.IsNotFound(err) { - return ctrl.Result{RequeueAfter: 60 * time.Second}, nil + if !hasStorageClientRef { + clusterFSIDs := make(map[string]string) + logger.Info("Fetching clusterFSIDs") + err = r.fetchClusterFSIDs(ctx, &mirrorPeer, clusterFSIDs) + if err != nil { + if errors.IsNotFound(err) { + return ctrl.Result{RequeueAfter: 60 * time.Second}, nil + } + return ctrl.Result{}, fmt.Errorf("an unknown error occurred while fetching the cluster fsids, retrying again: %v", err) } - return ctrl.Result{}, fmt.Errorf("an unknown error occurred while fetching the cluster fsids, retrying again: %v", err) - } - if !hasStorageClientRef { logger.Info("Labeling RBD storageclasses") errs := r.labelStorageClasses(ctx, scr.Namespace, clusterFSIDs) if len(errs) > 0 { @@ -168,25 +168,25 @@ func (r *MirrorPeerReconciler) Reconcile(ctx context.Context, req ctrl.Request) if len(errs) > 0 { return ctrl.Result{}, fmt.Errorf("few failures occurred while labeling VolumeSnapshotClasses: %v", errs) } - } - if mirrorPeer.Spec.Type == multiclusterv1alpha1.Async && !hasStorageClientRef { - logger.Info("Enabling async mode dependencies") - err = r.labelCephClusters(ctx, scr, clusterFSIDs) - if err != nil { - logger.Error("Failed to label cephcluster", "error", err) - return ctrl.Result{}, err - } - err = r.enableCSIAddons(ctx, scr.Namespace) - if err != nil { - return ctrl.Result{}, fmt.Errorf("failed to start CSI Addons for rook: %v", err) - } + if mirrorPeer.Spec.Type == multiclusterv1alpha1.Async { + logger.Info("Enabling async mode dependencies") + err = r.labelCephClusters(ctx, scr, clusterFSIDs) + if err != nil { + logger.Error("Failed to label cephcluster", "error", err) + return ctrl.Result{}, err + } + err = r.enableCSIAddons(ctx, scr.Namespace) + if err != nil { + return ctrl.Result{}, fmt.Errorf("failed to start CSI Addons for rook: %v", err) + } - err = r.enableMirroring(ctx, scr.Name, scr.Namespace, &mirrorPeer) - if err != nil { - return ctrl.Result{}, fmt.Errorf("failed to enable mirroring the storagecluster %q in namespace %q in managed cluster: %v", scr.Name, scr.Namespace, err) - } + err = r.enableMirroring(ctx, scr.Name, scr.Namespace, &mirrorPeer) + if err != nil { + return ctrl.Result{}, fmt.Errorf("failed to enable mirroring the storagecluster %q in namespace %q in managed cluster: %v", scr.Name, scr.Namespace, err) + } + } } if mirrorPeer.Spec.Type == multiclusterv1alpha1.Async && hasStorageClientRef { diff --git a/controllers/mirrorpeer_controller.go b/controllers/mirrorpeer_controller.go index ab19248f..8762373c 100644 --- a/controllers/mirrorpeer_controller.go +++ b/controllers/mirrorpeer_controller.go @@ -1089,7 +1089,7 @@ func (r *MirrorPeerReconciler) updateMirrorPeerStatus(ctx context.Context, mirro logger.Error("Error occurred while updating the status of mirrorpeer", "error", statusErr, "MirrorPeer", mirrorPeer.Name) return ctrl.Result{Requeue: true}, nil } - return ctrl.Result{}, nil + return ctrl.Result{Requeue: true}, nil } } else { // Sync mode status update, same flow as async but for s3 profile