[Azure] Store the resource group for volumes during snapshot
Use it during restore so that it can be restored across resource groups
@@ -210,6 +210,9 @@ func (a *azure) StartBackup(backup *storkapi.ApplicationBackup,
volumeInfo.PersistentVolumeClaim = pvc.Name
volumeInfo.Namespace = pvc.Namespace
volumeInfo.DriverName = driverName
+ volumeInfo.Options = map[string]string{
+ resourceGroupKey: a.resourceGroup,
+ }
volumeInfos = append(volumeInfos, volumeInfo)
pvName, err := k8s.Instance().GetVolumeForPersistentVolumeClaim(&pvc)
@@ -331,7 +334,15 @@ func (a *azure) StartRestore(
volumeInfos := make([]*storkapi.ApplicationRestoreVolumeInfo, 0)
for _, backupVolumeInfo := range volumeBackupInfos {
- snapshot, err := a.snapshotClient.Get(context.TODO(), a.resourceGroup, backupVolumeInfo.BackupID)
+ var resourceGroup string
+ if val, present := backupVolumeInfo.Options[resourceGroupKey]; present {
+ resourceGroup = val
+ } else {
+ resourceGroup = a.resourceGroup
+ logrus.Warnf("missing resource group in snapshot %v, will use current resource group", backupVolumeInfo.BackupID)
+ }
+
+ snapshot, err := a.snapshotClient.Get(context.TODO(), resourceGroup, backupVolumeInfo.BackupID)
if err != nil {
return nil, err
}
