mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-11-02 14:51:58 +00:00
Run deleteValidation at the storage layer so that it will be retried on
conflict. Adding unit test verify that deleteValidation is retried. adding e2e test verifying the webhook can intercept configmap and custom resource deletion, and the existing object is sent via the admissionreview.OldObject. update the admission integration test to verify that the existing object is passed to the deletion admission webhook as oldObject, in case of an immediate deletion and in case of an update-on-delete.
This commit is contained in:
@@ -162,10 +162,6 @@ func (r *REST) Delete(ctx context.Context, name string, deleteValidation rest.Va
|
||||
// upon first request to delete, we switch the phase to start namespace termination
|
||||
// TODO: enhance graceful deletion's calls to DeleteStrategy to allow phase change and finalizer patterns
|
||||
if namespace.DeletionTimestamp.IsZero() {
|
||||
if err := deleteValidation(nsObj); err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
|
||||
key, err := r.store.KeyFunc(ctx, name)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
@@ -182,6 +178,9 @@ func (r *REST) Delete(ctx context.Context, name string, deleteValidation rest.Va
|
||||
// wrong type
|
||||
return nil, fmt.Errorf("expected *api.Namespace, got %v", existing)
|
||||
}
|
||||
if err := deleteValidation(existingNamespace); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Set the deletion timestamp if needed
|
||||
if existingNamespace.DeletionTimestamp.IsZero() {
|
||||
now := metav1.Now()
|
||||
|
||||
@@ -163,7 +163,7 @@ func TestDeleteNamespaceWithIncompleteFinalizers(t *testing.T) {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if _, _, err := storage.Delete(ctx, "foo", rest.ValidateAllObjectFunc, nil); err == nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
t.Errorf("unexpected no error")
|
||||
}
|
||||
// should still exist
|
||||
_, err := storage.Get(ctx, "foo", &metav1.GetOptions{})
|
||||
@@ -578,7 +578,7 @@ func TestDeleteWithGCFinalizers(t *testing.T) {
|
||||
}
|
||||
var obj runtime.Object
|
||||
var err error
|
||||
if obj, _, err = storage.Delete(ctx, test.name, test.deleteOptions); err != nil {
|
||||
if obj, _, err = storage.Delete(ctx, test.name, rest.ValidateAllObjectFunc, test.deleteOptions); err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
ns, ok := obj.(*api.Namespace)
|
||||
|
||||
Reference in New Issue
Block a user