Skip to content

Commit 1c9a6fd

Browse files
committed
Defaulting to strict SS validation when enabled
1 parent 794cccc commit 1c9a6fd

File tree

1 file changed

+27
-25
lines changed
  • keps/sig-api-machinery/2885-server-side-unknown-field-validation

1 file changed

+27
-25
lines changed

keps/sig-api-machinery/2885-server-side-unknown-field-validation/README.md

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,11 @@ know that this has succeeded?
225225
misspelled), nor are any fields duplicated (for json and yaml data).
226226
* We must maintain compatibility with all existing clients, thus server side
227227
unknown field validation should be opt-in.
228-
* kubectl should provide the ability for a user to request server-side
229-
validation.
228+
* kubectl should default to server-side validation against servers that support
229+
it.
230+
* kubectl should provide the ability for a user to request no validation,
231+
warning only validation, or client-side validation (while it is still supported)
232+
instead of strict server-side validation on a per-request basis.
230233

231234
### Non-Goals
232235

@@ -266,12 +269,14 @@ presence of unknown/duplicate fields.
266269

267270
For beta, we propose modifying the kubectl `--validate` flag to enable users
268271
to choose between client-side validation or server-side
269-
validation (either strict or warning)
272+
validation (either strict or warning), when server-side validation is supported
273+
by the server (and default to strict server-side validation).
270274

271275
### Notes/Constraints/Caveats (Optional)
272276

273277
#### Future Work
274278

279+
##### Deprecating Client Side Validation
275280
Upon successfully providing kubectl access to server-side validation via the
276281
`--validate` flag, an open question will remain as to the future of client
277282
side validation.
@@ -352,7 +357,6 @@ parameter to indicate the level of field validation the server should perform,
352357
such as `?fieldValidation=Strict`.
353358

354359
Primary arguments for using query parameter include:
355-
* Being able version them with the API version.
356360
* Parameters are discoverable in openapi.
357361
* We have precedent for using query parameters for write requests already (via CreateOptions,
358362
PatchOptions, UpdateOptions)
@@ -498,21 +502,21 @@ for strict server-side validation.
498502
encounters any validation errors before sending a request to the server. If no
499503
client-side validation errors are found, the request sent to the server has
500504
fieldValidation param set to `Ignore`. This will be the default behavior in beta
501-
as it is identical to the current validation behavior pre-1.24
505+
as it is identical to the current validation behavior pre-1.24.
502506
* `ignore`: This performs no client-side validation or server-side validation,
503507
sending a request to the server with fieldValidation param set to `Ignore`.
504508
* `warn`: This sends a request to the server with the fieldValidation param set
505509
to `Warn`. It performs server-side validation, but validation errors are
506510
exposed as warnings in the result header rather than failing the request. This
507511
will be the default once server-side validation goes GA.
508-
* `strict`: same behavior as `--validate=server`.
509-
* `true`: This is the same as `--validate=client`, but throws a warning along
510-
the lines of "`--validate=true` is being deprecated, use `--validate=client`
511-
instead". This is also the default behavior if `--validate` flag is passed
512-
withouth a value set.
513-
* `false`: This is the same as `--validate=ignore`, but throws a warning along
514-
the lines of "`--validate=false` is being deprecated use `--validate=ignore`
515-
instead".
512+
* `strict`: same behavior as `--validate=server`. This will be the default
513+
behavior for servers with the server-side field validation feature enabled.
514+
* `true`: This is the same as `--validate=strict` for servers where server side field
515+
validation is enabled. For pre-1.24 servers and servers with the server-side
516+
field validation feature disabled, this will perform client-side validation
517+
identical to `--validate=client`. Passing the `--validate` flag
518+
without a value set behaves identical to `--validate=true`.
519+
* `false`: This is the same as `--validate=ignore`
516520

517521

518522
### Test Plan
@@ -580,18 +584,10 @@ Below are some examples to consider, in addition to the aforementioned [maturity
580584

581585
#### Beta
582586

583-
- kubectl validate flag offers ability to perform server-side validation
584-
- All follow-ups from alpha are complete (see below)
585-
586-
##### Alpha Follow Ups
587-
588-
These are some tasks that were initially planned for alpha, but did not make it
589-
and should be addressed before beta is considered complete.
587+
- [ ]kubectl validate flag offers ability to perform server-side validation
590588
- [ ] endpoints handler unit testing of field validation
591589
- [ ] customresource handler unit testing of field validation
592590
- [ ] field validation integration tests check for exact match of strict errors
593-
- [ ] [sigs.k8s.io/yaml should
594-
report](https://github.com/kubernetes/kubernetes/pull/105916#discussion_r748530682) strict errors consistent with kjson
595591
- [ ] [make
596592
use](https://github.com/kubernetes/kubernetes/pull/105916#discussion_r746125180) of the decoded object rather than decoding multiple times
597593
- [ ]
@@ -747,8 +743,9 @@ No
747743

748744
###### Is the rollout accompanied by any deprecations and/or removals of features, APIs, fields of API types, flags, etc.?
749745

750-
For beta we will be warning kubectl users that `--validate={true,false}` is
751-
being deprecated in favor of `--validate={client,server,strict,warn,ignore}`.
746+
No deprecations or removals however the kubectl flag `--validate=true` is being changed
747+
to perform server-side validation instead of client-side validation (for servers
748+
that support it).
752749

753750
### Monitoring Requirements
754751

@@ -871,7 +868,12 @@ Think about adding additional work or introducing new steps in between
871868
-->
872869
Mutating API calls that opt-in to validation will be slower.
873870
Benchmarks of alpha changes indicate that performing validation results in
874-
~2-5% slower request latency and ~4-8% more memory usage.
871+
~2-5% slower request latency and ~4-8% more memory usage for json and yaml
872+
requests.
873+
874+
Given that the majority of high-frequency requests made by system
875+
components use protobuf, we expect a negligible increase in overall resource
876+
usage.
875877

876878
###### Will enabling / using this feature result in non-negligible increase of resource usage (CPU, RAM, disk, IO, ...) in any components?
877879

0 commit comments

Comments
 (0)