-
Notifications
You must be signed in to change notification settings - Fork 40k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CEL Admission Plugin #112858
CEL Admission Plugin #112858
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pointing out some things maybe others can illuminate for me
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/admission.go
Outdated
Show resolved
Hide resolved
/sig api-machinery |
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/admission.go
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some discussion points
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/generic/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/generic/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/interface.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/controller.go
Outdated
Show resolved
Hide resolved
} | ||
|
||
if len(allDecisions) > 0 { | ||
return errors.New("deny") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe future work, but we want to ultimately be able to respond with message(s), and a status and code here like webhooks do. The response back to the client request (the one being validated for admission) should use the status and code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This brings up a question I didn't fully cover in the KEP:
When multiple policy definition validations deny admission, which status and code are returned? The alternatives I'm aware of:
- Agree on an order of precedent of http response codes, use the "most severe" code
- Use the code of whatever policy fails first
If we go with (2) we need to make sure we validate policies (and bindings) in a consistent order. But I would love to see (1) work, I just haven't thought it through carefully enough to know if there is a sane ordering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we only return one status/code back, do we include all validation failures in messages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was assuming if, for any reason, any validation is a Deny
, then the response code is unconditionally 409 Conflict
. Should policy definitions be able to control the HTTP status code? Are there other codes that one might choose?
Re: returning multiple errors. I believe we can return a JSON-formatted error string with some metadata like web hooks do. In this case we can return an JSON array with an entry for each validation that failed where the requestor can look for more information.
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/generic/controller.go
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The interface generally looks good to me. Thank you!
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/controller.go
Outdated
Show resolved
Hide resolved
} | ||
|
||
if len(allDecisions) > 0 { | ||
return errors.New("deny") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we only return one status/code back, do we include all validation failures in messages?
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/interface.go
Outdated
Show resolved
Hide resolved
ec09b77
to
1eb00eb
Compare
b0659fb
to
aec92bb
Compare
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/controller.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/admission.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/admission.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/policy_decision.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiserver/pkg/admission/plugin/cel/internal/generic/doc.go
Outdated
Show resolved
Hide resolved
/approve |
aec92bb
to
3336168
Compare
3336168
to
8b74e73
Compare
/approve |
/priority important-soon |
/retest |
@alexzielenski: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/retest |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alexzielenski, jpbetz, lavalamp The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
What type of PR is this?
/kind feature
What this PR does / why we need it:
This PR is a core dependency of other incoming CEL PRs implementing various bits of functionality from the KEP.
This PR adds support for consuming CEL policy definitions and policy bindings to enforce validation constraints on objects. It also defines interfaces for those types to implement with their CEL data source.
It is not yet integrated or hooked into anything yet. Is only expected to pass its tests for now until the other parts of the feature merge.
83% test coverage in the
cel
packageWhich issue(s) this PR fixes:
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
/cc @cici37 @jpbetz @DangerOnTheRanger @jiahuif