-
Notifications
You must be signed in to change notification settings - Fork 39.2k
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
Make kubernetes json serializer case sensitive #65034
Make kubernetes json serializer case sensitive #65034
Conversation
84be0b0
to
c9efab0
Compare
c9efab0
to
f5e4ac6
Compare
I think some tests need fixing because of the Should this be cherry-picked into 1.8+? I'm not sure if that is such a good idea since this does a dependency bump... |
/kind bug Needs a milestone update too. |
/uncc @dchen1107 |
@@ -157,7 +169,7 @@ func (s *Serializer) Decode(originalData []byte, gvk *schema.GroupVersionKind, i | |||
types, _, err := s.typer.ObjectKinds(into) | |||
switch { | |||
case runtime.IsNotRegisteredError(err), isUnstructured: | |||
if err := jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(data, into); err != nil { | |||
if err := caseSensitiveJsonIterator().Unmarshal(data, into); 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.
private package var rather than reconstructing the options every time?
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.
Done.
more godeps need fixing (apiextensions-apiserver/Godeps/Godeps.json)... should find/replace the json-iter revision in all of them |
Other: "test", | ||
}, | ||
}, | ||
// Unmarshalling is case-sensitive for big strut. |
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.
nit: struct
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.
Done.
/approve |
67ff1fe
to
0334021
Compare
@@ -157,7 +167,7 @@ func (s *Serializer) Decode(originalData []byte, gvk *schema.GroupVersionKind, i | |||
types, _, err := s.typer.ObjectKinds(into) | |||
switch { | |||
case runtime.IsNotRegisteredError(err), isUnstructured: | |||
if err := jsoniter.ConfigCompatibleWithStandardLibrary.Unmarshal(data, into); 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.
looks like there are four other uses of jsoniter.ConfigCompatibleWithStandardLibrary
in the codebase... should replace those as well (and as a follow-up think about how to ensure we only use a standard consistent config; possibly something like #63284)
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.
Replaced the other references in the latest commit.
#63284 is a good follow-up.
/retest |
Automatic merge from submit-queue (batch tested with PRs 64838, 65138). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. use case-sensitive json-iter to decode custom resource ObjectMeta found one additional spot where case-insensitivity could bite us. uses the case-sensitive decode added in kubernetes/kubernetes#65034 /assign @sttts /cc @caesarxuchao ```release-note NONE ``` Kubernetes-commit: 4ba0dbde84ba54941d998fc93b863b7eb97b8d53
Automatic merge from submit-queue. Manually cherrypick #65034 to 1.10 Manually cherrypicking #65034. Using hack/cherry_pick_pull.sh to cherrypick is difficult because that requires cherrypicking #63059 first. This PR imported the latest jsoniterator library so that case sensitivity during unmarhsaling is optional. The PR also set Kubernetes json serializer to be case sensitive. Fix #64612. ```release-notes Kubernetes json deserializer is now case-sensitive to restore compatibility with pre-1.8 servers. If your config files contains fields with wrong case, the config files will be now invalid. ```
Cherrypicked to 1.10, still needs to be cherrypicked to 1.8 and 1.9. |
Automatic merge from submit-queue (batch tested with PRs 65339, 65343, 65324, 65335, 65367). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Fix k8s json package import name Fixes nits found while cherry-picking #65034 in #65298. **Release note**: ```release-note NONE ``` /cc sttts liggitt caesarxuchao
Automatic merge from submit-queue (batch tested with PRs 65339, 65343, 65324, 65335, 65367). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Fix k8s json package import name Fixes nits found while cherry-picking kubernetes/kubernetes#65034 in kubernetes/kubernetes#65298. **Release note**: ```release-note NONE ``` /cc sttts liggitt caesarxuchao Kubernetes-commit: 456f85e736069398329226b9dff39d0304ee52d2
Automatic merge from submit-queue. Manual cherrypick of #65034 to 1.9: make json serializer case sensitive fixes partially #64612 This PR imports the latest jsoniterator library so that case sensitivity during unmarshalling is optional. The PR also sets Kubernetes json serializer to be case sensitive. **Release note**: ```release-note ACTION REQUIRED: Kubernetes JSON deserializer is now case-sensitive to restore compatibility with pre-1.8 servers. If your config files contains fields with wrong case, the config files will be now invalid. ``` /sig api-machinery /kind bug /assign caesarxuchao liggitt thockin sttts mbohlool
Saw this in the release notes. Are there any tools to verify your cluster only has objects with the correct casing, or does each site need to write a tool to do so? |
object data persisted in etcd is correct, so no stored data is problematic. kubectl create/apply performs case-sensitive client-side validation which complains about incorrect/unknown fields. For your resource manifest files, I'm not aware of a stand-alone tool that only validates a resource manifest against the openapi schema |
Automatic merge from submit-queue. Manual cherrypick of #65034 to 1.8: make json serializer case sensitive fixes partially #64612 This PR imports the latest jsoniterator library so that case sensitivity during unmarshalling is optional. The PR also sets Kubernetes json serializer to be case sensitive. **Release note**: ```release-note ACTION REQUIRED: Kubernetes JSON deserializer is now case-sensitive to restore compatibility with pre-1.8 servers. If your config files contains fields with wrong case, the config files will be now invalid. ``` /sig api-machinery /kind bug /assign caesarxuchao liggitt thockin sttts mbohlool
* Bump v1.11.0 * Bump vendor k8s 1.11.0 Also bump json-iterator as required per: kubernetes/kubernetes#65034
Using lessons learned from k8s changes: kubernetes/kubernetes#65034 Change-Id: Ia17a8f94ae6ed00c5af2595c2b48d3c9a0344427
…ugorji Using lessons learned from k8s changes: kubernetes/kubernetes#65034 Change-Id: Ia17a8f94ae6ed00c5af2595c2b48d3c9a0344427
…ugorji Using lessons learned from k8s changes: kubernetes/kubernetes#65034 Change-Id: Ia17a8f94ae6ed00c5af2595c2b48d3c9a0344427
…ugorji Using lessons learned from k8s changes: kubernetes/kubernetes#65034 Change-Id: Ia17a8f94ae6ed00c5af2595c2b48d3c9a0344427
…ugorji Using lessons learned from k8s changes: kubernetes/kubernetes#65034 Change-Id: Ia17a8f94ae6ed00c5af2595c2b48d3c9a0344427
…ugorji Using lessons learned from k8s changes: kubernetes/kubernetes#65034 Change-Id: Ia17a8f94ae6ed00c5af2595c2b48d3c9a0344427
…ugorji Using lessons learned from k8s changes: kubernetes/kubernetes#65034 Change-Id: Ia17a8f94ae6ed00c5af2595c2b48d3c9a0344427
…ugorji Using lessons learned from k8s changes: kubernetes/kubernetes#65034 Change-Id: Ia17a8f94ae6ed00c5af2595c2b48d3c9a0344427
Automatic merge from submit-queue (batch tested with PRs 65339, 65343, 65324, 65335, 65367). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Fix k8s json package import name Fixes nits found while cherry-picking kubernetes/kubernetes#65034 in kubernetes/kubernetes#65298. **Release note**: ```release-note NONE ``` /cc sttts liggitt caesarxuchao Kubernetes-commit: 456f85e736069398329226b9dff39d0304ee52d2
This PR imported the latest jsoniterator library so that case sensitivity during unmarhsaling is optional. The PR also set Kubernetes json serializer to be case sensitive.
Kubernetes json serializer had been case sensitive for 1.1-1.7 as we were using ugorji. This PR restores the behavior.
Fix #64612.