From 849ed3bc4ea77b32f63821dc88a913c3c4a180e4 Mon Sep 17 00:00:00 2001 From: vbadrina Date: Thu, 19 Dec 2024 12:53:40 +0530 Subject: [PATCH] Unset CephBlockPool mirroring if Mirroring spec is nil on SC Signed-off-by: vbadrina --- controllers/storagecluster/cephblockpools.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/controllers/storagecluster/cephblockpools.go b/controllers/storagecluster/cephblockpools.go index 6cd0ea92ef..066e79684f 100644 --- a/controllers/storagecluster/cephblockpools.go +++ b/controllers/storagecluster/cephblockpools.go @@ -94,12 +94,14 @@ func (o *ocsCephBlockPools) reconcileCephBlockPool(r *StorageClusterReconciler, cephBlockPool.Spec.PoolSpec.Replicated = generateCephReplicatedSpec(storageCluster, "data") cephBlockPool.Spec.PoolSpec.EnableRBDStats = true - if storageCluster.Spec.Mirroring != nil { - if storageCluster.Spec.Mirroring.Enabled { + // Since provider mode handles mirroring, we only need to handle for internal mode + if storageCluster.Annotations["ocs.openshift.io/deployment-mode"] != "provider" { + if storageCluster.Spec.Mirroring != nil && storageCluster.Spec.Mirroring.Enabled { cephBlockPool.Spec.PoolSpec.Mirroring.Enabled = true cephBlockPool.Spec.PoolSpec.Mirroring.Mode = "image" cephBlockPool.Spec.PoolSpec.Mirroring.Peers = o.addPeerSecretsToCephBlockPool(r, storageCluster, cephBlockPool.Name, cephBlockPool.Namespace) } else { + // If mirroring is not enabled or is nil, disable it. This is to ensure that the pool mirroring does not remain enabled during further reconciliations cephBlockPool.Spec.PoolSpec.Mirroring = cephv1.MirroringSpec{Enabled: false} } } @@ -257,12 +259,14 @@ func (o *ocsCephBlockPools) reconcileNonResilientCephBlockPool(r *StorageCluster } cephBlockPool.Spec.PoolSpec.EnableRBDStats = true - if storageCluster.Spec.Mirroring != nil { - if storageCluster.Spec.Mirroring.Enabled { + // Since provider mode handles mirroring, we only need to handle for internal mode + if storageCluster.Annotations["ocs.openshift.io/deployment-mode"] != "provider" { + if storageCluster.Spec.Mirroring != nil && storageCluster.Spec.Mirroring.Enabled { cephBlockPool.Spec.PoolSpec.Mirroring.Enabled = true cephBlockPool.Spec.PoolSpec.Mirroring.Mode = "image" cephBlockPool.Spec.PoolSpec.Mirroring.Peers = o.addPeerSecretsToCephBlockPool(r, storageCluster, cephBlockPool.Name, cephBlockPool.Namespace) } else { + // If mirroring is not enabled or is nil, disable it. This is to ensure that the pool mirroring does not remain enabled during further reconciliations cephBlockPool.Spec.PoolSpec.Mirroring = cephv1.MirroringSpec{Enabled: false} } }