Skip to content
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-4153: Declarative Validation Proposal and Design #4163

Merged

Conversation

alexzielenski
Copy link
Contributor

@alexzielenski alexzielenski commented Aug 28, 2023

  • One-line PR description: Replaces handwritten validation of internal native types with declarative validation based on OpenAPI schemas.
  • Other comments:

/sig api-machinery
/assign @jpbetz @apelisse

@k8s-ci-robot k8s-ci-robot added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Aug 28, 2023
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 28, 2023
@k8s-ci-robot k8s-ci-robot requested a review from deads2k August 28, 2023 20:21
@k8s-ci-robot k8s-ci-robot added the kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory label Aug 28, 2023
@k8s-ci-robot k8s-ci-robot requested a review from jpbetz August 28, 2023 20:21
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Aug 28, 2023
@alexzielenski alexzielenski mentioned this pull request Aug 28, 2023
4 tasks
@alexzielenski alexzielenski changed the title KEP-4153: Proposal and Design KEP-4153: Declarative Validation Proposal and Design Aug 28, 2023
Comment on lines +452 to +477
| 'dns1123subdomain' | metadata name and generateName |
| 'dns1123label' | metadata name and generateName |
| 'dns1035label' | Scoped names and keys |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about this a bit more, I think we should offer nicknames for these formats. Maybe we don't need a nickname for all of them, but at least the most popular name format (I believe most names in kubernetes use dns1123subdomain) we should offer a simpler name. Maybe "io.k8s.identifier" or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I like that they are named after exactly what they are. RFC numbers are unambiguous. Though if there are k8s-isms about our implementation them it would probably be good at least to namespace them i.e. io.k8s.dns1123subdomain

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

honestly, we should just get rid of 1035 and normalize everything to 1123 :)

Comment on lines +423 to +455
- IP and CIDR library:
- `isIP(string) bool`
- `ip(string) IP`
- `IP.is4() bool`
- `IP.is6() bool`
- `IP.isLoopback() bool`
- `isCIDR(string) bool`
- `cidr(string) CIDR`
- `CIDR.overlaps(CIDR) bool`
- `CIDR.containsIP(IP) bool`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • @thockin @robscott for ideas on what specifically we should support for IPs and CIDRs. Also, are there other network concepts we need better direct support for?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a great start! A few questions:

  1. How would IP comparison work? Some places in Kubernetes I believe we already trim whitespace before validating IP for example.
  2. Could we trim the IP out of a larger string like an IP:Port pair?
  3. In addition to the proposed CIDR functions, could we have CIDR.containsCIDR(CIDR)?

Can we provide a path for projects to define their own helpers? I can think of several Gateway API helpers I'd like to have.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to audit a bunch of hand-written code and brainstorm the least-painful CEL equivalents and for things that are just TOO painful, derive new helper functions. See my comment above. As a non-CEL expert, I don't know all of what's viable.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thockin CEL team would be happy to accept a package for working with CIDR masks. We try to remain compatible with ZetaSQL, so if there's a subset of functions from there which would be desired here, we can iterate on a CEL-idiomatic way of exposing them. If you need more than what's listed, we can also support that too, but would like to align where possible.

In general, even for other packages, I can consult on what is general enough to include in CEL and what should probably be K8s-specific.

Comment on lines +433 to +459
- UTF8 Library (for CRD validation, ManagedFields)
- IsValid
- IsPrint
- IsControl
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this intended to be used with strings or individual chars? I worry that this function list will expand over time. Is this possible to achieve using just regex? How much worse is the regex?

cc @TristonianJones

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UTF8 spec is so crisp here that the performance would be better with special functions. I wouldn't use regex here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For ManagedFIelds we need to test that all characters in the entire string are printable. The Go unicode.IsPrint seems to very specifically specify all printable characters (source).

For CRDs we test if the whole string is valid, and whether the whole string uses printable, non-control chars:
https://github.com/kubernetes/kubernetes/blob/12dc19d46fb97cbbfeb1e12b8a10ff7ae73d9515/staging/src/k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/validation/validation.go#L271-L283

