-
Notifications
You must be signed in to change notification settings - Fork 39.7k
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
kubectl / kubernetes not 100% compatible with YAML 1.2 #34146
Comments
@saad-ali, @caesarxuchao is this related to something we discovered on kubectl version issue |
@kubernetes/kubectl |
As you've pointed out, Kubernetes uses ghodss/yaml which is just a wrapper for candiedyaml. candiedyaml's README states that it's a "YAML 1.1 parser with support for YAML 1.2 features" ... I would recommend filing an issue with candiedyaml if you think that the behavior should be different. Alternatively, ghodss/yaml used to be a wrapper around go-yaml, but we switched it to candiedyaml due to licensing concerns. It seems, however, that those concerns were recently addressed and go-yaml changed its license, so if you find that go-yaml has better behavior we could consider switching back. |
go-yaml has the same issues, but I would recommend you still switch back due to compatibility issues. Kube is using an older version of your code which relies on go-yaml. |
@fabianofranz Would you be able to own this or find it an owner? |
@pwittrock on it. ;) Before anything else I'll submit a PR to ghodss/yaml to switch back to go-yaml since it seems more reliable and it's now licensed as Apache 2.0 (go-yaml/yaml#160 (comment) and go-yaml/yaml@e4d366f). |
SGTM. |
The YAML 1.2 spec became, as one of the biggest changes, more restrictive about what's supported as booleans, mostly now only recommending I opened a go-yaml issue about this, but I'm not sure a fix is going to happen since go-yaml wants to claim to "support most of YAML 1.1 and 1.2", so they will most likely want to keep supporting the specs disjunction instead of becoming more restrictive and leaving 1.1 out. If we really want to fix this, I mostly see two options: we either a) fully move to 1.2, everywhere (and find a library that does it according to the spec); or b) try to extend go-yaml by proposing more flexibility to choose how to handle the differences between 1.1 and 1.2. In case of b), for example, have a Thoughts? |
In my limited experience it's usually better to fully support standard(s) for maximum interoperability and less user surprises. From a distance, I'd guess that supporting a disjointed set of standards adds confusion and technical debt to a community. And piling on to standards confusion just because other projects do it doesn't seem right. But this may not reflect the reasons for the current disjointed support. There might be another option because YAML 1.2 and 1.1 allow version directives like so: %YAML 1.2
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: redis
spec:
replicas: 1
selector:
matchLabels:
name: redis
template:
metadata:
labels:
name: redis
spec:
containers:
-
name: redis
image: 'redis:3.2'
command:
- redis-server
- '--appendonly'
- no currently The downside of requiring directives for boolean handling are that we'd still need to find a compatible library and I generally don't see yaml libraries including them in output, so we'd probably need to add version directive printing support to libraries/tools that are missing the option. The upside is that it is 100% standards compliant. |
If go-yaml exposes an Encoder/Decoder, one could set an option to enable "strict" YAML 1.2 parsing. Booleans are just one change in YAML 1.2, there are others. There is also a separate issue opened on allowing longer lines to be emitted which could be made possible as well. |
/sig cli |
Issues go stale after 90d of inactivity. Prevent issues from auto-closing with an If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
/triage accepted |
See also kubernetes/kubernetes#34146 (Kubernetes manifest files are still using yaml 1.1)
See also kubernetes/kubernetes#34146 (Kubernetes manifest files are still using yaml 1.1)
See also kubernetes/kubernetes#34146 (Kubernetes manifest files are still using yaml 1.1)
See also kubernetes/kubernetes#34146 (Kubernetes manifest files are still using yaml 1.1)
See also kubernetes/kubernetes#34146 (Kubernetes manifest files are still using yaml 1.1)
This issue is labeled with You can:
For more details on the triage process, see https://www.kubernetes.dev/docs/guide/issue-triage/ /remove-triage accepted |
I wonder if this still merits the important-soon priority. I'm going to take initiative here: |
[js-yaml](https://www.npmjs.com/package/js-yaml) has had no releases in over 3 years. Also, the fact it only supports YAML 1.2 is leading to bugs, since Kubernetes uses YAML 1.1 (see kubernetes/kubernetes#34146). This switches over to [yaml](https://www.npmjs.com/package/yaml), which had a release last month, is [licensed under ISC](https://github.com/eemeli/yaml/blob/main/LICENSE), and supports YAML 1.1. I also added test cases for the parsing/stringifying code. Signed-off-by: Mason Malone <[email protected]>
[js-yaml](https://www.npmjs.com/package/js-yaml) has had no releases in over 3 years. Also, the fact it only supports YAML 1.2 is leading to bugs, since Kubernetes uses YAML 1.1 (see kubernetes/kubernetes#34146). This switches over to [yaml](https://www.npmjs.com/package/yaml), which had a release last month, is [licensed under ISC](https://github.com/eemeli/yaml/blob/main/LICENSE), and supports YAML 1.1. I also added test cases for the parsing/stringifying code. Signed-off-by: Mason Malone <[email protected]>
[js-yaml](https://www.npmjs.com/package/js-yaml) has had no releases in over 3 years. Also, the fact it only supports YAML 1.2 is leading to bugs, since Kubernetes uses YAML 1.1 (see kubernetes/kubernetes#34146). This switches over to [yaml](https://www.npmjs.com/package/yaml), which had a release last month, is [licensed under ISC](https://github.com/eemeli/yaml/blob/main/LICENSE), and supports YAML 1.1. I also added test cases for the parsing/stringifying code. Signed-off-by: Mason Malone <[email protected]>
Is this a request for help? (If yes, you should use our troubleshooting guide and community support channels, see http://kubernetes.io/docs/troubleshooting/.): No
What keywords did you search in Kubernetes issues before filing this one? (If you have found any duplicates, you should instead reply there.): is:issue yaml in:title version
Is this a BUG REPORT or FEATURE REQUEST? (choose one): Bug Report
Kubernetes version (use
kubectl version
): v1.3.7 (seems to be the same on master)What happened: I tried to apply a yaml file with
kubectl --context=minikube apply -f ./etc/deployment.yaml
and got a validation error. However the yaml is valid 1.2.The error is:
error validating "./etc/deployment.yaml": error validating data: expected type string, for field spec.template.spec.containers[2].command[6], got bool; if you choose to ignore these errors, turn validation off with --validate=false
What you expected to happen: kubectl should apply the deployment file
How to reproduce it (as minimally and precisely as possible):
Try to apply this object file:
Anything else do we need to know:
The "no" is the source of confusion for the program. In previous YAML versions this should be translated to be a boolean value, but in the current, 1.2, it should be a string "no". kubectl is using the older standard and translating this as a bool.
It is not so simple for me as to quote the "no" value like
'no'
- this object file is the output of another library which uses the 1.2 standard. We need to be aware that of course people will use various libraries to consume and produce yaml.I believe the problem can be traced from this https://github.com/ghodss/yaml to this source library here: https://github.com/cloudfoundry-incubator/candiedyaml/blob/master/resolver.go#L42
Should kubernetes only support YAML 1.2? It seems to me that we'd want to deprecate previous yaml support since YAML is not backwards compatible. YAML spec versions at: http://yaml.org/ - I have noticed that several of the online yaml validators also seem to get this "wrong".
The text was updated successfully, but these errors were encountered: