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

fix 'y' to true when YAML decode to JSON #102445

Closed
wants to merge 1 commit into from

Conversation

CaoDonghui123
Copy link
Contributor

@CaoDonghui123 CaoDonghui123 commented May 31, 2021

What type of PR is this?

/kind bug

What this PR does / why we need it:

Which issue(s) this PR fixes:

Fixes #102308

Special notes for your reviewer:

Does this PR introduce a user-facing change?

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels May 31, 2021
@k8s-ci-robot k8s-ci-robot requested review from deads2k, ncdc and a team May 31, 2021 06:02
@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. area/dependency Issues or PRs related to dependency changes sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels May 31, 2021
@@ -98,7 +99,7 @@ func (d *YAMLToJSONDecoder) Decode(into interface{}) error {
}

if len(bytes) != 0 {
err := yaml.Unmarshal(bytes, into)
err := yaml3.Unmarshal(bytes, into)
Copy link
Member

@wzshiming wzshiming May 31, 2021

Choose a reason for hiding this comment

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

I think it is necessary to consider as a whole, patch this piece of logic separately and introduce new dependencies. I don't think this is a good modification.

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: CaoDonghui123
To complete the pull request process, please assign smarterclayton after the PR has been reviewed.
You can assign the PR to them by writing /assign @smarterclayton in a comment when ready.

The full list of commands accepted by this bot can be found 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

@k8s-ci-robot k8s-ci-robot added area/kubeadm sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. labels May 31, 2021
@k8s-ci-robot
Copy link
Contributor

@CaoDonghui123: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-kubernetes-integration e5e17ea link /test pull-kubernetes-integration
pull-kubernetes-conformance-kind-ga-only-parallel e5e17ea link /test pull-kubernetes-conformance-kind-ga-only-parallel
pull-kubernetes-e2e-kind e5e17ea link /test pull-kubernetes-e2e-kind
pull-kubernetes-e2e-kind-ipv6 e5e17ea link /test pull-kubernetes-e2e-kind-ipv6
pull-kubernetes-unit e5e17ea link /test pull-kubernetes-unit
pull-kubernetes-e2e-gce-ubuntu-containerd e5e17ea link /test pull-kubernetes-e2e-gce-ubuntu-containerd

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@fedebongio
Copy link
Contributor

/assign @roycaihw
/cc @lavalamp @liggitt since there is a version bump of yaml decoder
/triage accepted

@k8s-ci-robot k8s-ci-robot added the triage/accepted Indicates an issue or PR is ready to be actively worked on. label Jun 1, 2021
@k8s-ci-robot k8s-ci-robot requested a review from liggitt June 1, 2021 20:14
@k8s-ci-robot k8s-ci-robot removed the needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. label Jun 1, 2021
@k8s-ci-robot
Copy link
Contributor

@fedebongio: GitHub didn't allow me to request PR reviews from the following users: there, a, version, decoder, yaml, since, is, bump, of.

Note that only kubernetes members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/assign @roycaihw
/cc @lavalamp @liggitt since there is a version bump of yaml decoder
/triage accepted

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.

@lavalamp
Copy link
Member

lavalamp commented Jun 1, 2021

One does not simply increase the version of the yaml library... 😱

This appears to have broken many unit tests. Ideally we can fix the bug with a much more lightweight tweak.

@roycaihw
Copy link
Member

roycaihw commented Jun 1, 2021

$ kubectl apply -f crd.yaml -v=9
...
Request Body: {"apiVersion":"apiextensions.k8s.io/v1","kind":"CustomResourceDefinition","metadata":{"annotations":{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"apiextensions.k8s.io/v1\",\"kind\":\"CustomResourceDefinition\",\"metadata\":{\"annotations\":{},\"name\":\"tests.calci.io\"},\"spec\":{\"group\":\"calci.io\",\"names\":{\"kind\":\"Test\",\"plural\":\"tests\",\"shortNames\":[\"tt\"],\"singular\":\"test\"},\"scope\":\"Namespaced\",\"versions\":[{\"name\":\"v1\",\"schema\":{\"openAPIV3Schema\":{\"properties\":{\"spec\":{\"properties\":{\"operation\":{\"enum\":[\"ADD\",\"SUB\",\"DIV\",\"MUL\"],\"type\":\"string\"},\"true\":{\"type\":\"number\"},\"x\":{\"type\":\"number\"}},\"type\":\"object\"}},\"type\":\"object\"}},\"served\":true,\"storage\":true}]}}\n"},"name":"tests.calci.io"},"spec":{"group":"calci.io","names":{"kind":"Test","plural":"tests","shortNames":["tt"],"singular":"test"},"scope":"Namespaced","versions":[{"name":"v1","schema":{"openAPIV3Schema":{"properties":{"spec":{"properties":{"operation":{"enum":["ADD","SUB","DIV","MUL"],"type":"string"},"true":{"type":"number"},"x":{"type":"number"}},"type":"object"}},"type":"object"}},"served":true,"storage":true}]}}

so far it looks like the problem happened in kubectl when sending the request. Could you look into fixing kubectl instead?

@BenTheElder
Copy link
Member

there's also: #78946 which is a bit broader.

@@ -98,7 +99,7 @@ func (d *YAMLToJSONDecoder) Decode(into interface{}) error {
}

if len(bytes) != 0 {
err := yaml.Unmarshal(bytes, into)
err := yaml3.Unmarshal(bytes, into)
Copy link
Member

Choose a reason for hiding this comment

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

sigs.k8s.io/yaml uses json tags in structs for marshaling/unmarshaling, and does mechanical yaml-json conversion

gopkg.in/yaml.v3 expects yaml struct tags, which none of our API types have, so this switch will not work at all for API types.

Copy link
Member

@roycaihw roycaihw left a comment

Choose a reason for hiding this comment

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

the fundamental issue is #34146. It's unclear if someone will eventually pick it up

@@ -98,7 +99,7 @@ func (d *YAMLToJSONDecoder) Decode(into interface{}) error {
}

if len(bytes) != 0 {
err := yaml.Unmarshal(bytes, into)
Copy link
Member

Choose a reason for hiding this comment

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

this is sigs.k8s.io/yaml. Kubernetes depends on the features that sigs.k8s.io/yaml implements on top of go-yaml. We cannot simply change sigs.k8s.io/yaml to go-yaml v3.

Please consider moving forward the go-yaml v3 conversation in sigs.k8s.io/yaml. Some background:

/close

@k8s-ci-robot
Copy link
Contributor

@roycaihw: Closed this PR.

In response to this:

this is sigs.k8s.io/yaml. Kubernetes depends on the features that sigs.k8s.io/yaml implements on top of go-yaml. We cannot simply change sigs.k8s.io/yaml to go-yaml v3.

Please consider moving forward the go-yaml v3 conversation in sigs.k8s.io/yaml. Some background:

/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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dependency Issues or PRs related to dependency changes area/kubeadm cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CRD definition is changing the property name 'y' in openAPIV3Schema spec to True
8 participants