Skip to content

Commit

Permalink
addons: move the fetching of cephfsid only for non-provider mode
Browse files Browse the repository at this point in the history
Signed-off-by: Rewant Soni <[email protected]>
  • Loading branch information
rewantsoni committed Dec 17, 2024
1 parent 27674c2 commit 0d6d955
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
50 changes: 25 additions & 25 deletions addons/agent_mirrorpeer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion controllers/mirrorpeer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0d6d955

Please sign in to comment.