Change:
} } <ins> func TestDeleteWithGCFinalizers(t *testing.T) { storage, server := newStorage(t) defer server.Terminate(t) defer storage.store.DestroyFunc() propagationBackground := metav1.DeletePropagationBackground propagationForeground := metav1.DeletePropagationForeground propagationOrphan := metav1.DeletePropagationOrphan trueVar := true var tests = []struct { name          string deleteOptions *metav1.DeleteOptions existingFinalizers  []string remainingFinalizers map[string]bool }{ { name:          "nil-with-orphan", deleteOptions: nil, existingFinalizers: []string{ metav1.FinalizerOrphanDependents, }, remainingFinalizers: map[string]bool{ metav1.FinalizerOrphanDependents: true, }, }, { name:          "nil-with-delete", deleteOptions: nil, existingFinalizers: []string{ metav1.FinalizerDeleteDependents, }, remainingFinalizers: map[string]bool{ metav1.FinalizerDeleteDependents: true, }, }, { name:                "nil-without-finalizers", deleteOptions:       nil, existingFinalizers:  []string{}, remainingFinalizers: map[string]bool{}, }, { name: "propagation-background-with-orphan", deleteOptions: &metav1.DeleteOptions{ PropagationPolicy: &propagationBackground, }, existingFinalizers: []string{ metav1.FinalizerOrphanDependents, }, remainingFinalizers: map[string]bool{}, }, { name: "propagation-background-with-delete", deleteOptions: &metav1.DeleteOptions{ PropagationPolicy: &propagationBackground, }, existingFinalizers: []string{ metav1.FinalizerDeleteDependents, }, remainingFinalizers: map[string]bool{}, }, { name: "propagation-background-without-finalizers", deleteOptions: &metav1.DeleteOptions{ PropagationPolicy: &propagationBackground, }, existingFinalizers:  []string{}, remainingFinalizers: map[string]bool{}, }, { name: "propagation-foreground-with-orphan", deleteOptions: &metav1.DeleteOptions{ PropagationPolicy: &propagationForeground, }, existingFinalizers: []string{ metav1.FinalizerOrphanDependents, }, remainingFinalizers: map[string]bool{ metav1.FinalizerDeleteDependents: true, }, }, { name: "propagation-foreground-with-delete", deleteOptions: &metav1.DeleteOptions{ PropagationPolicy: &propagationForeground, }, existingFinalizers: []string{ metav1.FinalizerDeleteDependents, }, remainingFinalizers: map[string]bool{ metav1.FinalizerDeleteDependents: true, }, }, { name: "propagation-foreground-without-finalizers", deleteOptions: &metav1.DeleteOptions{ PropagationPolicy: &propagationForeground, }, existingFinalizers: []string{}, remainingFinalizers: map[string]bool{ metav1.FinalizerDeleteDependents: true, }, }, { name: "propagation-orphan-with-orphan", deleteOptions: &metav1.DeleteOptions{ PropagationPolicy: &propagationOrphan, }, existingFinalizers: []string{ metav1.FinalizerOrphanDependents, }, remainingFinalizers: map[string]bool{ metav1.FinalizerOrphanDependents: true, }, }, { name: "propagation-orphan-with-delete", deleteOptions: &metav1.DeleteOptions{ PropagationPolicy: &propagationOrphan, }, existingFinalizers: []string{ metav1.FinalizerDeleteDependents, }, remainingFinalizers: map[string]bool{ metav1.FinalizerOrphanDependents: true, }, }, { name: "propagation-orphan-without-finalizers", deleteOptions: &metav1.DeleteOptions{ PropagationPolicy: &propagationOrphan, }, existingFinalizers: []string{}, remainingFinalizers: map[string]bool{ metav1.FinalizerOrphanDependents: true, }, }, { name: "orphan-dependents-with-orphan", deleteOptions: &metav1.DeleteOptions{ OrphanDependents: &trueVar, }, existingFinalizers: []string{ metav1.FinalizerOrphanDependents, }, remainingFinalizers: map[string]bool{ metav1.FinalizerOrphanDependents: true, }, }, { name: "orphan-dependents-with-delete", deleteOptions: &metav1.DeleteOptions{ OrphanDependents: &trueVar, }, existingFinalizers: []string{ metav1.FinalizerDeleteDependents, }, remainingFinalizers: map[string]bool{ metav1.FinalizerOrphanDependents: true, }, }, { name: "orphan-dependents-without-finalizers", deleteOptions: &metav1.DeleteOptions{ OrphanDependents: &trueVar, }, existingFinalizers: []string{}, remainingFinalizers: map[string]bool{ metav1.FinalizerOrphanDependents: true, }, }, } for _, test := range tests { key := "namespaces/" + test.name ctx := genericapirequest.NewContext() namespace := &api.Namespace{ ObjectMeta: metav1.ObjectMeta{ Name:       test.name, Finalizers: test.existingFinalizers, }, Spec: api.NamespaceSpec{ Finalizers: []api.FinalizerName{}, }, Status: api.NamespaceStatus{Phase: api.NamespaceActive}, } if err := storage.store.Storage.Create(ctx, key, namespace, nil, 0, false); err != nil { t.Fatalf("unexpected error: %v", err) } var obj runtime.Object var err error if obj, _, err = storage.Delete(ctx, test.name, test.deleteOptions); err != nil { t.Fatalf("unexpected error: %v", err) } ns, ok := obj.(*api.Namespace) if !ok { t.Errorf("unexpected object kind: %+v", obj) } if len(ns.Finalizers) != len(test.remainingFinalizers) { t.Errorf("%s: unexpected remaining finalizers: %v", test.name, ns.Finalizers) } for _, f := range ns.Finalizers { if test.remainingFinalizers[f] != true { t.Errorf("%s: unexpected finalizer %s", test.name, f) } } } } </ins> func TestShortNames(t *testing.T) { storage, server := newStorage(t) defer server.Terminate(t)

Discussion:
What happened: I created a namespace with finalizer, and then tried to delete it: The namespace can be deleted, and the finalizer is removed by garbage collection controller: What you expected to happen: Since kubectl species , it is not an orphaning operation, the finalizer should be removed in namespace store. How to reproduce it (as minimally and precisely as possible): Same as what I observed: a namespace. finalizer. . Anything else we need to know?: Environment: Kubernetes version (use ): HEAD
/sig api-machinery
cc
Discussion on slack: