-
Notifications
You must be signed in to change notification settings - Fork 331
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 metadata fields #2249
allow unknown metadata fields #2249
Conversation
/assign @julz @markusthoemmes @shinigambit I'm going to test downstream |
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 love this 🥳 . Had something similar in mind but didn't dare doing the parsing shenanigans. Great stuff!
if v == "metadata" && level == 1 { | ||
start = dec.InputOffset() | ||
x := struct{}{} | ||
if err = dec.Decode(&x); err != nil { |
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.
Is this guaranteed to move the decoder to the end of the entire metadata object? Even if there's sub objects like annotations
for example? Is that worth an extra test?
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.
Is this guaranteed to move the decoder to the end of the entire metadata object?
Yeah - it's decoding the metadata value into the empty struct.
Even if there's sub objects like annotations for example? Is that worth an extra test?
It's easy enough to add so we can catch regressions if someone changes the implementation
The biggest gain over the naive implementation is because we bail out early after we have the metadata byte offsets. |
this is for catching any regressions
Codecov Report
@@ Coverage Diff @@
## main #2249 +/- ##
==========================================
+ Coverage 63.92% 64.05% +0.13%
==========================================
Files 220 221 +1
Lines 9550 9596 +46
==========================================
+ Hits 6105 6147 +42
- Misses 3172 3174 +2
- Partials 273 275 +2
Continue to review full report at Codecov.
|
|
||
for { | ||
t, err = dec.Token() | ||
if err == io.EOF { //nolint |
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.
can we not do the errors.Is
thing? (I guess this is asking for that?)
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.
You could but it's not necessary - https://pkg.go.dev/encoding/json#Decoder.Token states it will return io.EOF
Downstream serving passes |
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.
/lgtm
/approve
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: dprotaso, markusthoemmes 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 |
/cherry-pick release-0.25 |
@dprotaso: new pull request created: #2254 In response to this:
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. |
@chizhg do we have the latest cherry pick plugin? It should support multiple invocations |
/cherry-pick release-0.24 |
/cherry-pick release-0.23 |
/cherry-pick release-0.22 |
@dprotaso: new pull request created: #2255 In response to this:
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. |
@dprotaso: new pull request created: #2256 In response to this:
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. |
@dprotaso: new pull request created: #2257 In response to this:
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. |
Need to pull in knative/pkg#2249 for k8s 1.22 support
Need to pull in knative/pkg#2249 for k8s 1.22 support
* Bump to cert-manager 1.5.3 1.2.0 no longer works with k8s 1.22 * Bump to latest eventing patch releases Need to pull in knative/pkg#2249 for k8s 1.22 support
Validation webhook was failing with `json: unknown field "subresource"` on decoding the admission request. It's because of the new "subresource" field in `metadata.managedFields`[^0]. Folks in Knative fixed the issue[^1] with creating a custom json decoder that ignores unknown fields *only* in metadata. [^0]: kubernetes/apimachinery@5c420e5 [^1]: knative/pkg#2249
* K8SPXC-885: Fix validation webhook on k8s 1.22 Validation webhook was failing with `json: unknown field "subresource"` on decoding the admission request. It's because of the new "subresource" field in `metadata.managedFields`[^0]. Folks in Knative fixed the issue[^1] with creating a custom json decoder that ignores unknown fields *only* in metadata. [^0]: kubernetes/apimachinery@5c420e5 [^1]: knative/pkg#2249 * address review comments Co-authored-by: Mykola Marzhan <mykola.marzhan@percona.com> Co-authored-by: Mykola Marzhan <mykola.marzhan@percona.com>
Fixes: knative/serving#11448