Skip to content

Fixing regression for numeric values refs #6708 - #6709

Closed
osdrv wants to merge 1 commit into
helm:dev-v2from
osdrv:icanhazbroccoli/issue-6708
Closed

osdrv wants to merge 1 commit into
helm:dev-v2from
osdrv:icanhazbroccoli/issue-6708

Conversation

@osdrv

@osdrv osdrv commented Oct 19, 2019 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

This commit is a fix for the regression introduced in 2.15
with an attempt to carry all numeric values in json.Number container
(see #6708 for more details).

The fix overloads a series of Helm template functions:

  • int64
  • int
  • float64
  • add1
  • add
  • sub
  • div
  • mod
  • mul
  • max
  • min
  • ceil
  • floor
  • round
  • until
  • untilStep
  • splitn
  • abbrev
  • abbrevboth
  • trunc
  • substr
  • repeat
  • randAlphaNum
  • randAlpha
  • randAscii
  • randNumeric
  • wrap
  • wrapWith
  • indent
  • nindent
  • plural
  • slice
  • eq
  • gt
  • ge
  • lt
  • le
  • ne

The PR might need some polishing and refactoring: this is very much a first working fix.

Special notes for your reviewer:

If applicable:

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

@helm-bot helm-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Oct 19, 2019
@osdrv

osdrv commented Oct 19, 2019 •

Copy link
Copy Markdown
Contributor Author

Hey folks, my progress on this fix is pretty humble yet: the majority of numeric functions seems to have been fixed, but I'm still struggling implementing a workaround for comparison functions without a full re-definition of these monsters (https://golang.org/src/text/template/funcs.go#L441). I need to think over how these functions could be overloaded. From a brief look, the problem boils down to finding a way to reference and re-use corresponding citizens of template.builtins. In the meantime, if there are any hints on how it could be wrapped nicely, I'd be super happy to hear these. Thanks in advance!

@osdrv
osdrv force-pushed the icanhazbroccoli/issue-6708 branch from 764f354 to 57fea3e Compare October 20, 2019 08:40
@helm-bot helm-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 20, 2019
@osdrv

osdrv commented Oct 20, 2019 •

Copy link
Copy Markdown
Contributor Author

My progress so far:

  • numeric conversion functionality has been fixed: functions like int, int64, float64 etc are working (fixes issues like: --set=replicas=3 which is known to set the value to 0 in 2.15.0)
  • comparison functions are still broken for numeric arguments (only fixed for float64): the original builtins from text/template are context-dependant, I need to make overloaded functions to be smarter (TODO).

I am planning to work on fixing comparison functions and extending pkg/engine test suite. An ETA for this operation: a couple of days.

In the meantime, I'd really appreciate an early code review and feedback: it's super important for me to understand the core team has no strict objections against this approach. If there are objections, another rational solution would be to fully revert my earlier Number-converting patch so 2.15 can be unscrewed.

@helm-bot helm-bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Oct 21, 2019
@osdrv osdrv changed the title [WIP] Fixing regression for numeric values refs #6708 Fixing regression for numeric values refs #6708 Oct 21, 2019
@osdrv
osdrv marked this pull request as ready for review October 21, 2019 09:51
@osdrv
osdrv force-pushed the icanhazbroccoli/issue-6708 branch from c948afa to 53dea97 Compare October 21, 2019 09:53
@osdrv

osdrv commented Oct 21, 2019

Copy link
Copy Markdown
Contributor Author

Recent update on the fix: known reported issues seem to be addressed and fixed by this PR. Waiting for a review from the core team to figure out the next action points.

@osdrv
osdrv force-pushed the icanhazbroccoli/issue-6708 branch 2 times, most recently from d502834 to a9b2be7 Compare October 21, 2019 14:19
@osdrv
osdrv changed the base branch from master to dev-v2 October 21, 2019 19:03
@osdrv

osdrv commented Oct 21, 2019

Copy link
Copy Markdown
Contributor Author

#6721 might be related to the same regression and it has to be tested carefully before this PR could be counted safe to merge.

@osdrv
osdrv force-pushed the icanhazbroccoli/issue-6708 branch from a9b2be7 to e7a2367 Compare October 21, 2019 21:28
This commit is a fix for the regression introduced in 2.15
with an attempt to carry all numeric values in json.Number container
(see helm#6708 for more details).

The fix overloads a series of Helm template functions:
  * int64
  * int
  * float64
  * add1
  * add
  * sub
  * div
  * mod
  * mul
  * max
  * min
  * ceil
  * floor
  * round
  * until
  * untilStep
  * splitn
  * abbrev
  * abbrevboth
  * trunc
  * substr
  * repeat
  * randAlphaNum
  * randAlpha
  * randAscii
  * randNumeric
  * wrap
  * wrapWith
  * indent
  * nindent
  * plural
  * slice
  * eq
  * gt
  * ge
  * lt
  * le
  * ne

Corresponding test cases are included in the engine test suite.

Signed-off-by: Oleg Sidorov <[email protected]>
@osdrv
osdrv force-pushed the icanhazbroccoli/issue-6708 branch from e7a2367 to 9ed8bca Compare October 22, 2019 13:42

@bacongobbler bacongobbler left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thank you for the changes as well as the tests. My concern lies with having to overload every function that involves a numerical value, including any new functions that are introduced by sprig. Can we cast the json.Number to its native type before passing it as a value? That might prevent the need to wrap every function with a call to cast a json.Number to the expected type.

Given the changes involved in this PR, I'd be more inclined to revert the original commit than to introduce this code, and carry forward with a better fix in Helm 3. What do you think about that approach?

@osdrv

osdrv commented Oct 22, 2019 •

Copy link
Copy Markdown
Contributor Author

@bacongobbler I totally agree with you. Indeed, this looks like an overload madness to me as well: a small change that looked good turned to an absolute evil. I'd like to ask for 1 more evening of hacking to see if I can play with values the way you suggested above. If it doesn't work, I'm in favour of reverting the original commit. I'll update this PR shortly.

@bacongobbler bacongobbler added bug Categorizes issue or PR as related to a bug. v2.x Issues and Pull Requests related to the major version v2 labels 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 osdrv closed this Oct 22, 2019
@osdrv

osdrv commented Oct 22, 2019

Copy link
Copy Markdown
Contributor Author

Closed in favor of #6749

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
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Categorizes issue or PR as related to a bug. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. v2.x Issues and Pull Requests related to the major version v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants