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-2885: Beta Graduation Criteria for Field Validation #3081

Merged

Conversation

kevindelgado
Copy link
Contributor

  • One-line PR description: Update PR for beta milestone targeting 1.24 (kubectl support and alpha follow-ups)

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 9, 2021
@kevindelgado kevindelgado requested a review from apelisse December 9, 2021 17:33
@k8s-ci-robot k8s-ci-robot added the sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. label Dec 9, 2021
@kevindelgado kevindelgado force-pushed the 2885-ss-field-validation-beta branch from 47ffa50 to 5dd7845 Compare December 9, 2021 17:42
@kevindelgado kevindelgado force-pushed the 2885-ss-field-validation-beta branch from 5dd7845 to fb9b1d4 Compare December 20, 2021 23:29
Copy link
Contributor

@sftim sftim left a comment

Choose a reason for hiding this comment

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

One question, one minor and optional tweak.

to `Warn`. It performs server-side validation, but validation errors are
exposed as warnings in the result header rather than failing the request. This
will be the default once server-side validation goes GA.
* `strict`: same behavior as `--validate=server`.
Copy link
Member

Choose a reason for hiding this comment

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

Why do we need it then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"Strict", "Warn", and "Ignore" are the semantics used by the fieldValidation query param and will be permanent.

"Server" and "Client" are transitionary semantics for now since we want to give the caller the ability to choose until client side validation is no longer an option. It makes sense to offer both "server" and "strict" for now so that the user sees the expected behavior regardless of which set of semantics they are using.

@kevindelgado
Copy link
Contributor Author

cc @liggitt

@kevindelgado
Copy link
Contributor Author

This should be ready for a prod-readiness review now @deads2k

For beta, we will modify the kubectl `--validate` flag from being a bool flag to
a string flag that accepts the following values:

* `true` or `strict`: If server-side validation is enabled on the server it sends
Copy link
Member

Choose a reason for hiding this comment

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

The conditional behavior based on the servers ability sounds confusing to me. Also, what do you do on a "client-dry-run"? i.e. kubectl create --dry-run=client --validate? Does that automatically fall back to client-side validation? How do you explain that? "Why are the errors looking so different"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a note that we will treat --dry-run=client as not being connected to any server at-all and thus will trigger a fallback to CS validation

Copy link
Member

Choose a reason for hiding this comment

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

doesn't dry-run=client trigger local mode and prevent getting the schema from the server at all, and therefore do no validation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@apelisse do you know if there's some mechanism under the hood that using a cached schema or something.

FWIW I can definitely see that validation is being performed with --dry-run=client when running a simple experiment on a generic 1.23 cluster

Copy link
Member

Choose a reason for hiding this comment

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

Yes, client dry-run still asks the server for the openapi. It has pros and cons ...

@liggitt
Copy link
Member

liggitt commented Jan 18, 2022

@apelisse:
I'm not usually a big fan of flags whose behavior depends on some hard-to-assess logic (in this case, looking at the existence of a query param defined in the openapi). I'd rather want the behavior to be strictly defined and unconditional, with a proper error when used incorrectly (rather than the query param being merely ignored).

kubectl already inspects published openapi to determine support for server side dry run. Since client side validation doesn't work well and there's an end goal of dropping the current implementation from create/replace/apply, I don't think we should do anything to increase the CLI flag surface to explicitly depend on it

@apelisse
Copy link
Member

kubectl already inspects published openapi to determine support for server side dry run.

It does, but it doesn't implicitly change the behavior of flags based on that, it just stops you from doing something broken, no?

@apelisse
Copy link
Member

Since my main concern is changing the behavior without the person knowing, I suggest we go with that sort of messaging:

client-side validation is deprecated and server-side validation will be used instead by default if available. We will fallback to client-side validation in the mean time if ..., along with a warning to let users know what's going on."

@kevindelgado
Copy link
Contributor Author

Since my main concern is changing the behavior without the person knowing, I suggest we go with that sort of messaging:

client-side validation is deprecated and server-side validation will be used instead by default if available. We will fallback to client-side validation in the mean time if ..., along with a warning to let users know what's going on."

Modified the proposal to include this messaging

@kevindelgado kevindelgado requested a review from apelisse January 19, 2022 02:29
@k8s-ci-robot k8s-ci-robot added sig/cli Categorizes an issue or PR as relevant to SIG CLI. kind/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API labels Jan 19, 2022
@k8s-triage-robot
Copy link

This PR may require API review.

If so, when the changes are ready, complete the pre-review checklist and request an API review.

Status of requested reviews is tracked in the API Review project.

@deads2k
Copy link
Contributor

deads2k commented Jan 20, 2022

PRR lgtm and the beta criteria lgtm too, but I'll leave time for additional reviewers there.

/approve

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 20, 2022
Copy link
Member

@apelisse apelisse left a comment

Choose a reason for hiding this comment

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

LGTM for me, thank you Kevin!

* Enhanced offline validation. Current client-side validation has been used as a
form of offline validation to simply validate configs that have no intention
of being actually applied to a server. Ideally users would have a supported
way to perform offline validation, but that is outside the scope of this KEP.
Copy link
Member

Choose a reason for hiding this comment

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

Not asking for a change here, but using the same yaml/json library client side would already be an improvement (even if it doesn't work with openapi support, it would at least detect duplicates for example?)

For beta, we will modify the kubectl `--validate` flag from being a bool flag to
a string flag that accepts the following values:

* `true` or `strict`: If server-side validation is enabled on the server it sends
Copy link
Member

Choose a reason for hiding this comment

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

Yes, client dry-run still asks the server for the openapi. It has pros and cons ...

Copy link
Contributor

@soltysh soltysh left a comment

Choose a reason for hiding this comment

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

this lgtm from sig-cli pov

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: deads2k, kevindelgado, soltysh

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

@kevindelgado
Copy link
Contributor Author

Anything I'm missing @liggitt or @apelisse? We have lgtms from PRR and sig-cli

@liggitt
Copy link
Member

liggitt commented Jan 24, 2022

no, lgtm

@liggitt
Copy link
Member

liggitt commented Jan 25, 2022

/lgtm
per #3081 (review)

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 25, 2022
@k8s-ci-robot k8s-ci-robot merged commit f251d39 into kubernetes:master Jan 25, 2022
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/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API 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. sig/cli Categorizes an issue or PR as relevant to SIG CLI. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants