diff --git a/addons/agent_mirrorpeer_controller.go b/addons/agent_mirrorpeer_controller.go index b24048f3..2b76ffef 100644 --- a/addons/agent_mirrorpeer_controller.go +++ b/addons/agent_mirrorpeer_controller.go @@ -374,6 +374,9 @@ func (r *MirrorPeerReconciler) toggleMirroring(ctx context.Context, storageClust // 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 diff --git a/addons/rook_secret_handler.go b/addons/rook_secret_handler.go index b50ef29a..375eccd8 100644 --- a/addons/rook_secret_handler.go +++ b/addons/rook_secret_handler.go @@ -197,6 +197,9 @@ func updateStorageCluster(secretName, storageClusterName, storageClusterNamespac } // Update secret name + if sc.Spec.Mirroring == nil { + sc.Spec.Mirroring = &ocsv1.MirroringSpec{} + } if !utils.ContainsString(sc.Spec.Mirroring.PeerSecretNames, secretName) { sc.Spec.Mirroring.PeerSecretNames = append(sc.Spec.Mirroring.PeerSecretNames, secretName) err := spokeClient.Update(ctx, sc)