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
Can't create pods from yaml template #2763
Comments
/cc @ghodss |
I believe if you wrap 1234 in quotes it will work, but this is definitely a On Friday, December 5, 2014, bgrant0607 notifications@github.com wrote:
Sam |
Unfortunately this is a real bug in the new way YAML is being decoded. If you recall from #2600, the way we handle YAML now is to convert it to JSON then unmarshal using JSON. The problem is that YAML is less specific than JSON so if you have a YAML value of 1234, go-yaml assumes it's an int and encodes it as such, then when it's converted to JSON it's kept as an int, then when it's attempted to be unmarshaled into a string, Go errors. I am working on a fix right now and will have something by Sunday. If this is urgent in the mean time, one workaround is to wrap the string value (in this case the env var value) in quotes, and the other is to rollback the YAML change (#2676). I am fine with a rollback if this is not an acceptable bug for the next 48 hours. There may just be some merge conflicts because of all the YAML tag changes but those should be easy to resolve. Let me know if there's anything else I can do in the mean time. |
Okay I have this fixed locally, but need to write a few more tests. I will have a PR ready by midday today. |
Thanks for working on this guys. Just ran into this myself. |
Still happening, boolean will also not work if it is not quoted. |
@pencilcheck Got example? |
An example:
The version has to be quoted in order for it to pass, however I don't need for port and targetPort. |
It's all about the underlying struct types. port/targetPort are of type "IntOrString", which can deserialize from strings or ints. "selector" is a map of strings to strings, so the values have to be strings (and therefore quoted if all numeric, per yaml rules) |
In fact @pencilcheck is right, |
I had to quote the new, coincidentally fully-numeric version number due to kubernetes/kubernetes#2763 which I believe hasn't yet been released. #254
I had to quote the new, coincidentally fully-numeric version number due to kubernetes/kubernetes#2763 which I believe hasn't yet been released. #254
This is still an issue and should be resolved by the Kubernetes team. I cannot specify environment variables with integer values. Integer values are perfectly valid YAML and JSON, so the issue is Kubernetes. I should not have to quote integer values in a YAML file. What's worse is the inconsistency. This seems to work for port values, replicas, etc, but still not in environment variables. This should be allowed as it is perfectly valid YAML AND JSON (when converted):
Yet, apply complains:
|
A basic bug, four years in the running, still not fixed in 1.6+. Any word on when this will be fixed? |
it is not likely to be fixed. you must specify your types correctly in the yaml. the client is converting to json and sending to the API without knowledge of the struct types, and sending an int value for a string field is incorrect. |
But the format is legal YAML, where numerics are entirely legal. It's likely the JSON conversion is flawed. |
It is ambiguous whether the value is a string or a number. |
How is it ambiguous when most processors handle this? Why is it inconsistent across other fields where an integer value is allowed? |
Yeah, I don't understand this. As a Golang developer myself, the YAML processors out of the box handle numerics flawlessly, and preserve them as numerics. And when I use a standard JSON processor to write a JSON file from the hash, it works flawlessly. I don't get why this is being debated. It's a bug. |
Because the client has to send JSON to the API, and is converting YAML to JSON generically without the schema that tells it whether the field is a string or an int. It would be incorrect to assume the destination field was a string. Quoting the YAML types the data |
It's amazing how easy this seems to handle integers going from yaml to json. It seems to me that Google is just not interested in spending the effort to figure out something is a number. |
JSON to YAML is easy. YAML to JSON is ambiguous |
So again, you figure it out. This converter seems to handle it flawlessly, even with exponent notation. There's only so many scenarios needed to determine something is a number. Hell, if you don't want to figure it out, why don't you just take whatever value we've given and pop it into a string behind the scenes? It's just being used to set an environment variable so at the end of the day it DOESN'T MATTER. |
Kubectl does exactly what this converter does, preserving numerics. If you paste the snippet in question into the convertor, you get this JSON:
That's exactly what kubectl is converting to and submitting to the API, and what the API is rejecting, because |
Then either: |
I'm able to use numbers without quoting by prefixing values with Ex:
|
With apiserver HEAD, creating pod from this yml template fails:
The text was updated successfully, but these errors were encountered: