Enable restoring resources with ownerReference set

Signed-off-by: Michal Wieczorek <wieczorek-michal@wp.pl>
This commit is contained in:
Michal Wieczorek
2018-09-11 13:41:03 +02:00
committed by Steve Kriss
parent ccfef26ef3
commit 226a687c01
3 changed files with 1 additions and 19 deletions

View File

@@ -381,6 +381,7 @@ var defaultResourcePriorities = []string{
"serviceaccounts",
"limitranges",
"pods",
"replicaset",
}
func applyConfigDefaults(c *api.Config, logger logrus.FieldLogger) {

View File

@@ -631,15 +631,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.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))

View File

@@ -432,16 +432,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").WithArkLabel("my-restore").ConfigMap),
},
{
name: "namespace is remapped",
namespace: "ns-2",