Skip to content

Commit

Permalink
skip filtering using sid with replicationClass
Browse files Browse the repository at this point in the history
skip filtering using sid with replicationClass if peerclass
is not found

Signed-off-by: rakeshgm <rakeshgm@redhat.com>
  • Loading branch information
rakeshgm committed Sep 23, 2024
1 parent b27af18 commit 2e75380
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion internal/controller/volumereplicationgroup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
24 changes: 17 additions & 7 deletions internal/controller/vrg_volrep.go
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ func (v *VRGInstance) createVR(vrNamespacedName types.NamespacedName, state volr
// functions to be changed would be processVRAsPrimary(), processVRAsSecondary()
// to either receive pvc NamespacedName or pvc itself as an additional argument.

//nolint:funlen,cyclop
//nolint:funlen,cyclop,gocognit
func (v *VRGInstance) selectVolumeReplicationClass(
namespacedName types.NamespacedName,
) (*volrep.VolumeReplicationClass, error) {
Expand Down Expand Up @@ -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 {
Expand All @@ -1285,13 +1287,21 @@ 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)
Expand Down

0 comments on commit 2e75380

Please sign in to comment.