From e0e3ab39e25464471c87bfd48c4965cd63ad0727 Mon Sep 17 00:00:00 2001 From: Shyamsundar Ranganathan Date: Tue, 5 Nov 2024 10:05:55 -0500 Subject: [PATCH] Update Secondary VRG peerClasses from Primary VRG 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 --- .../controller/drplacementcontrolvolsync.go | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/internal/controller/drplacementcontrolvolsync.go b/internal/controller/drplacementcontrolvolsync.go index e4bf99f34..73bc27ba5 100644 --- a/internal/controller/drplacementcontrolvolsync.go +++ b/internal/controller/drplacementcontrolvolsync.go @@ -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) @@ -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 }