-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Fix multiple bugs in values handling #12162
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
Conversation
dd570de
to
d0c29d7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mattfarina this is really good!
One small removal of debugging
First, some notes about priority and how some code flow works. For Helm handling values, the expected order of precidence is: 1. User specified values (e.g CLI) 2. Imported values 3. Parent chart values 4. Subchart values Helm handles dependency values slightly differently. If there are dependencies in the charts folder that are not marked as dependencies all of the values, including nil values, are pulled in. If those charts are listed as a dependency in the Chart.yaml file than they are processed for import handling. Prior to the changes here, it caused nil values at the top level to NOT remove values specified. The changes: 1. The order of priority was chagned from the list above. Parnet chart values would override specifically imported values. This is due to a change from just over a year ago that introduced a bug. That was undone by changing the precidence when maps were merged. 2. To handle merging while retaining the nil values, which was causing inconsistent behavior, a new set of Merge functions were introduced. These functions are just like coalesce except that they DO NOT remove nil/null values. The new functions are used in a backward compatible manner meaning some new functions were introduced that called them. Specific issues fixed (that are known): Closes helm#9027 Can now delete subkeys from charts when specified in the parent. This behavior was previously inconsistent. Sometimes they could be deleted and other times it did not work. Now it is consistent. Closes helm#10899 Imported values (from library or other subcharts) are now used following the order above. The previous behavior was inconsistent. import-values using just a string would import them. When named with a child/parent it did not work if the parent already had a value. If string and named were mixed the imports worked if the string happened first but just for the string not the named. If the named parent/child went first then none of them worked for cases where the parent already had a value. It was inconsistent and the tests sometimes mirrored the functionality rather than expected behavior. Tests for this fall into the sub-packages and are in the template tests to verify it's happening in the output. Including having values passed at the CLI as the ultimate highest priority to be used. This relates to a fix that went in for helm#9940. The expected values there don't fit the precedence above where the parent value would override the imported value. That fix/change introduced more bugs. Closes helm#10052 This is the case where imported values using the parent/child designation just didn't work right. That has been fixed and there are tests. The underlying issue had to do with the precedence order handling. Note, a lot of tests were added. Hope we got it more right this time. Signed-off-by: Matt Farina <matt.farina@suse.com>
d0c29d7
to
0a5148f
Compare
@sabre1041 can you please re-review it? |
Thanks for jumping on this @mattfarina @sabre1041! 🚀 |
Minimal repro is:
chart values.yaml as
The null will persist through into the template |
@jamoflaw You bring up a good point. Thanks for providing a good example. Here are my thoughts...
Before removing all |
Signed-off-by: Matt Farina <matt.farina@suse.com>
@gjenkins8 @sabre1041 can you please re-review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! LGTM from me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@mattfarina Have you tested unsetting subchart keys with a Parent-to-child unset works: |
@benjaminjb I can reproduce this, but there's an additional nuance that's even more problematic. This doesn't just not fix the issue, it also introduces a new bug. I've attached a test script below, it:
for clarity, in this comment I'll be using the words "parent", "child", and "grandchild" in the absolute sense, as the names of the charts, not as relative terms to a prior reference.
|
@mattfarina should I move my comment to a new issue? For my use case this is a serious regression |
Adding to what @alice-sawatzky wrote: So from my tests: 3.13.0 |
The fix introduced together with my colleague @ankitabhopatkar13 in the above referenced #9940 is now reverted and broke our charts. I don't think it's wise to change these rather complex things and add it as an (unreferenced!) footnote in a release. For reference, this is now (again) broken: https://github.com/ankitabhopatkar13/helm-values-issue. Very curious if I am misinterpreting this. |
I am still seeing this issue in |
First, some notes about priority and how some code flow works.
For Helm handling values, the expected order of precedence is:
Helm handles dependency values slightly differently. If there are dependencies in the charts folder that are not marked as dependencies all of the values, including nil values, are pulled in. If those charts are listed as a dependency in the Chart.yaml file than they are processed for import handling. Prior to the changes here, it caused nil values at the top level to NOT remove values specified.
The changes:
The order of priority was changed from the list above. Parent chart values would override specifically imported values. This is due to a change from just over a year ago that introduced a bug. That was undone by changing the precedence when maps were merged.
To handle merging while retaining the nil values, which was causing inconsistent behavior, a new set of Merge functions were introduced. These functions are just like coalesce except that they DO NOT remove nil/null values. The new functions are used in a backward compatible manner meaning some new functions were introduced that called them.
Specific issues fixed (that are known):
Closes #9027
Can now delete subkeys from charts when specified in the parent. This behavior was previously inconsistent. Sometimes they could be deleted and other times it did not work. Now it is consistent.
Closes #10899
Imported values (from library or other subcharts) are now used following the order above.
The previous behavior was inconsistent. import-values using just a string would import them. When named with a child/parent it did not work if the parent already had a value. If string and named were mixed the imports worked if the string happened first but just for the string not the named. If the named parent/child went first then none of them worked for cases where the parent already had a value. It was inconsistent and the tests sometimes mirrored the functionality rather than expected behavior.
Tests for this fall into the sub-packages and are in the template tests to verify it's happening in the output. Including having values passed at the CLI as the ultimate highest priority to be used.
This relates to a fix that went in for #9940. The expected values there don't fit the precedence above where the parent value would override the imported value. That fix/change introduced more bugs.
Closes #10052
This is the case where imported values using the parent/child designation just didn't work right. That has been fixed and there are tests. The underlying issue had to do with the precedence order handling.
Note, a lot of tests were added. Hope we got it more right this time.
What this PR does / why we need it: import-values is broken which is causing a number of bugs (see above).
Special notes for your reviewer:
There have been changes around this code for years which has introduced bugs. Also, some of the old tests check for the wrong values. For example, expecting a value to be overridden but making sure it's the original value instead of the override. The system around import-values has long had issues and those issues have changed over time leading to long term inconsistency.
This change fixes some long standing issues. Some of which come up just under edge conditions (e.g., you use import-values but you use parent/child before using a string value and the parent has an existing value for the import).
If applicable: