From a654e19f580b830a7e2a9ec669434b819256e789 Mon Sep 17 00:00:00 2001 From: rakeshgm Date: Fri, 20 Sep 2024 16:25:39 +0530 Subject: [PATCH] skip filtering using sid with replicationClass skip filtering using sid with replicationClass if peerclass is not found Signed-off-by: rakeshgm --- .../volumereplicationgroup_controller.go | 2 +- internal/controller/vrg_volrep.go | 23 ++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/internal/controller/volumereplicationgroup_controller.go b/internal/controller/volumereplicationgroup_controller.go index 39df5a5e1..ba50a8575 100644 --- a/internal/controller/volumereplicationgroup_controller.go +++ b/internal/controller/volumereplicationgroup_controller.go @@ -854,7 +854,7 @@ func (v *VRGInstance) separatePVCsUsingStorageClassProvisioner(pvcList *corev1.P switch len(v.instance.Spec.Async.PeerClasses) { case 0: - v.log.Info("validate using sc provisioner") + v.log.Info("validate using only sc provisioner") replicationClassMatchFound := false diff --git a/internal/controller/vrg_volrep.go b/internal/controller/vrg_volrep.go index db93bca7c..b7b682d0c 100644 --- a/internal/controller/vrg_volrep.go +++ b/internal/controller/vrg_volrep.go @@ -1269,6 +1269,8 @@ func (v *VRGInstance) selectVolumeReplicationClass( return nil, fmt.Errorf("missing storageID label in storageclass of pvc %s", namespacedName) } + peerClasses := len(v.instance.Spec.Async.PeerClasses) + matchingReplicationClassList := []*volrep.VolumeReplicationClass{} for index := range v.replClassList.Items { @@ -1285,13 +1287,22 @@ func (v *VRGInstance) selectVolumeReplicationClass( continue } - sIDFromReplicationClass, exists := replicationClass.GetLabels()[StorageIDLabel] - if !exists { - continue - } + // if peerClasses does not exist, replicationClasses would not have sid in + // older ramen versions, this check is neeed because we need to handle upgrade + // scenario where sid is not present in replicatioClass. - if sIDFromReplicationClass != sID { - continue + // if peerClass exist, continue to check if sid matches, or skip the check and proceed + // to append to matchingReplicationClassList + if peerClasses != 0 { + + sIDFromReplicationClass, exists := replicationClass.GetLabels()[StorageIDLabel] + if !exists { + continue + } + + if sIDFromReplicationClass != sID { + continue + } } matchingReplicationClassList = append(matchingReplicationClassList, replicationClass)