Skip to content

Commit

Permalink
Merge pull request #2923 from rewantsoni/scp-annotation
Browse files Browse the repository at this point in the history
controllers: read the storageclusterpeer name from annotation
  • Loading branch information
openshift-merge-bot[bot] authored Dec 5, 2024
2 parents 13988d9 + 43531c2 commit f3c1b94
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions controllers/mirroring/mirroring_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,10 @@ import (

const (
// internalKey is a special key for storage-client-mapping to establish mirroring between blockPools for internal mode
internalKey = "internal"
mirroringFinalizer = "ocs.openshift.io/mirroring"
clientIDIndexName = "clientID"
internalKey = "internal"
mirroringFinalizer = "ocs.openshift.io/mirroring"
clientIDIndexName = "clientID"
storageClusterPeerAnnotationKey = "ocs.openshift.io/storage-cluster-peer"
)

// MirroringReconciler reconciles a Mirroring fields for Ceph Object(s)
Expand Down Expand Up @@ -184,20 +185,18 @@ func (r *MirroringReconciler) reconcilePhases(clientMappingConfig *corev1.Config
}

// Fetch the StorageClusterPeer instance
storageClusterPeerList := &ocsv1.StorageClusterPeerList{}
if err := r.list(
storageClusterPeerList,
client.InNamespace(clientMappingConfig.Namespace),
client.Limit(2),
); err != nil {
if clientMappingConfig.GetAnnotations()[storageClusterPeerAnnotationKey] == "" {
return ctrl.Result{}, fmt.Errorf("storageClusterPeer reference not found")
}

storageClusterPeer := &ocsv1.StorageClusterPeer{}
storageClusterPeer.Name = clientMappingConfig.GetAnnotations()[storageClusterPeerAnnotationKey]
storageClusterPeer.Namespace = clientMappingConfig.Namespace

if err := r.get(storageClusterPeer); err != nil {
r.log.Error(err, "Failed to get StorageClusterPeer.")
return ctrl.Result{}, err
}
if len(storageClusterPeerList.Items) != 1 {
return ctrl.Result{}, fmt.Errorf("expected 1 StorageClusterPeer but got %d", len(storageClusterPeerList.Items))
}

storageClusterPeer := &storageClusterPeerList.Items[0]

if storageClusterPeer.Status.State != ocsv1.StorageClusterPeerStatePeered ||
storageClusterPeer.Status.PeerInfo == nil ||
Expand Down

0 comments on commit f3c1b94

Please sign in to comment.