Skip to content

Commit

Permalink
Set Mirroring field to false than setting it to nil
Browse files Browse the repository at this point in the history
Signed-off-by: vbadrina <[email protected]>
  • Loading branch information
vbnrh committed Dec 18, 2024
1 parent 1f8102f commit 8da6b1d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions addons/agent_mirrorpeer_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}

Expand Down

0 comments on commit 8da6b1d

Please sign in to comment.