Skip to content

Could not delete default keys from subcharts if subchart is defined in dependencies #9027

Closed

Description

@jkroepke

Hi,

looking at docs https://helm.sh/docs/chart_template_guide/values_files/#deleting-a-default-key I'm able to remove keys from default values located in subcharts:

values.yaml:

# demo/values.yaml:
global:
  hash:
    key1: null
    key2: null
    key3: 13

subchart:
  hash:
    key1: null
    key2: null
    key3: 13
---
# demo/charts/subchart/values.yaml:
global:
  hash:
    key1: 1
    key2: 2
    key3: 3
    key4: 4
    key5: 5
    key6: 6

hash:
  key1: 1
  key2: 2
  key3: 3
  key4: 4
  key5: 5
  key6: 6

Output:

jkr@joe-nb demo % helm template .
---
# Source: demo/charts/subchart/templates/values.yaml
global:
  hash:
    key3: 13
    key4: 4
    key5: 5
    key6: 6
hash:
  key3: 13
  key4: 4
  key5: 5
  key6: 6

But If I add:

dependencies:
  - name: subchart
    version: 0.1.0

to the main Chart.yaml the behavior changes:

jkr@joe-nb demo % helm template .
---
# Source: demo/charts/subchart/templates/values.yaml
global:
  hash:
    key1: 1
    key2: 2
    key3: 13
    key4: 4
    key5: 5
    key6: 6
hash:
  key1: 1
  key2: 2
  key3: 13
  key4: 4
  key5: 5
  key6: 6

The merge of values is still working while removing key isn't working.
This bug exists on helm2 w/ requirements.yaml, too. Just for notice.

Output of helm version:

jkr@joe-nb demo % helm version  
version.BuildInfo{Version:"v3.4.0", GitCommit:"7090a89efc8a18f3d8178bf47d2462450349a004", GitTreeState:"dirty", GoVersion:"go1.15.3"}

Demo: chart.tar.gz (wrong file extension, its an uncompressed tar)

