diff --git a/controllers/drplacementcontrol.go b/controllers/drplacementcontrol.go index 5babad20d..e3521380f 100644 --- a/controllers/drplacementcontrol.go +++ b/controllers/drplacementcontrol.go @@ -18,6 +18,7 @@ import ( "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" + "k8s.io/apimachinery/pkg/util/sets" "sigs.k8s.io/yaml" rmn "github.com/ramendr/ramen/api/v1alpha1" @@ -1501,7 +1502,7 @@ func (d *DRPCInstance) generateVRG(repState rmn.ReplicationState) rmn.VolumeRepl Spec: rmn.VolumeReplicationGroupSpec{ PVCSelector: d.instance.Spec.PVCSelector, ReplicationState: repState, - S3Profiles: rmnutil.DRPolicyS3Profiles(d.drPolicy, d.drClusters).List(), + S3Profiles: d.availableS3Profiles(), KubeObjectProtection: d.instance.Spec.KubeObjectProtection, }, } @@ -1513,6 +1514,21 @@ func (d *DRPCInstance) generateVRG(repState rmn.ReplicationState) rmn.VolumeRepl return vrg } +func (d *DRPCInstance) availableS3Profiles() []string { + profiles := sets.New[string]() + + for i := range d.drClusters { + drCluster := &d.drClusters[i] + if drClusterIsDeleted(drCluster) { + continue + } + + profiles.Insert(drCluster.Spec.S3ProfileName) + } + + return sets.List(profiles) +} + func (d *DRPCInstance) generateVRGSpecAsync() *rmn.VRGAsyncSpec { if dRPolicySupportsRegional(d.drPolicy, d.drClusters) { return &rmn.VRGAsyncSpec{