- IsPrint
- IsControl
- Selectors
- `Matches(LabelSelector)`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of supporting selectors, and I agree native types will need it. I just wanted to point out that declaring LabelSelectors (a complex object type) in CEL will require using CEL struct initialization in a more complex way than we've supported before, so this will be quite a bit of work

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always thought it would be fine to map selector -> CEL, but that you might not want to mix the two so you could yourself room for optimizing via indexing with special operators.

Comment on lines 461 to 463
- `APIVersion` (GroupVersion)
- Quantity
- Qualified name
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add more detail here? Pods resources will need this, so I think it's going to be important, but I haven't spent the time to break down exactly what is needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should change "qualified name" to something less confusing. maybePrefixedName or labelKey or something

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added links to the explicit Go validations being referred to. These are terms used all over k8s validation, so I was planning on simply exposing most of the functions from apimachinery/pkg/util/validation

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know "qualified name" is used within the codebase, but it's a terrible name (and it's my fault).

Copy link
Contributor

@jpbetz jpbetz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair disclosure- I'd helped with the early proposals for this feature, so I'm biased, but I'm very supportive of this approach.

@robscott
Copy link
Member

Copy link
Member

@robscott robscott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @alexzielenski!


Declarative validation will benefit Kubernetes maintainers:

- It will make it easier to develop, maintain and review APIs.
Copy link
Member

@robscott robscott Sep 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although this may true for the simplest of validations, we've had significant trouble with this in Gateway API. It is very easy for CEL rules to get out of hand quickly. In Gateway API we're using CEL rules primarily because we don't want to maintain a validating webhook, but if we had the choice between CEL and built-in validations written and tested with go, I'm pretty sure we'd choose go.

Before we go all-in on this, it would be very helpful to see how we can make CEL validation rules more manageable to write and maintain. Can we define them somewhere else? Could they span multiple lines? In general, trying to fit each validation rule into a single line within API spec has not been a good experience so far for development, maintainability, or review.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is critical feedback. I agree that this KEP should be blocked from GA, maybe even from beta, by positive feedback from some preponderance of use-cases (e.g. converting "core" validation to use it).

Copy link
Contributor Author

@alexzielenski alexzielenski Sep 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree putting all of the validation, error, reason, etc. in one line is not good UX for writing or reviewing, which is counter to our goal.

I think at the very least we should have the ability to split the annotation for the rule, reason, fieldPath into separate lines. We can add this to the code generator. I will add that to our list of requirements for adding x-kubernetes-validations marker comments to the code generator.

Another QoL improvement which would assist in expression writing might be to support variables as we do for ValidatingAdmissionPolicy. I think that is out of scope for this KEP since it would need to be added to CRD Validation Rules (KEP will just use the same API exposed)

I also think referring to constants from code is something to be explored, but seems challenging.

TLDR: We can and should do easy improvements ahead of time. Many more advanced UX improvements to experience over time into the code-generator.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we had a tool to help authoring/testing/maintaining these?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tools help, but ultimately humans have to read and review them.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the specifics, Rob. As we collectivel learn how to do this, you are again paying the trail-blazer tax :)

A few things to think about:

  1. We don't need to block the KEP on solving this, just acknowledging that it needs to be solved.

  2. There are going to be "fairly trivial" validations that are easy to read and comprehend. There are going to be "fairly complex" validations that would benefit from being written as multi-line expressions (maybe with comments!) which seems like a k8s problem rather than intrinsic to CEL. And there will be some "very complex" validations which do not easily distill into a single expression. For this last set, we need to consider those specific cases. It may be that there are idioms or capabilities missing in CEL that we can help define. It may be that there are library functions missing. It may be that some validations just DON'T fit very well.

  3. Our near-to-medium term goal is not 100% elimination of hand-written validation. Let's take wins where we can get them and iterate on how to fit the hard-cases.

  4. I want to believe that it's in everyone's best interest to make CEL work well here, so I will assume that reasonable questions will be met with reasonable consideration until otherwise demonstrated :) Let's not assume that everything is fully baked and we have no degrees of freedom.

