Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

controllers: read the storageclusterpeer name from annotation #2923

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading