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

Allow unknown fields in webhooks #11848

Closed
wants to merge 2 commits into from

Conversation

julz
Copy link
Member

@julz julz commented Aug 23, 2021

Given we now have schema validation, we should stop relying on json decoders to block unknown fields. This prevents API additions in new versions of kubernetes breaking Knative (as happened in #11448).

Unfortunately this does leave us without a great solution for things such as Tekton where schema validation bumps against etcd limits, so we may need another approach there. Still, for serving this is a low-cost fix to get things working without - I think! - obvious downsides (due to having schema validation now), and which seems to best match (based on conversations with them) how upstream k8s expects us to hold them.

Also adds k8s 1.22 to CI via the GitHub actions.

Related: #11805
Fixes: #11448

/assign @dprotaso @markusthoemmes
cc @vdemeester

Release Note

Stops disallowing unknown fields via the validation webhook. Instead, schema validation should now be used for this purpose.

Given we now have schema validation and explicit validation on PodSpec,
we should stop relying on json decoders to block unknown fields. This
prevents API additions in new versions of kubernetes breaking Knative.

Unfortunately this does leave us without a great solution for things
such as Tekton where schema validation bumps against etcd limits, so we
may need another approach there. Still, for serving this is a low-cost
fix to get things working without - I think! - obvious downsides.
@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Aug 23, 2021
@knative-prow-robot knative-prow-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 23, 2021
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: julz

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

@knative-prow-robot knative-prow-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. area/API API objects and controllers labels Aug 23, 2021
@codecov
Copy link

codecov bot commented Aug 23, 2021

Codecov Report

Merging #11848 (5ac71e0) into main (6891f62) will increase coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #11848      +/-   ##
==========================================
+ Coverage   87.81%   87.83%   +0.02%     
==========================================
  Files         196      196              
  Lines        9393     9393              
==========================================
+ Hits         8248     8250       +2     
+ Misses        889      888       -1     
+ Partials      256      255       -1     
Impacted Files Coverage Δ
pkg/reconciler/configuration/configuration.go 86.15% <0.00%> (+1.53%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6891f62...5ac71e0. Read the comment docs.

@liggitt
Copy link

liggitt commented Aug 23, 2021

a potential hybrid that would enable cross-version compatibility with different Kubernetes versions would be to tolerate unknown fields under metadata (which Kubernetes takes responsibility for validating and pruning unknown fields from) and not tolerate unknown fields anywhere else

@dprotaso
Copy link
Member

So we've landed the K8s 1.22 fixes in a separate PR but I think we still want to reject unknown properties because our schema is not fully specified - we have uses of x-kubernetes-preserve-unknown-fields.

A few problems I though of

  1. Valid fields are not propagated to the resulting Pod - may trip up users

A user installs an older version of Knative on a newer version of Kubernetes. There is a drift between the PodSpecs between our versions. If a user uses a newer PodSpec field Knative will truncate that field when reconciling Revisions => Deployments.

  1. API WG Group may restrict the use of new fields in the future

Given that we preserve unknown fields we may in fact be preserving fields which will become part of the PodSpec in a future K8s release. The API WG may choose to limit the use of this field for whatever reason. This would break users when upgrading since valid specs are now invalid.

@julz
Copy link
Member Author

julz commented Sep 10, 2021

yeah, I think this is the right way to do this.. but not until we've done #11980 :(. I'll repurpose this to add 1.22 to the actions, since we clearly want to do that either way and that's actually most of what this PR does

@julz
Copy link
Member Author

julz commented Sep 10, 2021

/close

@knative-prow-robot
Copy link
Contributor

@julz: Closed this PR.

In response to this:

/close

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.

@julz
Copy link
Member Author

julz commented Sep 10, 2021

Pulled the k8s 1.22 CI commit out and opened #11981.

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. area/API API objects and controllers cla: yes Indicates the PR's author has signed the CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

mutation failed: cannot decode incoming new object: json: unknown field "subresource"
5 participants