Activity

  1. bacongobbler commented on Nov 16, 2020

    @bacongobbler
    Member

    The attachment you provided is not a gzipped tarball, FYI. Just a tar file.

    ><> tar xzf chart.tar.gz
    
    gzip: stdin: not in gzip format
    tar: Child returned status 1
    tar: Error is not recoverable: exiting now
    

    tar xf chart.tar.gz works fine.

    I can reproduce this behaviour via the values file.

    /tmp/test-9027/demo ><> helm template .
    ---
    # Source: demo/charts/subchart/templates/values.yaml
    global:
      hash:
        key1: 1
        key2: 2
        key3: 13
        key4: 4
        key5: 5
        key6: 6
    hash:
      key1: 1
      key2: 2
      key3: 13
      key4: 4
      key5: 5
      key6: 6
    

    However, this can be worked around by setting a value via --set to null.

    /tmp/test-9027/demo ><> helm template . --set subchart.hash.key1=null,subchart.hash.key2=null
    ---
    # Source: demo/charts/subchart/templates/values.yaml
    global:
      hash:
        key1: 1
        key2: 2
        key3: 13
        key4: 4
        key5: 5
        key6: 6
    hash:
      key3: 13
      key4: 4
      key5: 5
      key6: 6
    

    This to me seems like something to do with the YAML parser where a null value is not received or parsed, whereas the --set parser can pick up these null values and propagate them down the tree as needed.

  2. added
    bug
    on Nov 16, 2020
  3. jkroepke commented on Nov 16, 2020

    @jkroepke
    Author

    Thanks for the info about the attachment, I add a note.

    If you are removing

    dependencies:
      - name: subchart
        version: 0.1.0
    

    from Chart.yaml everything works as expected.

    I don't know if the YAML parser is wrong here but it seems like there is a different code path if dependencies are defined.

  4. sbaier1 commented on Nov 23, 2020

    @sbaier1

    I am seeing a similar problem, except it's one layer deeper: I'm including loki-stack as a sub-chart, which then has the loki chart as a sub-chart.

    I am trying to remove the resulting loki-stack.loki.config.storage_config.filesystem key, which i can only do using helm template --set loki-stack.loki.config.storage_config.filesystem=null (as you also observed).

    The only practical workaround appears to be to extract the chart locally and remove the actual default value itself.

    Basic reproducer (helm version i used: v3.4.1):

    • Chart.yaml with the loki-stack chart as dependency
    • Override to delete in values.yaml:
    loki-stack:
      loki:
        config:
          storage_config:
            filesystem: null
    • Run template and check the loki secret
  5. jkroepke commented on Dec 7, 2020

    @jkroepke
    Author

    My workaround conflicts with

    #3585

    If no dependencies are defined, helm lint will fail.

  6. github-actions commented on Mar 8, 2021

    @github-actions

    This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

  7. jkroepke commented on Mar 8, 2021

    @jkroepke
    Author

    .

  8. github-actions commented on Jun 8, 2021

    @github-actions

    This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

  9. jkroepke commented on Jun 9, 2021

    @jkroepke
    Author

    .

  10. github-actions commented on Sep 9, 2021

    @github-actions

    This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

  11. 37 remaining items

  12. added a commit that references this issue on Jun 26, 2023
    0a5148f
  13. github-actions commented on Jun 27, 2023

    @github-actions

    This issue has been marked as stale because it has been open for 90 days with no activity. This thread will be automatically closed in 30 days if no further activity occurs.

  14. tspearconquest commented on Jun 27, 2023

    @tspearconquest

    /remove-lifecycle stale

  15. jkroepke commented on Jun 27, 2023

    @jkroepke
    Author

    Thanks for the info 👍

  16. krokofant commented on Jul 5, 2023

    @krokofant

    Here is my summary of some tests I've made. Will these cases be treated differently when #11440 or #12162 is merged?
    Tested with helm 3.11.3.
    global means the value is under the global i helm values.
    The number in the key is how deep the key is nested: myKey1, myKey2 etc.

    1. First is chart with library dep and explicit -f values.yaml
    2. Second is chart with library dep and without explicit -f values.yaml
    3. Third is chart without library dep and with explicit -f values.yaml
    4. Fourth is chart without library dep and without explicit -f values.yaml

    image

    values.yaml

    global:
      myKey1: ~
      foo:
        myKey2: ~
        bar:
          myKey3: ~
          baz:
            myKey4: ~
    
    myOtherKey1: ~
    foo:
      myOtherKey2: ~
      bar:
        myOtherKey3: ~
        baz:
          myOtherKey4: ~

    main.yaml

    # global myKey1: {{ hasKey .Values.global "myKey1" }}
    # global myKey2: {{ hasKey .Values.global.foo "myKey2" }}
    # global myKey3: {{ hasKey .Values.global.foo.bar "myKey3" }}
    # global myKey4: {{ hasKey .Values.global.foo.bar.baz "myKey4" }}
    # myOtherKey1: {{ hasKey .Values "myOtherKey1" }}
    # myOtherKey2: {{ hasKey .Values.foo "myOtherKey2" }}
    # myOtherKey3: {{ hasKey .Values.foo.bar "myOtherKey3" }}
    # myOtherKey4: {{ hasKey .Values.foo.bar.baz "myOtherKey4" }}
  17. added a commit that references this issue on Nov 6, 2023
    5356377
  18. rptaylor commented on Dec 14, 2023

    @rptaylor

    Removing keys in subcharts was supposed to be fixed by #12162 but the bug is still present in Helm 3.13.2 and 3.13.3: #12488

    The fix only works if --values is not used, so the "workaround" is to write your configuration changes into the default values.yml file without specifying it with --values or -f.

  19. turowicz commented on Dec 15, 2023

    @turowicz

    does it work for -f values-file.yaml @rptaylor ?

  20. rptaylor commented on Dec 15, 2023

    @rptaylor

    does it work for -f values-file.yaml @rptaylor ?

    No, the behaviour for -f and --values is the same.

  21. messiahUA commented on Jan 10, 2024

    @messiahUA

    I'm experiencing this issue or similar with a chart that has a dependency. Using helm v3.13.3, executing:
    helm template chart -f values1.yaml -f values2.yaml

    values1.yaml contains some key and values2.yaml sets this key to null, but helm doesn't remove the key.

  22. ravnalexquinn commented on Jan 24, 2024

    @ravnalexquinn

    Ignore the below please, I found the solution to my issue.

    I needed to set the cpu limits to null in my values.yaml file (specifically the file called 'values.yaml'). I was unable to override the default cpu limit values when using a file that I passed using '--values somefile.yaml', but was able to do it when I overwrote it in the main values.yaml


    original post:

    I'm also still seeing what seems to be the bug in v3.14.0

    The following is defined in the values.yaml of a dependency sub-chart:

    foo:
      resources:
        limits:
          cpu: 100m
          memory: 100Mi
        requests:
          cpu: 10m
          memory: 20Mi
    

    If I set the below in my chart's values yaml the cpu limit is not removed from the sub-chart's values as it should be:

    chartname:
      foo:
          resources:
            limits:
              cpu: null
              memory: 202Mi
            requests:
              cpu: 202Mi
              memory: 102Mi
    

    Applied using: helm template . --values my-values.yaml
    Also tried using: helm template . --set chartname.foo.resources.limits.cpu=null --values my-values.yaml to no avail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions