diff --git a/pkg/backup/item_backupper.go b/pkg/backup/item_backupper.go index 8c907a67a2a..2e0fdf12ae2 100644 --- a/pkg/backup/item_backupper.go +++ b/pkg/backup/item_backupper.go @@ -147,6 +147,9 @@ func (ib *defaultItemBackupper) backupItem(logger logrus.FieldLogger, obj runtim return nil } + if metadata.GetDeletionTimestamp() != nil { + return nil + } key := itemKey{ resource: groupResource.String(), namespace: namespace, diff --git a/pkg/backup/item_backupper_test.go b/pkg/backup/item_backupper_test.go index a172c83e91d..0363772eb37 100644 --- a/pkg/backup/item_backupper_test.go +++ b/pkg/backup/item_backupper_test.go @@ -48,6 +48,7 @@ func TestBackupItemSkips(t *testing.T) { namespaces *collections.IncludesExcludes groupResource schema.GroupResource resources *collections.IncludesExcludes + terminating bool backedUpItems map[itemKey]struct{} }{ { @@ -89,6 +90,15 @@ func TestBackupItemSkips(t *testing.T) { {resource: "bar.foo", namespace: "ns", name: "foo"}: {}, }, }, + { + testName: "terminating resource", + namespace: "ns", + name: "foo", + groupResource: schema.GroupResource{Group: "foo", Resource: "bar"}, + namespaces: collections.NewIncludesExcludes(), + resources: collections.NewIncludesExcludes(), + terminating: true, + }, } for _, test := range tests { @@ -99,7 +109,12 @@ func TestBackupItemSkips(t *testing.T) { backedUpItems: test.backedUpItems, } - u := unstructuredOrDie(fmt.Sprintf(`{"apiVersion":"v1","kind":"Pod","metadata":{"namespace":"%s","name":"%s"}}`, test.namespace, test.name)) + var deletionTimestamp string + + if test.terminating { + deletionTimestamp = `, "deletionTimestamp": "2018-05-30T13:30:34Z"` + } + u := unstructuredOrDie(fmt.Sprintf(`{"apiVersion":"v1","kind":"Pod","metadata":{"namespace":"%s","name":"%s" %s}}`, test.namespace, test.name, deletionTimestamp)) err := ib.backupItem(arktest.NewLogger(), u, test.groupResource) assert.NoError(t, err) })