Skip to content

Commit

Permalink
controllers: allow failover to complete when peer site is down
Browse files Browse the repository at this point in the history
For failover to complete, we need to reconcile the rbdMirror CR.
ocs-client creation was blocking reconcile of rbdMirror, hence
continue reconcile for local resources even if the peer site is
down

Signed-off-by: Rewant Soni <resoni@redhat.com>
(cherry picked from commit e7121c8)
rewantsoni committed Jan 9, 2025
1 parent a09234c commit 7007f01
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions controllers/mirroring/mirroring_controller.go
Original file line number Diff line number Diff line change
@@ -16,8 +16,6 @@ package mirroring
import (
"context"
"fmt"
"golang.org/x/exp/maps"
"k8s.io/utils/ptr"
"slices"
"time"

@@ -29,10 +27,12 @@ import (

"github.com/go-logr/logr"
rookCephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
"golang.org/x/exp/maps"
corev1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -209,13 +209,15 @@ 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
} else if ocsClient != nil {
defer ocsClient.Close()
}
defer ocsClient.Close()

errorOccurred := false

if errored := r.reconcileRbdMirror(clientMappingConfig, shouldMirror); errored {
errorOccurred = true
@@ -321,7 +323,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,
@@ -479,7 +481,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,

0 comments on commit 7007f01

Please sign in to comment.