get resource client again after restore actions in case resource's gv is changed

Signed-off-by: lou <alex1988@outlook.com>
This commit is contained in:
lou
2023-08-10 18:46:14 +08:00
parent a88cb465a4
commit 1784f63b93

View File

@@ -1368,7 +1368,8 @@ func (ctx *restoreContext) restoreItem(obj *unstructured.Unstructured, groupReso
// The object apiVersion might get modified by a RestorePlugin so we need to
// get a new client to reflect updated resource path.
resourceClient, err = ctx.getResourceClient(groupResource, obj, namespace)
newGR := schema.GroupResource{Group: obj.GroupVersionKind().Group, Resource: groupResource.Resource}
resourceClient, err = ctx.getResourceClient(newGR, obj, obj.GetNamespace())
if err != nil {
errs.AddVeleroError(fmt.Errorf("error getting updated resource client for namespace %q, resource %q: %v", namespace, &groupResource, err))
return warnings, errs, itemExists