From 8da6b1d646952a86bef40ae747c32d8d168c35d5 Mon Sep 17 00:00:00 2001 From: vbadrina Date: Wed, 18 Dec 2024 11:13:14 +0530 Subject: [PATCH] Set Mirroring field to false than setting it to nil Signed-off-by: vbadrina --- addons/agent_mirrorpeer_controller.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/addons/agent_mirrorpeer_controller.go b/addons/agent_mirrorpeer_controller.go index a85b2dce..07e479d1 100644 --- a/addons/agent_mirrorpeer_controller.go +++ b/addons/agent_mirrorpeer_controller.go @@ -417,11 +417,12 @@ func (r *MirrorPeerReconciler) toggleMirroring(ctx context.Context, storageClust return err } + if sc.Spec.Mirroring == nil { + sc.Spec.Mirroring = &ocsv1.MirroringSpec{} + } + // Determine if mirroring should be enabled or disabled if enabled { - if sc.Spec.Mirroring == nil { - sc.Spec.Mirroring = &ocsv1.MirroringSpec{} - } oppPeers := getOppositePeerRefs(mp, r.SpokeClusterName) if hasRequiredSecret(sc.Spec.Mirroring.PeerSecretNames, oppPeers) { sc.Spec.Mirroring.Enabled = true @@ -430,7 +431,7 @@ func (r *MirrorPeerReconciler) toggleMirroring(ctx context.Context, storageClust return fmt.Errorf("StorageCluster %q does not have required PeerSecrets", storageClusterName) } } else { - sc.Spec.Mirroring = nil + sc.Spec.Mirroring.Enabled = false r.Logger.Info("Mirroring disabled on StorageCluster", "storageClusterName", storageClusterName) }