Skip to content

Commit

Permalink
Merge pull request #2961 from rewantsoni/rbdmirror-4.18
Browse files Browse the repository at this point in the history
DFBUGS-1258: [release-4.18] controllers: allow failover to complete when peer site is down
  • Loading branch information
openshift-merge-bot[bot] authored Jan 10, 2025
2 parents 75ec5d1 + 7007f01 commit 08092c9
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
Expand Up @@ -16,8 +16,6 @@ package mirroring
import (
"context"
"fmt"
"golang.org/x/exp/maps"
"k8s.io/utils/ptr"
"slices"
"time"

Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 08092c9

Please sign in to comment.