diff --git a/pkg/registry/core/namespace/storage/storage.go b/pkg/registry/core/namespace/storage/storage.go index b64a4f4abb0..ac75a9d5dec 100644 --- a/pkg/registry/core/namespace/storage/storage.go +++ b/pkg/registry/core/namespace/storage/storage.go @@ -238,8 +238,7 @@ func (r *REST) Delete(ctx context.Context, name string, deleteValidation rest.Va // prior to final deletion, we must ensure that finalizers is empty if len(namespace.Spec.Finalizers) != 0 { - err = apierrors.NewConflict(api.Resource("namespaces"), namespace.Name, fmt.Errorf("The system is ensuring all content is removed from this namespace. Upon completion, this namespace will automatically be purged by the system.")) - return nil, false, err + return namespace, false, nil } return r.store.Delete(ctx, name, deleteValidation, options) } diff --git a/pkg/registry/core/namespace/storage/storage_test.go b/pkg/registry/core/namespace/storage/storage_test.go index 61e3dedee78..ace116a406c 100644 --- a/pkg/registry/core/namespace/storage/storage_test.go +++ b/pkg/registry/core/namespace/storage/storage_test.go @@ -165,12 +165,18 @@ func TestDeleteNamespaceWithIncompleteFinalizers(t *testing.T) { if err := storage.store.Storage.Create(ctx, key, namespace, nil, 0, false); err != nil { t.Fatalf("unexpected error: %v", err) } - if _, _, err := storage.Delete(ctx, "foo", rest.ValidateAllObjectFunc, nil); err == nil { - t.Errorf("unexpected no error") + obj, immediate, err := storage.Delete(ctx, "foo", rest.ValidateAllObjectFunc, nil) + if err != nil { + t.Fatalf("unexpected error") + } + if immediate { + t.Fatalf("unexpected immediate flag") + } + if ns, ok := obj.(*api.Namespace); !ok || obj == nil || ns == nil || ns.Name != namespace.Name { + t.Fatalf("object not returned by delete") } // should still exist - _, err := storage.Get(ctx, "foo", &metav1.GetOptions{}) - if err != nil { + if _, err := storage.Get(ctx, "foo", &metav1.GetOptions{}); err != nil { t.Errorf("unexpected error: %v", err) } }