Copy link
Member

@apelisse apelisse Sep 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kubernetes-sigs/gateway-api#2433.

image
I suggest we create "The International Obfuscated CEL Code Contest" (see https://www.ioccc.org/ for those not familiar with it). 🤣

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely agree with everything @thockin said, not trying to block this KEP at all, just trying to find ways we can improve the overall experience here.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@robscott Thanks for sharing the detailed notes about your experience. It's useful in how I consider which sorts of tools the CEL team should consider building in the future.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is critical feedback. I agree that this KEP should be blocked from GA, maybe even from beta, by positive feedback from some preponderance of use-cases (e.g. converting "core" validation to use it).

I share reservations about whether CEL is actually easier than golang, particular for feature-gated fields, tests that require oldSelf, and cross field references. I agree this does not block alpha. I think it should prevent beta (on by default).

Comment on lines +325 to +340
- No change to error message structure for clients. Difference to clients is
limited to minimal changes to error detail strings.
Copy link
Member

@robscott robscott Sep 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this new approach have a way to access common + predefined error messages like we already have for go validations? In Gateway API we've found it pretty challenging to fit both the message and rule in a single line.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mentioned elsewhere multi-line expressions. I suspect errors will need some more robust support too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For non-CEL validations we will be using the field.Error types you linked with the predefined error messages. For CEL validations the errors currently have to be duplicated in the CEL rule.

This sounds like something that could be added to the code generator if not supported directly by CEL Validation Rules, so if it becomes a problem we can add it later without too much friction

Comment on lines +423 to +455
- IP and CIDR library:
- `isIP(string) bool`
- `ip(string) IP`
- `IP.is4() bool`
- `IP.is6() bool`
- `IP.isLoopback() bool`
- `isCIDR(string) bool`
- `cidr(string) CIDR`
- `CIDR.overlaps(CIDR) bool`
- `CIDR.containsIP(IP) bool`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a great start! A few questions:

  1. How would IP comparison work? Some places in Kubernetes I believe we already trim whitespace before validating IP for example.
  2. Could we trim the IP out of a larger string like an IP:Port pair?
  3. In addition to the proposed CIDR functions, could we have CIDR.containsCIDR(CIDR)?

Can we provide a path for projects to define their own helpers? I can think of several Gateway API helpers I'd like to have.

Comment on lines +311 to +324
- Vast majority (95%+) of hand written validation are replaced with declarative
validation. The remaining hand written rules will primarily be rules that _should
not_ be published as part of the API, usually because server side state is
involved in the validation decision.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we ensure this migration is safe? We tried our best with Gateway API and still made at least one key mistake in the process. We thought we had thorough test coverage but unfortunately still missed things. I'd imagine it will be very difficult to safely translate the wide set of existing Kubernetes validations to CEL without making some mistakes along the way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also need to establish conventions for testing. Does a type which ONLY uses declarative validation need a validation test? Can we provide a streamlined way of writing those tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can expect to have an automated process that catches 100% of everything. We are moving slowly and carefully with this transition.

Automated tests will be as thorough as possible. This includes coverage of existing validation unit tests, as well as instrumenting ALL current upstream tests to use declarative validation to shake out differences.

Until GA we will compare the validation output from the new backend to the Go backend and log the diff (# of differences tracked in a metric)

We won't promote to GA until we are confident that the number of differences is near zero. To inform that confidence we might be able to look at the above mentioned metric at the cloud operator level, and look at frequency of user submitted bug reports from the differences reported in their logs.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexzielenski please let the CEL team know how we can support you in this effort. We'd be happy to find a way to offer more standardized tooling around testing. If it happens to be K8s-specific, that is fine too, but if there's a way to generalize a part of the problem so all CEL users could benefit that would be great.

Copy link
Member

@thockin thockin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for nitpicking. This is a LOT of detail, maybe too much.

I think the way to go about this is to iterate - go thru validation code and do all the easy ones (like numeric comparisons, reuquiredness, etc). Then pick some of the simpler formats and go do all of those. Then crank up the complexity. At any point in time, the codebase WORKS, but as we figure things out, we might evolve the expressions we use.

```go
// staging/src/k8s.io/api/core/v1/types.go

// +validationRule="!self.hostNetwork || self.containers.all(c, c.containerPort.all(cp, cp.hostPort == cp.containerPort))"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be explicit about CEL (so if any OTHER language arises later, we can have room?

e.g.

+validationRule=cel("...")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is a needed. In the API where we have CEL we've been careful to arrange stanzas such that we could add a language field later if needed. We should future proof go tags in some way to allow for this as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a similar vein, I think the final tag should have a prefix (like kubebuilder:), so we can confidently fail closed on unrecognized ones.

Comment on lines +423 to +455
- IP and CIDR library:
- `isIP(string) bool`
- `ip(string) IP`
- `IP.is4() bool`
- `IP.is6() bool`
- `IP.isLoopback() bool`
- `isCIDR(string) bool`
- `cidr(string) CIDR`
- `CIDR.overlaps(CIDR) bool`
- `CIDR.containsIP(IP) bool`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to audit a bunch of hand-written code and brainstorm the least-painful CEL equivalents and for things that are just TOO painful, derive new helper functions. See my comment above. As a non-CEL expert, I don't know all of what's viable.

Comment on lines 461 to 463
- `APIVersion` (GroupVersion)
- Quantity
- Qualified name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should change "qualified name" to something less confusing. maybePrefixedName or labelKey or something

Copy link
Member

@thockin thockin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm overall really happy with this and I think we should merge and iterate. I don't see any fundamental objections?

| string format | `+format={format name}` | `format` | Invalid |
| size limits | `+min{Length,Properties,Items}`, `+max{Length,Properties,Items}` | `min{Length,Properties,Items}`, `max{Length,Properties,Items}` | TooMany, TooLong |
| numeric limits | `+minimum`, `+maximum`, `+exclusiveMinimum`, `+exclusiveMaximum` | `minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum` | Invalid |
| required fields | `+optional` (exists today) | `required` | Required |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. When I say "formalize" I really mean "write down how people express the difference". Today we only have +optional and +default is pretty new and not widely used. Before it becomes the norm, let's just write down (API convention doc or something) which one (or both) should be used.

Comment on lines +452 to +477
| 'dns1123subdomain' | metadata name and generateName |
| 'dns1123label' | metadata name and generateName |
| 'dns1035label' | Scoped names and keys |
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

honestly, we should just get rid of 1035 and normalize everything to 1123 :)

the hand written validation rules.
- It will enable clients to perform validation of native types earlier in
development worflows ("shift-left"), such as at with a Git pre-submit linter.
- It will improve API composition. In particular CRDs that embed native types
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, since we have historical baggage, we may not be able to do "obvious" things like I suggested above. I recently changed ONE field to stop defaulting in *.PodSpec and instead only in Pod.PodSpec, and I broke things (doing a diff of old saved state with new dry-run results - the field was marked absent).

@thockin
Copy link
Member

thockin commented Sep 28, 2023

You'll want to squash, I think :)

@alexzielenski alexzielenski force-pushed the declarative-validation branch 2 times, most recently from b982996 to d273093 Compare September 28, 2023 23:53
@alexzielenski alexzielenski force-pushed the declarative-validation branch 2 times, most recently from 179e8ba to a43d249 Compare September 28, 2023 23:57
@thockin
Copy link
Member

thockin commented Sep 29, 2023

I think this looks pretty good, @jpbetz ?

@alexzielenski alexzielenski force-pushed the declarative-validation branch 2 times, most recently from 02c09d5 to a777079 Compare October 2, 2023 23:41
@jpbetz
Copy link
Contributor

jpbetz commented Oct 3, 2023

@deads2k @robscott @thockin

I think this meets the bar for alpha. Do any reviewers have objections with us merging and iterating? If not I'll approve at this time tomorrow.

@robscott
Copy link
Member

robscott commented Oct 4, 2023

Have not had time to review all of this in detail, but no objections from me based on what I've been able to review. Thanks for driving this forward!

Comment on lines +5 to +16
- "@jpbetz"
owning-sig: sig-api-machinery
status: implementable
creation-date: 2023-08-20
reviewers:
- apelisse
- jpbetz
- thockin
- robscott
approvers:
- thockin
- jpbetz
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little strange to have an author as a reviewer and approver.

@alexzielenski alexzielenski force-pushed the declarative-validation branch 2 times, most recently from c4f22ba to 53183bf Compare October 4, 2023 17:12
@thockin
Copy link
Member

thockin commented Oct 4, 2023

@jpbetz

I think this meets the bar for alpha. Do any reviewers have objections with us merging and iterating? If not I'll approve at this time tomorrow.

LGTM

@apelisse
Copy link
Member

apelisse commented Oct 4, 2023

I think this meets the bar for alpha. Do any reviewers have objections with us merging and iterating? If not I'll approve at this time tomorrow.

LGTM for me too.

@alexzielenski alexzielenski force-pushed the declarative-validation branch 2 times, most recently from c9fda45 to 3dc5beb Compare October 4, 2023 19:27
@alexzielenski alexzielenski force-pushed the declarative-validation branch from 3dc5beb to 3801dda Compare October 4, 2023 19:29
@jpbetz
Copy link
Contributor

jpbetz commented Oct 4, 2023

/approve

Leaving lgtm with @deads2k

Copy link
Contributor

@deads2k deads2k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a big change. I don't see anything that makes me think we can't start. I think it's possible that we'll find additional beta criteria as the alpha is implemented.

```go
// staging/src/k8s.io/api/core/v1/types.go

// +validationRule="!self.hostNetwork || self.containers.all(c, c.containerPort.all(cp, cp.hostPort == cp.containerPort))"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In a similar vein, I think the final tag should have a prefix (like kubebuilder:), so we can confidently fail closed on unrecognized ones.


Declarative validation will benefit Kubernetes maintainers:

- It will make it easier to develop, maintain and review APIs.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is critical feedback. I agree that this KEP should be blocked from GA, maybe even from beta, by positive feedback from some preponderance of use-cases (e.g. converting "core" validation to use it).

I share reservations about whether CEL is actually easier than golang, particular for feature-gated fields, tests that require oldSelf, and cross field references. I agree this does not block alpha. I think it should prevent beta (on by default).

- Enablement/Disablement tests
- Initial e2e tests completed and enabled

#### Beta
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

| string format | `+format={format name}` | `format` | Invalid |
| size limits | `+min{Length,Properties,Items}`, `+max{Length,Properties,Items}` | `min{Length,Properties,Items}`, `max{Length,Properties,Items}` | TooMany, TooLong |
| numeric limits | `+minimum`, `+maximum`, `+exclusiveMinimum`, `+exclusiveMaximum` | `minimum`, `maximum`, `exclusiveMinimum`, `exclusiveMaximum` | Invalid |
| required fields | `+optional` (exists today) | `required` | Required |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The user perspective varies depending on whether you're the writer or the reader:

  1. writer: defaulted fields are optional, I don't have to specify
  2. reader: default fields are required, they will always have values.

fwiw, I personally find that defaulted fields as required matches my expectations, but allowing exactly one of required, optional, default maybe the clearest.


##### Mitigation: Avoid Conversion to Internal Type

Requests are received as the versioned type, so it should be feasible to avoid
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear to me when defaulting would happen if this was done. It's also not clear to me how we ensure that validation for different versions stays in sync

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexzielenski, deads2k, 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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 4, 2023
@deads2k
Copy link
Contributor

deads2k commented Oct 4, 2023

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 4, 2023
@k8s-ci-robot k8s-ci-robot merged commit bd64e70 into kubernetes:master Oct 4, 2023
@k8s-ci-robot k8s-ci-robot added this to the v1.29 milestone Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/kep Categorizes KEP tracking issues and PRs modifying the KEP directory lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants