Sending existing object to the webhook for the DELETE verb#76346
Sending existing object to the webhook for the DELETE verb#76346k8s-ci-robot merged 4 commits intokubernetes:masterfrom
Conversation
390f260 to
744bf2a
Compare
744bf2a to
8e93456
Compare
test/e2e/apimachinery/webhook.go
Outdated
There was a problem hiding this comment.
This is a duplicate of line 183.
8a3bd0f to
35c38f7
Compare
There was a problem hiding this comment.
This might be controversial.
There was a problem hiding this comment.
this is interesting. wouldn't malformed data in etcd also prevent us from listing and finding out what the problematic key was? I'm trying to understand if this special handling actually enables us to resolve the issue, or if it's just a step in that direction.
There was a problem hiding this comment.
Good point. The error message send by the LIST handler does include the key:
So this special handling enables us to resolve the issue.
6bafd02 to
f6b94b4
Compare
|
/retest |
|
/unassign |
Somehow the rv goes backwards in this code block: https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/apiserver/pkg/registry/generic/registry/store.go#L873-L909. |
|
Any chance to squash this into logical pieces for easier review? |
There was a problem hiding this comment.
I had to add a specific delete test for CRD, because like namespaces, apiserver does not delete CRD on an update that removes the last pending finalizer.
There was a problem hiding this comment.
should it? that seems like the same bug as the one you fixed in storage
There was a problem hiding this comment.
CRD storage doesn't override Update, and only changes Delete behavior on first delete... I don't think it should require a custom test method (I'd expect removing finalizers on update of a CRD with a deletiontimestamp set to actually delete)
There was a problem hiding this comment.
I removed the commit that modified shouldDeleteDuringUpdate. The function returns false unless the DeletionGracePeriodSeconds was set on the first Delete. CRD storage doesn't set the DeletionGracePeriodSeconds.
I removed my previous fix to shouldDeleteDuringUpdate because that would make Namespaces misbehave.
I tracked the issue in #77944. We can solve it in a followup.
There was a problem hiding this comment.
This matches the existing behavior:
kubernetes/staging/src/k8s.io/apiserver/pkg/storage/etcd3/store_test.go
Lines 743 to 750 in 08afeb8
|
/retest |
There was a problem hiding this comment.
Is it better to skip validateDeletion or call it with a nil object? Currently, delete admission is always called, regardless of transform error, with a nil oldObject. would it be preferable to continue calling delete admission with a nil oldObject in the case of a transform error over skipping it entirely?
There was a problem hiding this comment.
I can't decide which bothers me more, giving an inconsistent API to admission consumers (sometimes getting a nil oldObject in a delete admission call), skipping delete admission entirely, or requiring talking to etcd to delete a malformed value.
Will CRD webhook conversion errors and KMS transform errors exercise this path? I'm not sure I'd want to abandon calling admission if an external system like that flakes.
There was a problem hiding this comment.
Indeed the KMS transform is part of the transformer stack:
I'll trace the CRD webhook path later.
[update] CRD webhook conversion is plumbed to the storage codec, not as a transformer. See code.
There was a problem hiding this comment.
Among all the options, "giving an inconsistent API to admission consumers" seems to be the lesser of the evils.
I added the last commit to send nil objects to validateDelete.
There was a problem hiding this comment.
Discussed offline. since we already have to look up the existing object in the REST handler to verify there are no remaining finalizers, a persistent transform error is already blocking, and we'll never make it here. Continuing to simply return if we encounter a transform error (rather than skipping admission or passing a nil object) is no worse than the current state, and lets us give a consistent API to admission authors.
There was a problem hiding this comment.
Let's drop the transformation error changes from this PR to keep it focused on passing existing objects to delete admission
There was a problem hiding this comment.
also return if origState is nil, since we don't have the rev info to use later
There was a problem hiding this comment.
Added a return after the error checks.
There was a problem hiding this comment.
CRD storage doesn't override Update, and only changes Delete behavior on first delete... I don't think it should require a custom test method (I'd expect removing finalizers on update of a CRD with a deletiontimestamp set to actually delete)
|
/retest |
|
/lgtm needs a rebase since #77952 merged |
validate deletion admission object backward compatibility: add validation for direct storage delete calls apply nil validation to existing tests revert behavior changes in deleteCollection call fixes validation on wiring graceful deletion remove nil validation check continue admission check on not found error
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.
|
/retest |
1 similar comment
|
/retest |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: caesarxuchao, liggitt The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
awesome! 🎉 |
|
included in docs PR for 1.15 at kubernetes/website#14671 |
|
/area admission-control |
Based on #66535, with these major changes:
/assign
/sig api-machinery
/kind bug