From 50d0f01d864ba59e15294968fdead3a32311ac41 Mon Sep 17 00:00:00 2001 From: tamal Date: Sat, 21 Apr 2018 09:26:58 -0700 Subject: [PATCH] Always register finalizer for Repository --- pkg/controller/repository.go | 15 ++++++--------- pkg/util/kubernetes.go | 4 ++-- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/pkg/controller/repository.go b/pkg/controller/repository.go index db779dbf7..3d6262266 100644 --- a/pkg/controller/repository.go +++ b/pkg/controller/repository.go @@ -69,17 +69,14 @@ func (c *StashController) runRepositoryInjector(key string) error { in.ObjectMeta = core_util.RemoveFinalizer(in.ObjectMeta, util.RepositoryFinalizer) return in }) - if err != nil { - return err - } + return err } } else { - if repo.Spec.WipeOut { - _, _, err = stash_util.PatchRepository(c.stashClient.StashV1alpha1(), repo, func(in *api.Repository) *api.Repository { - in.ObjectMeta = core_util.AddFinalizer(in.ObjectMeta, util.RepositoryFinalizer) - return in - }) - } + _, _, err = stash_util.PatchRepository(c.stashClient.StashV1alpha1(), repo, func(in *api.Repository) *api.Repository { + in.ObjectMeta = core_util.AddFinalizer(in.ObjectMeta, util.RepositoryFinalizer) + return in + }) + return err } } return nil diff --git a/pkg/util/kubernetes.go b/pkg/util/kubernetes.go index 46b66320e..70f13a006 100644 --- a/pkg/util/kubernetes.go +++ b/pkg/util/kubernetes.go @@ -44,7 +44,7 @@ const ( AppLabelStash = "stash" OperationScaleDown = "scale-down" - RepositoryFinalizer = "wipeOut-repository" + RepositoryFinalizer = "stash" SnapshotIDLength = 8 SnapshotIDLengthWithDashPrefix = 9 ) @@ -584,9 +584,9 @@ func FixBackendPrefix(backend *api.Backend, autoPrefix string) *api.Backend { backend.B2.Prefix = strings.TrimSuffix(backend.B2.Prefix, autoPrefix) backend.B2.Prefix = strings.TrimSuffix(backend.B2.Prefix, "/") } - return backend } + func GetBucketAndPrefix(backend *api.Backend) (string, string, error) { if backend.S3 != nil { return backend.S3.Bucket, strings.TrimPrefix(backend.S3.Prefix, backend.S3.Bucket+"/"), nil