Skip to content

Commit

Permalink
Allow cross-namespace restore of CSI snapshots
Browse files Browse the repository at this point in the history
- Check for namespace mapping information.
- If there is a map, replace VolumeSnapshots namespace to the target namespace

Fixes KUBEDR-364 and KUBEDR-406

Fixes Issues these similar issues from Velero:
1. vmware-tanzu/velero#2143
2. https://github.com/vmware-tanzu/velero-plugin-for-csi/issues/75
  • Loading branch information
sshende-catalogicsoftware committed Oct 3, 2022
1 parent be3dbc3 commit 40d2b08
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/restore/pvc_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ func (p *PVCRestoreItemAction) Execute(input *velero.RestoreItemActionExecuteInp
pvc.SetNamespace(val)
}

// If cross-namespace restore is configured, change the namespace
// for PVC object to be restored
if val, ok := input.Restore.Spec.NamespaceMapping[pvc.GetNamespace()]; ok {
pvc.SetNamespace(val)
}

volumeSnapshotName, ok := pvc.Annotations[util.VolumeSnapshotLabel]
if !ok {
p.Log.Infof("Skipping PVCRestoreItemAction for PVC %s/%s, PVC does not have a CSI volumesnapshot.", pvc.Namespace, pvc.Name)
Expand Down

0 comments on commit 40d2b08

Please sign in to comment.