You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Due to discrepancies between Go YAML and Ruby YAML (psych), we have run into deployment failures when YAML contains strings that encapsulate numbers with a specific variants of scientific/e-notation format. The discrepancy lies in the fact that Go's YAML parser (mostly) follows YAML 1.2, which accepts a wider range of scientific/e-notation variants as compared to psych. Despite having properly encapsulated (quoted) our string, the final output that Krane pushes to K8s API server is interpreted as a number, rather than a string. This causes K8s to reject the patch.
Example input fragment:
...
env:
- name: FOO
- value: "1e3"
Resulting JSON patch applied to Kubernetes:
"env":[{"name":"FOO","value":1000}]
Changing the number format is not a workaround for us, since this has been triggered in the real world with ENV vars that contain hex-formatted API keys that just happen to have the form <digits>'e'<digits>.
Expected behaviour:
Krane preserves encapsulation (quotes) for string scalars that would otherwise be interpreted as numbers.
Actual behaviour:
Krane serializes strings that without encapsulation, causing any YAML 1.2-compliant consumers to read a number.
Version(s) affected: [run krane version]
krane 1.1.4 (AFAIK it has always been broken)
Steps to Reproduce
Using Kubenetes 1.15+ client and server.
Create a deployment spec that includes an ENV var with double-quoted value: "1e3".
Run krane deploy <namespace> <context> -f <deployment_file>
Proposal:
We have faced similar problems with other internal tools at Shopify, and the workaround has been to monkey-patch Psych.dump/dump_stream to massage the YAML. I can prepare a PR for consideration. As this is public-facing OSS, I cannot push such hacks without consensus from primary maintainers.
The text was updated successfully, but these errors were encountered:
jpfourny
changed the title
krane deploy ignores quotes in strings that encapsulate scientific/e-notation formatted numbers
YAML string scalars with scientific/e-notation numeric format not properly quoted
Aug 22, 2020
Bug report
Due to discrepancies between Go YAML and Ruby YAML (psych), we have run into deployment failures when YAML contains strings that encapsulate numbers with a specific variants of scientific/e-notation format. The discrepancy lies in the fact that Go's YAML parser (mostly) follows YAML 1.2, which accepts a wider range of scientific/e-notation variants as compared to psych. Despite having properly encapsulated (quoted) our string, the final output that Krane pushes to K8s API server is interpreted as a number, rather than a string. This causes K8s to reject the patch.
Example input fragment:
Resulting JSON patch applied to Kubernetes:
"env":[{"name":"FOO","value":1000}]
Changing the number format is not a workaround for us, since this has been triggered in the real world with ENV vars that contain hex-formatted API keys that just happen to have the form
<digits>'e'<digits>
.Expected behaviour:
Krane preserves encapsulation (quotes) for string scalars that would otherwise be interpreted as numbers.
Actual behaviour:
Krane serializes strings that without encapsulation, causing any YAML 1.2-compliant consumers to read a number.
Version(s) affected: [run
krane version
]krane 1.1.4 (AFAIK it has always been broken)
Steps to Reproduce
krane deploy <namespace> <context> -f <deployment_file>
Proposal:
We have faced similar problems with other internal tools at Shopify, and the workaround has been to monkey-patch Psych.dump/dump_stream to massage the YAML. I can prepare a PR for consideration. As this is public-facing OSS, I cannot push such hacks without consensus from primary maintainers.
The text was updated successfully, but these errors were encountered: