Skip to content

Commit

Permalink
Update Secondary VRG peerClasses from Primary VRG
Browse files Browse the repository at this point in the history
Secondary VRG should carry the same peerClass information as the Primary
VRG, such that on action changes that promotes the Secondary to a Primary
the same peerClasses are used to recover and protect the PVCs.

This commit addresses updating Secondary VRG with Primary VRG peerClasses
for async cases when Volsync is in use.

Currently VRG as Secondary is created when there are any PVCs protected
by Volsync. Once the issue of mixed workloads is addressed, a Secondary
VRG would exist for all cases, VolRep and sync DR setups as well. This
will ensure that in all cases the Secondary peerClasses are a copy of
the Primary.

Signed-off-by: Shyamsundar Ranganathan <[email protected]>
  • Loading branch information
ShyamsundarR authored and BenamarMk committed Nov 6, 2024
1 parent 80ba156 commit e0e3ab3
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions internal/controller/drplacementcontrolvolsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,11 @@ func (d *DRPCInstance) createOrUpdateVolSyncDestManifestWork(srcCluster string)
annotations[DRPCNameAnnotation] = d.instance.Name
annotations[DRPCNamespaceAnnotation] = d.instance.Namespace

vrg, err := d.refreshRDSpec(srcCluster, dstCluster)
vrg, err := d.refreshVRGSecondarySpec(srcCluster, dstCluster)
if err != nil {
return ctrlutil.OperationResultNone, err
}

// TODO: Update peerClass from source VRG MW (NOT from view)

opResult, err := d.mwu.CreateOrUpdateVRGManifestWork(
d.instance.Name, d.vrgNamespace,
dstCluster, *vrg, annotations)
Expand All @@ -171,22 +169,28 @@ func (d *DRPCInstance) createOrUpdateVolSyncDestManifestWork(srcCluster string)
return ctrlutil.OperationResultNone, nil
}

func (d *DRPCInstance) refreshRDSpec(srcCluster, dstCluster string) (*rmn.VolumeReplicationGroup, error) {
func (d *DRPCInstance) refreshVRGSecondarySpec(srcCluster, dstCluster string) (*rmn.VolumeReplicationGroup, error) {
d.setProgression(rmn.ProgressionSettingupVolsyncDest)

srcVRG, found := d.vrgs[srcCluster]
srcVRGView, found := d.vrgs[srcCluster]
if !found {
return nil, fmt.Errorf("failed to find source VolSync VRG in cluster %s. VRGs %v", srcCluster, d.vrgs)
}

if len(srcVRG.Status.ProtectedPVCs) == 0 {
d.log.Info("ProtectedPVCs on pirmary cluster is empty")

return nil, WaitForSourceCluster
srcVRG, err := d.getVRGFromManifestWork(srcCluster)
if err != nil {
return nil, fmt.Errorf("failed to find source VRG ManifestWork in cluster %s", srcCluster)
}

dstVRG := d.newVRG(dstCluster, rmn.Secondary, nil)
d.resetRDSpec(srcVRG, &dstVRG)

if len(srcVRGView.Status.ProtectedPVCs) != 0 {
d.resetRDSpec(srcVRGView, &dstVRG)
}

// Update destination VRG peerClasses with the source classes, such that when secondary is promoted to primary
// on actions, it uses the same peerClasses as the primary
dstVRG.Spec.Async.PeerClasses = srcVRG.Spec.Async.PeerClasses

return &dstVRG, nil
}
Expand Down

0 comments on commit e0e3ab3

Please sign in to comment.