restore flow changes

Signed-off-by: Anshul Ahuja <anshulahuja@microsoft.com>
This commit is contained in:
Anshul Ahuja
2023-07-03 13:48:24 +05:30
parent 9ea54c81fe
commit 5424b07bb3
2 changed files with 11 additions and 0 deletions

View File

@@ -48,6 +48,7 @@ import (
"github.com/vmware-tanzu/velero/internal/credentials"
"github.com/vmware-tanzu/velero/internal/hook"
"github.com/vmware-tanzu/velero/internal/resourcemodifiers"
velerov1api "github.com/vmware-tanzu/velero/pkg/apis/velero/v1"
"github.com/vmware-tanzu/velero/pkg/archive"
"github.com/vmware-tanzu/velero/pkg/client"
@@ -305,6 +306,7 @@ func (kr *kubernetesRestorer) RestoreWithResolvers(
hooksCancelFunc: hooksCancelFunc,
kbClient: kr.kbClient,
itemOperationsList: req.GetItemOperationsList(),
resourceModifiers: req.ResourceModifiers,
}
return restoreCtx.execute()
@@ -350,6 +352,7 @@ type restoreContext struct {
hooksCancelFunc go_context.CancelFunc
kbClient crclient.Client
itemOperationsList *[]*itemoperation.RestoreOperation
resourceModifiers *resourcemodifiers.ResourceModifiers
}
type resourceClientKey struct {
@@ -1340,6 +1343,12 @@ func (ctx *restoreContext) restoreItem(obj *unstructured.Unstructured, groupReso
// and which backup they came from.
addRestoreLabels(obj, ctx.restore.Name, ctx.restore.Spec.BackupName)
if ctx.resourceModifiers != nil {
if err := ctx.resourceModifiers.ApplyResourceModifierRules(obj, ctx.log); err != nil {
errs.Add(namespace, err)
}
}
ctx.log.Infof("Attempting to restore %s: %v", obj.GroupVersionKind().Kind, name)
createdObj, restoreErr := resourceClient.Create(obj)
if restoreErr == nil {