Skip to content

Commit

Permalink
controllers: disable mirroring when peer cluster is down
Browse files Browse the repository at this point in the history
allow the mirroring to be disabled when the peer site is down

Signed-off-by: Rewant Soni <[email protected]>
  • Loading branch information
rewantsoni committed Jan 7, 2025
1 parent a8aa21c commit b883b8c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions controllers/mirroring/mirroring_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,16 @@ func (r *MirroringReconciler) reconcilePhases(clientMappingConfig *corev1.Config
return ctrl.Result{RequeueAfter: 3 * time.Second}, nil
}

errorOccurred := false

ocsClient, err := providerClient.NewProviderClient(r.ctx, storageClusterPeer.Spec.ApiEndpoint, util.OcsClientTimeout)
if err != nil {
return ctrl.Result{}, fmt.Errorf("failed to create a new provider client: %v", err)
r.log.Error(err, "failed to create a new provider client")
errorOccurred = true
}
if ocsClient != nil {
defer ocsClient.Close()
}
defer ocsClient.Close()

errorOccurred := false

if errored := r.reconcileRbdMirror(clientMappingConfig, shouldMirror); errored {
errorOccurred = true
Expand Down Expand Up @@ -321,7 +324,7 @@ func (r *MirroringReconciler) reconcileBlockPoolMirroring(
blockPoolByName[cephBlockPool.Name] = cephBlockPool
}

if len(blockPoolByName) > 0 {
if len(blockPoolByName) > 0 && ocsClient != nil {
// fetch BlockPoolsInfo
response, err := ocsClient.GetBlockPoolsInfo(
r.ctx,
Expand Down Expand Up @@ -479,7 +482,7 @@ func (r *MirroringReconciler) reconcileRadosNamespaceMirroring(
peerClientIDs = append(peerClientIDs, peerClientID)
}

if len(peerClientIDs) > 0 {
if len(peerClientIDs) > 0 && ocsClient != nil {
response, err := ocsClient.GetStorageClientsInfo(
r.ctx,
storageClusterPeer.Status.PeerInfo.StorageClusterUid,
Expand Down

0 comments on commit b883b8c

Please sign in to comment.