-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
KEP-4008: CRDValidationRatcheting: Ratchet errors from CEL expressions if old
DeepEqual new
#121016
KEP-4008: CRDValidationRatcheting: Ratchet errors from CEL expressions if old
DeepEqual new
#121016
Conversation
Skipping CI for Draft Pull Request. |
5522aa6
to
543f8d3
Compare
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.
Mostly looks good so far.
staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/validation/ratcheting.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/validation.go
Outdated
Show resolved
Hide resolved
543f8d3
to
d8df5a1
Compare
staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/validation_test.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiextensions-apiserver/test/integration/ratcheting_test.go
Outdated
Show resolved
Hide resolved
/triage accepted |
ce9c864
to
519b7ed
Compare
schema: mustSchema(` | ||
type: object | ||
properties: | ||
foo: | ||
type: string | ||
x-kubernetes-validations: | ||
- rule: self == "bar" | ||
message: "gotta be baz" | ||
`), |
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 looks so beautiful, tabsdiedie is proud of you
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.
Ah, is this a Scala stripMargin equivalent? Nice. I'd really like to have a general purpose one of these in a util package at some point (but this is great for now).
- bar: bar | ||
`), | ||
warnings: []string{ | ||
`root[0].bar: Invalid value: "string": gotta be baz`, |
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.
Unrelated and not an action, but what is this
invalid value: "string": gotta be baz
// instead of
invalid value: "bar": gotta be baz
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've always wondered that. It is a curiosity of how our forked openapi validator in kube-openapi generates errors :)
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.
Yeah, I guess it's a string indeed, cool ...
/lgtm |
LGTM label has been added. Git tree hash: b57b5ade299652c9ac34f428ef727e31aebb5ef1
|
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.
minor nit
staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/validation.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/validation.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/validation.go
Outdated
Show resolved
Hide resolved
schema: mustSchema(` | ||
type: object | ||
properties: | ||
foo: | ||
type: string | ||
x-kubernetes-validations: | ||
- rule: self == "bar" | ||
message: "gotta be baz" | ||
`), |
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.
Ah, is this a Scala stripMargin equivalent? Nice. I'd really like to have a general purpose one of these in a util package at some point (but this is great for now).
name: "ratchet error triggered by normal CEL expression from an uncorrelatable part of the schema if one of its parent nodes is totally unchanged", | ||
schema: mustSchema(` | ||
type: array | ||
x-kubernetes-list-type: atomic |
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.
nit: Can we also get one test using x-kubernetes-list-type: atomic
(I'm confident it will pass, I mostly want it for regression prevention)? It can be a copy-paste of an atomic one..
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.
Did you mean x-kubernetes-list-type: set
? Either way, I noticed it wasnt included, and added some more cases, as well as some maplist and nested map cases.
staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/cel/validation.go
Outdated
Show resolved
Hide resolved
519b7ed
to
f075f4c
Compare
f075f4c
to
7840f8e
Compare
7840f8e
to
6d580da
Compare
/retest |
/approve |
LGTM label has been added. Git tree hash: 2ef307349d17924e738faa0f405074e8949befb8
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alexzielenski, jpbetz 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 |
old
DeepEqual new
old
DeepEqual new
Changelog suggestion ℹ️ should get a technical check before making the change Added ratcheting (behind `CRDValidationRatcheting` feature gate) to tolerate `x-kubernetes-validations` errors when the old resource was equal - `reflect.DeepEqual()` - to the new object. |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Adds support for CEL expressions to CRDValidationRatcheting as part of beta. This is NOT the "Advanced CEL Ratcheting" part of the KEP. This is an implementation of standard ratcheting for CEL rules when
old
is DeepEqual tonew
.Factors out the correlation and comparison bits from the schema ratcheting code into a reusable type so that it can be shared with CEL implementation without much ripple
Which issue(s) this PR fixes:
None
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
/sig api-machinery
/assign @apelisse
/cc @sttts @cici37