Repository navigation
Conversation
The API server sends a DELETE with the deleted object as the old object and no object. Validate dropped every request without an object, so every DELETE was dropped before any rule saw it, although the chart subscribes the webhook to DELETE for pods and RBAC objects and the CEL event exposes the deleted object as oldObject. A rule on event.Operation == "DELETE" never fired. Only drop a request that has neither an object nor an old object, and look rules up for the old object when there is no new one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: itsvishalyadav <vishalyadav87695@gmail.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 55 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
matthyx
approved these changes
Nov 10, 2026
matthyx
left a comment
Contributor
There was a problem hiding this comment.
Approve — reviewed head f21415a against main @ 47e9ae6.
- Need: confirmed. On main,
Validatedrops every request withGetObject()==nil, which is all DELETEs (API server sends the deleted object as old object only), although the webhook subscribes to DELETE andcel/event.goexposesoldObject. Fixes #490; I found no duplicate or previously rejected PRs touching this. - Soundness: the guard now only drops when both object and old object are nil, and
evaluatefalls back to the old object for rule lookup. Downstream (cel/event.go,rules/cel/evaluator.go,v1/helpers.go) already nil-checksGetObject(). Pod DELETE (KindPod) takes the same branch; the non-Podpodssubresource path is unchanged. CREATE/UPDATE/CONNECT behave as before. - Validation:
go test ./admission/webhook/ -run TestValidatorpasses on the PR. Withvalidator.goreverted to base, the newTestValidator_DeleteIsEvaluatedWithTheDeletedObjectfails ("never reached rule evaluation"), so the test is a real regression test. CI: build, DCO, CodeQL, GitGuardian pass; Basic-Test was still running when I checked. Not run on a live cluster. - Blockers: none. Nonblocking: rules that use
event.Objectnow see it nil on DELETE (expected; they should useoldObject).
6 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This PR fixes #490
Signed Commits
The API server sends a DELETE with the deleted object as the old object and no object.
Validatedropped every request without an object, so every DELETE was dropped before any rule saw it, although the chart subscribes the webhook to DELETE for pods and RBAC objects and the CEL event already exposes the deleted object asoldObject. A rule onevent.Operation == "DELETE"never fired.Validatenow only drops a request that has neither an object nor an old object.evaluatelooks rules up for the old object when there is no new one.NewAdmissionCelEvent, the alert builder and the v1 rule helpers already checkGetObject()for nil, so nothing downstream needs to change. CREATE, UPDATE and CONNECT are handled as before.How to Test
The new
TestValidator_DeleteIsEvaluatedWithTheDeletedObjectsends a DELETE of a ClusterRoleBinding (old object only) throughValidateand waits for rule evaluation. On main it fails withthe DELETE request never reached rule evaluation; with the fix the rules are looked up for the deletedadminsbinding. The existingTestValidator_NilObjectIsDropped(no object and no old object) still passes.go test ./admission/webhook/ -skip TestRun_ReloadsSecretSymlinkSwap -count=1passes (that test needs symlinks and fails on Windows on main too),go test ./admission/cel/... ./admission/rules/... -count=1passes, andgofmt,goimports,go vetandgolangci-lintreport nothing new. I haven't run it on a live cluster.Checklist before requesting a review
🤖 Generated with Claude Code