diff --git a/addons/agent_mirrorpeer_controller.go b/addons/agent_mirrorpeer_controller.go index b24048f3..92091cb2 100644 --- a/addons/agent_mirrorpeer_controller.go +++ b/addons/agent_mirrorpeer_controller.go @@ -373,6 +373,9 @@ func (r *MirrorPeerReconciler) toggleMirroring(ctx context.Context, storageClust } // Determine if mirroring should be enabled or disabled + if sc.spec.Mirroring == nil { + sc.spec.Mirroring = &ocsv1.MirroringSpec{} + } if enabled { oppPeers := getOppositePeerRefs(mp, r.SpokeClusterName) if hasRequiredSecret(sc.Spec.Mirroring.PeerSecretNames, oppPeers) { diff --git a/addons/rook_secret_handler.go b/addons/rook_secret_handler.go index b50ef29a..5247d3e5 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)