Enable restoring resources with ownerReference set

Signed-off-by: Michal Wieczorek <wieczorek-michal@wp.pl>
This commit is contained in:
Michal Wieczorek
2018-10-02 12:04:51 +02:00
parent 94b8fae15a
commit 0f1c5c283f
3 changed files with 1 additions and 19 deletions
+1
View File
@@ -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
-9
View File
@@ -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))
-10
View File
@@ -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",