Remove finalizers from backups before syncing

Signed-off-by: Nolan Brubaker <nolan@heptio.com>
This commit is contained in:
Nolan Brubaker
2018-04-18 17:32:39 -04:00
parent 1f6b496f5e
commit 300a010959
3 changed files with 28 additions and 0 deletions
@@ -27,6 +27,7 @@ import (
"github.com/heptio/ark/pkg/apis/ark/v1"
"github.com/heptio/ark/pkg/generated/clientset/versioned/fake"
"github.com/heptio/ark/pkg/util/stringslice"
arktest "github.com/heptio/ark/pkg/util/test"
)
@@ -51,6 +52,18 @@ func TestBackupSyncControllerRun(t *testing.T) {
arktest.NewTestBackup().WithNamespace("ns-2").WithName("backup-3").Backup,
},
},
{
name: "Finalizer gets removed on sync",
cloudBackups: []*v1.Backup{
arktest.NewTestBackup().WithNamespace("ns-1").WithFinalizers(gcFinalizer).Backup,
},
},
{
name: "Only target finalizer is removed",
cloudBackups: []*v1.Backup{
arktest.NewTestBackup().WithNamespace("ns-1").WithFinalizers(gcFinalizer, "blah").Backup,
},
},
}
for _, test := range tests {
@@ -77,6 +90,8 @@ func TestBackupSyncControllerRun(t *testing.T) {
// we only expect creates for items within the target bucket
for _, cloudBackup := range test.cloudBackups {
// Verify that the run function stripped the GC finalizer
assert.False(t, stringslice.Has(cloudBackup.Finalizers, gcFinalizer))
action := core.NewCreateAction(
v1.SchemeGroupVersion.WithResource("backups"),
cloudBackup.Namespace,