Skip to content

chartutil.ReadValues is forced to unmarshal numbers into json.Number refs #1707 - #6010

Merged
bacongobbler merged 2 commits into
helm:masterfrom
osdrv:icanhazbroccoli/chartutil-no-scientific-notation
Jul 17, 2019
Merged

bacongobbler merged 2 commits into
helm:masterfrom
osdrv:icanhazbroccoli/chartutil-no-scientific-notation

Conversation

@osdrv

@osdrv osdrv commented Jul 11, 2019 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

This change is an attempt to address the common problem of json number
unmarshalling where any number is converted into a float64 and
represented in a scientific notation on a marshall call. This behavior
breaks things like: chart versions and image tags if not converted to
yaml strings explicitly.

An example of this behavior: k8s failure to fetch an image tagged with a
big number like: $IMAGE:20190612073634 after a few steps of yaml
re-rendering turns into: $IMAGE:2.0190612073634e+13.

Example issue: #1707

This commit forces yaml parser to use JSON modifiers and explicitly
enables interface{} unmarshalling instead of float64. The change
introduced might be breaking so should be processed with an extra care.

Due to the fact helm mostly dals with human-produced data (charts), we
have a decent level of confidence this change looses no functionality
helm users rely upon (the scientific notation).

Relevant doc: https://golang.org/pkg/encoding/json/#Decoder.UseNumber

Signed-off-by: Oleg Sidorov [email protected]

Special notes for your reviewer:

If applicable:

  • this PR contains documentation
  • this PR contains unit tests
  • this PR has been tested for backwards compatibility

This change is an attempt to address the common problem of json number
unmarshalling where any number is converted into a float64 and
represented in a scientific notation on a marshall call. This behavior
breaks things like: chart versions and image tags if not converted to
yaml strings explicitly.

An example of this behavior: k8s failure to fetch an image tagged with a
big number like: $IMAGE:20190612073634 after a few steps of yaml
re-rendering turns into: $IMAGE:2.0190612073634e+13.

Example issue: #1707

This commit forces yaml parser to use JSON modifiers and explicitly
enables interface{} unmarshalling instead of float64. The change
introduced might be breaking so should be processed with an extra care.

Due to the fact helm mostly dals with human-produced data (charts), we
have a decent level of confidence this change looses no functionality
helm users rely upon (the scientific notation).

Relevant doc: https://golang.org/pkg/encoding/json/#Decoder.UseNumber

Signed-off-by: Oleg Sidorov <[email protected]>
@helm-bot helm-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 11, 2019
@bacongobbler bacongobbler added the Needs v3 backport Label PRs for v4/main, which are still applicable to v3 so need a separate backport PR label Jul 11, 2019
@bacongobbler

Copy link
Copy Markdown
Member

Wow... That's a surprisingly simple patch to fix this issue. Nice catch.

Would you be willing to port this over to the dev-v3 branch as well? That way we can get this fix in for Helm 3. Thanks!

@bacongobbler

Copy link
Copy Markdown
Member

It turns out that this breaks certain unit tests from passing, however. Would you mind looking into the failing tests?

@osdrv

osdrv commented Jul 11, 2019

Copy link
Copy Markdown
Contributor Author

@bacongobbler I really appreciate your instant reply! I'm working on the failing tests atm, will push a fix once I've figured out what's up. Will port the change to dev-v3 with pleasure if the change makes sense to you folks.

@helm-bot helm-bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 11, 2019
@osdrv

osdrv commented Jul 12, 2019 •

Copy link
Copy Markdown
Contributor Author

A quick update on this PR: the recent fix seems to look quite promising for master and 2.x branches.
dev-v3 seems to be a more complicated case: the package dependency graph resolves ghodss/yaml library to version 1.0.0, which is missing the essential commit: ghodss/yaml@8aa0426#diff-e51f89b39d976550831afb510a926be0. This library has never issued any other releases since 1.0.0, so it's a bit clumsy. There is an open issue regarding bumping the version: ghodss/yaml#50, but it doesn't seem to be moving forward actively.

Dependency declarators I've identified so far:

In the current state of dev-v3 one of these components resolves yaml library to 1.0.0, not to c7ce16629ff4. Once it's fixed, the fix porting should be pretty trivial. I'll try to resolve it some time soon and update this thread.

@osdrv

osdrv commented Jul 17, 2019

Copy link
Copy Markdown
Contributor Author

Hey folks, as #6016 and #6032 got merged into dev-v3, I believe the porting job is done. Please let me know if there are any other action points on my side in regards to this PR or if I can provide any other help. Thanks!

@bacongobbler
bacongobbler merged commit 88bb48b into helm:master Jul 17, 2019
@osdrv

osdrv commented Jul 17, 2019

Copy link
Copy Markdown
Contributor Author

@bacongobbler <3

@hickeyma hickeyma left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks. Tested before and after fix and show number handled as expected.

@bacongobbler bacongobbler removed the Needs v3 backport Label PRs for v4/main, which are still applicable to v3 so need a separate backport PR label Jul 17, 2019
@mattfarina mattfarina added the Needs v3 backport Label PRs for v4/main, which are still applicable to v3 so need a separate backport PR label Aug 5, 2019
@thomastaylor312 thomastaylor312 added the v3 port complete For completed v2->v3 ports label Aug 8, 2019
@bacongobbler bacongobbler added this to the 2.15.0 milestone Oct 18, 2019
jmlrt added a commit to jmlrt/helm-charts that referenced this pull request Oct 22, 2019
osdrv pushed a commit to osdrv/helm that referenced this pull request Oct 22, 2019
This commit reverts changes introduced in helm#6010 due to a massive
regression reported in helm#6708. An attempt to fix the problem in
helm#6709 seems to be unreasonably clumzy
and hacky, therefore reverting the offensive change seems to be the most
pragmatic solution.

This reverts commits:
  * 70cd32c.
  * 9014bd9.
osdrv pushed a commit to osdrv/helm that referenced this pull request Oct 22, 2019
This commit reverts changes introduced in helm#6010 due to a massive
regression reported in helm#6708. An attempt to fix the problem in
helm#6709 seems to be unreasonably clumzy
and hacky, therefore reverting the offensive change seems to be the most
pragmatic solution.

This reverts commits:
  * 70cd32c.
  * 9014bd9.

Signed-off-by: Oleg Sidorov <[email protected]>
bacongobbler pushed a commit that referenced this pull request Oct 22, 2019
bacongobbler pushed a commit that referenced this pull request Oct 22, 2019
This commit reverts changes introduced in #6010 due to a massive
regression reported in #6708. An attempt to fix the problem in
#6709 seems to be unreasonably clumzy
and hacky, therefore reverting the offensive change seems to be the most
pragmatic solution.

This reverts commits:
  * 70cd32c.
  * 9014bd9.

Signed-off-by: Oleg Sidorov <[email protected]>
galina-tochilkin pushed a commit to mtp-devops/3d-party-helm that referenced this pull request Dec 20, 2022
@gjenkins8 gjenkins8 removed the Needs v3 backport Label PRs for v4/main, which are still applicable to v3 so need a separate backport PR label Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Denotes a PR that changes 30-99 lines, ignoring generated files. v3 port complete For completed v2->v3 ports

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants