Skip to content

Commit ad52f81

Browse files
committed
Update group replication secret before restoring VGRContent
Signed-off-by: Elena Gershkovich <[email protected]>
1 parent 5b0cef1 commit ad52f81

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

internal/controller/vrg_volgrouprep.go

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ import (
2222
rmnutil "github.com/ramendr/ramen/internal/controller/util"
2323
)
2424

25+
const (
26+
groupReplicationSecretName = "replication.storage.openshift.io/group-replication-secret-name"
27+
groupReplicationSecretNamespace = "replication.storage.openshift.io/group-replication-secret-namespace"
28+
)
29+
2530
//nolint:gocognit,cyclop,funlen
2631
func (v *VRGInstance) reconcileVolGroupRepsAsPrimary(groupPVCs map[types.NamespacedName][]*corev1.PersistentVolumeClaim,
2732
) {
@@ -976,7 +981,7 @@ func (v *VRGInstance) restoreVGRCsFromObjectStore(objectStore ObjectStorer, s3Pr
976981
return 0, fmt.Errorf("%s: %w", errMsg, err)
977982
}
978983

979-
return restoreClusterDataObjects(v, vgrcList, "VGRC", cleanupVGRCForRestore, v.validateExistingVGRC)
984+
return restoreClusterDataObjects(v, vgrcList, "VGRC", v.cleanupVGRCForRestore, v.validateExistingVGRC)
980985
}
981986

982987
func (v *VRGInstance) restoreVGRsFromObjectStore(objectStore ObjectStorer, s3ProfileName string) (int, error) {
@@ -1054,11 +1059,11 @@ func (v *VRGInstance) validateExistingVGR(vgr *volrep.VolumeGroupReplication) er
10541059
return nil
10551060
}
10561061

1057-
func cleanupVGRCForRestore(vgrc *volrep.VolumeGroupReplicationContent) error {
1062+
func (v *VRGInstance) cleanupVGRCForRestore(vgrc *volrep.VolumeGroupReplicationContent) error {
10581063
vgrc.ResourceVersion = ""
10591064
vgrc.Spec.VolumeGroupReplicationRef = nil
10601065

1061-
return nil
1066+
return v.processVGRCSecrets(vgrc)
10621067
}
10631068

10641069
func (v *VRGInstance) cleanupVGRForRestore(vgr *volrep.VolumeGroupReplication) error {
@@ -1076,3 +1081,24 @@ func (v *VRGInstance) cleanupVGRForRestore(vgr *volrep.VolumeGroupReplication) e
10761081

10771082
return nil
10781083
}
1084+
1085+
func (v *VRGInstance) processVGRCSecrets(vgrc *volrep.VolumeGroupReplicationContent) error {
1086+
vgrclass := &volrep.VolumeGroupReplicationClass{}
1087+
1088+
err := v.reconciler.Get(v.ctx, types.NamespacedName{Name: vgrc.Spec.VolumeGroupReplicationClassName}, vgrclass)
1089+
if err != nil {
1090+
return err
1091+
}
1092+
1093+
secretName := vgrclass.Spec.Parameters[groupReplicationSecretName]
1094+
if secretName != "" {
1095+
rmnutil.AddAnnotation(vgrc, groupReplicationSecretName, secretName)
1096+
}
1097+
1098+
secretNamespace := vgrclass.Spec.Parameters[groupReplicationSecretNamespace]
1099+
if secretNamespace != "" {
1100+
rmnutil.AddAnnotation(vgrc, groupReplicationSecretNamespace, secretNamespace)
1101+
}
1102+
1103+
return nil
1104+
}

0 commit comments

Comments
 (0)