mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-08-15 11:46:06 +00:00
Enable restoring resources with ownerReference set
Signed-off-by: Michal Wieczorek <wieczorek-michal@wp.pl>
This commit is contained in:
@@ -472,6 +472,7 @@ var defaultRestorePriorities = []string{
|
||||
"serviceaccounts",
|
||||
"limitranges",
|
||||
"pods",
|
||||
"replicaset",
|
||||
}
|
||||
|
||||
// watchConfig adds an update event handler to the Config shared informer, invoking s.cancelFunc
|
||||
|
||||
@@ -617,15 +617,6 @@ func (ctx *context) restoreResource(resource, namespace, resourcePath string) (a
|
||||
continue
|
||||
}
|
||||
|
||||
if hasControllerOwner(obj.GetOwnerReferences()) {
|
||||
// non-pods with controller owners shouldn't be restored; pods with controller
|
||||
// owners should only be restored if they have restic snapshots to restore
|
||||
if groupResource != kuberesource.Pods || !restic.PodHasSnapshotAnnotation(obj) {
|
||||
ctx.log.Infof("%s has a controller owner - skipping", kube.NamespaceAndName(obj))
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
complete, err := isCompleted(obj, groupResource)
|
||||
if err != nil {
|
||||
addToResult(&errs, namespace, fmt.Errorf("error checking completion %q: %v", fullPath, err))
|
||||
|
||||
@@ -433,16 +433,6 @@ func TestRestoreResourceForNamespace(t *testing.T) {
|
||||
labelSelector: labels.SelectorFromSet(labels.Set(map[string]string{"foo": "not-bar"})),
|
||||
fileSystem: arktest.NewFakeFileSystem().WithFile("configmaps/cm-1.json", newTestConfigMap().WithLabels(map[string]string{"foo": "bar"}).ToJSON()),
|
||||
},
|
||||
{
|
||||
name: "items with controller owner are skipped",
|
||||
namespace: "ns-1",
|
||||
resourcePath: "configmaps",
|
||||
labelSelector: labels.NewSelector(),
|
||||
fileSystem: arktest.NewFakeFileSystem().
|
||||
WithFile("configmaps/cm-1.json", newTestConfigMap().WithControllerOwner().ToJSON()).
|
||||
WithFile("configmaps/cm-2.json", newNamedTestConfigMap("cm-2").ToJSON()),
|
||||
expectedObjs: toUnstructured(newNamedTestConfigMap("cm-2").ConfigMap),
|
||||
},
|
||||
{
|
||||
name: "namespace is remapped",
|
||||
namespace: "ns-2",
|
||||
|
||||
Reference in New Issue
Block a user