Skip to content

Commit e0e3ab3

Browse files
ShyamsundarRBenamarMk
authored andcommitted
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 <[email protected]>
1 parent 80ba156 commit e0e3ab3

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

internal/controller/drplacementcontrolvolsync.go

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,11 @@ func (d *DRPCInstance) createOrUpdateVolSyncDestManifestWork(srcCluster string)
145145
annotations[DRPCNameAnnotation] = d.instance.Name
146146
annotations[DRPCNamespaceAnnotation] = d.instance.Namespace
147147

148-
vrg, err := d.refreshRDSpec(srcCluster, dstCluster)
148+
vrg, err := d.refreshVRGSecondarySpec(srcCluster, dstCluster)
149149
if err != nil {
150150
return ctrlutil.OperationResultNone, err
151151
}
152152

153-
// TODO: Update peerClass from source VRG MW (NOT from view)
154-
155153
opResult, err := d.mwu.CreateOrUpdateVRGManifestWork(
156154
d.instance.Name, d.vrgNamespace,
157155
dstCluster, *vrg, annotations)
@@ -171,22 +169,28 @@ func (d *DRPCInstance) createOrUpdateVolSyncDestManifestWork(srcCluster string)
171169
return ctrlutil.OperationResultNone, nil
172170
}
173171

174-
func (d *DRPCInstance) refreshRDSpec(srcCluster, dstCluster string) (*rmn.VolumeReplicationGroup, error) {
172+
func (d *DRPCInstance) refreshVRGSecondarySpec(srcCluster, dstCluster string) (*rmn.VolumeReplicationGroup, error) {
175173
d.setProgression(rmn.ProgressionSettingupVolsyncDest)
176174

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

182-
if len(srcVRG.Status.ProtectedPVCs) == 0 {
183-
d.log.Info("ProtectedPVCs on pirmary cluster is empty")
184-
185-
return nil, WaitForSourceCluster
180+
srcVRG, err := d.getVRGFromManifestWork(srcCluster)
181+
if err != nil {
182+
return nil, fmt.Errorf("failed to find source VRG ManifestWork in cluster %s", srcCluster)
186183
}
187184

188185
dstVRG := d.newVRG(dstCluster, rmn.Secondary, nil)
189-
d.resetRDSpec(srcVRG, &dstVRG)
186+
187+
if len(srcVRGView.Status.ProtectedPVCs) != 0 {
188+
d.resetRDSpec(srcVRGView, &dstVRG)
189+
}
190+
191+
// Update destination VRG peerClasses with the source classes, such that when secondary is promoted to primary
192+
// on actions, it uses the same peerClasses as the primary
193+
dstVRG.Spec.Async.PeerClasses = srcVRG.Spec.Async.PeerClasses
190194

191195
return &dstVRG, nil
192196
}

0 commit comments

Comments
 (0)