Skip to content

Nested null values don't remove keys as expected #5184

Closed

Description

@aeijdenberg

#2648 allows for deletion of keys by setting null values in a values.yaml file. However it doesn't work for nested values, e.g.:

web:
  livenessProbe:
    httpGet: null
    exec:
      command:
      - curl
      - -f
      - http://localhost:8080/api/v1/info

Will not remove web.livenessProbe.httpGet from the original values, rather it just overrides the value with null and prints the warning:

2019/01/18 11:30:07 Warning: Merging destination map for chart 'concourse'. Cannot overwrite table item 'httpGet', with non table value: map[path:/api/v1/info port:atc]

Ironically, above is a small variant on the example given in the docs, which I'm pretty sure does not actually do what it claims to: https://docs.helm.sh/chart_template_guide/#deleting-a-default-key

I suspect that since the template rendering doesn't seem to differentiate much between a null value and a value not being specified, that this warnings are being ignored and not having much effect.

Output of helm version:

Client: &version.Version{SemVer:"v2.12.1", GitCommit:"02a47c7249b1fc6d8fd3b94e6b4babf9d818144e", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.12.1", GitCommit:"02a47c7249b1fc6d8fd3b94e6b4babf9d818144e", GitTreeState:"clean"}

Output of kubectl version:

Client Version: version.Info{Major:"1", Minor:"13", GitVersion:"v1.13.1", GitCommit:"eec55b9ba98609a46fee712359c7b5b365bdd920", GitTreeState:"clean", BuildDate:"2018-12-13T10:39:04Z", GoVersion:"go1.11.2", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.5-eks-6bad6d", GitCommit:"6bad6d9c768dc0864dab48a11653aa53b5a47043", GitTreeState:"clean", BuildDate:"2018-12-06T23:13:14Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}

Cloud Provider/Platform (AKS, GKE, Minikube etc.):

EKS

Activity

  1. bacongobbler commented on Jan 21, 2019

    @bacongobbler
    Member

    @scottrigby, do you by any chance want to take a gander at this one?

  2. bacongobbler commented on Jan 21, 2019

    @bacongobbler
    Member

    Marking as question/support until it's been confirmed that this is indeed a bug according to the original author.

  3. cprivitere commented on Jan 23, 2019

    @cprivitere

    I'm seeing this as well on 2.12.3. I'm seeing while trying to set the value to null via both -f and --set. Either way it just sets it to "null" as a string (without the quotes) rather than removing the default value.
    My situation:

    > helm get values grafana
    admin:
      existingSecret: ""
    chownDataImage:
      pullPolicy: null
      repository: null
      tag: null
    <...>
    
    > helm upgrade grafana stable/grafana --tls --reuse-values --set chownDataImage.pullPolicy=null
    <output indicating it works>
    
    > helm get values grafana
    admin:
      existingSecret: ""
    chownDataImage:
      pullPolicy: null
      repository: null
      tag: null
    <...>
    

    Use case is to reset these values to use the defaults from the template instead of the defaults now stuck in helm.

  4. cdenneen commented on Mar 26, 2019

    @cdenneen

    stable/filebeat

    With null or nil I'm seeing the same thing... the key isn't removed... it's overwritten as null/nil but not removed and when you are replacing it with different key it causes problem:

    ---values.yml in the Chart
    output.file:
      path: /var/log/foo.log
    ---my overrides
    output.elasticsearch:
       hosts:
          - 'http://localhost:9200'
    output.file: null

    or

    ---my overrides
    output:
      elasticsearch:
         host:
          - 'http://localhost:9200'
      file: null

    or

    ---my overrides
    output:
      elasticsearch:
         hosts:
          - 'http://localhost:9200'
    output.file: null
    » k get secret filebeat -o jsonpath="{.data.filebeat\.yml}" | base64 -D
        filebeat.config:
          modules:
            path: ${path.config}/modules.d/*.yml
            reload.enabled: false
          prospectors:
            path: ${path.config}/prospectors.d/*.yml
            reload.enabled: false
        filebeat.prospectors:
        - enabled: true
          fields:
            apenv: dev
            app: kubernetes
            log_category: kubernetes
          fields_under_root: true
          paths:
          - /var/log/*.log
          - /var/log/messages
          - /var/log/syslog
          type: log
        - containers.ids:
          - '*'
          fields:
            apenv: dev
            app: kubernetes
            log_category: kubernetes
          fields_under_root: true
          processors:
          - add_kubernetes_metadata:
              in_cluster: true
          - drop_event:
              when:
                equals:
                  kubernetes.container.name: filebeat
          type: docker
        http.enabled: true
        http.port: 5066
        output:
          elasticsearch:
            hosts:
            - http://localhost9200
        output.file: null
        processors:
        - add_cloud_metadata: null
    

    pod errors as:

    Exiting: error unpacking config data: more than one namespace configured accessing 'output' (source:'filebeat.yml')
    
  5. PosicubeBeege commented on Apr 2, 2019

    @PosicubeBeege

    I'm also encountering this exact issue with the filebeat chart.

    @cdenneen You can get around file output specifically with config.output.file.enabled=false.

    I'm encountering an issue where I want to use the new inputs key for filebeat but cannot remove the prospectors key.

    Existing values:

    config:
      filebeat.prospectors:
        - type: log
          enabled: true
          paths:
            - /var/log/*.log
            - /var/log/messages
            - /var/log/syslog
    

    My override: --set config.filebeat.prospectors=null

    Result: (config is used to set a Secret value)

    filebeat:
      prospectors: null
    
  6. pjanuario commented on Apr 20, 2019

    @pjanuario

    I also encountered this problem with stable/kibana and stable/filebeat the keys will default to the chart values even when !!null is specified.

  7. cdenneen commented on Apr 20, 2019

    @cdenneen

    @aeijdenberg believe your PR just requires labels updated to be reviewed

  8. scottrigby commented on Apr 22, 2019

    @scottrigby
    Member

    Hey @bacongobbler sorry I missed your question in #5184 (comment). I can verify it is a bug. In #2648 I really should have added a test that matched the documented example. I had meant to get back to this but #5185 looks promising! 👏 will respond over there

  9. added
    bug
    and removed on Apr 22, 2019
  10. wxdao commented on Jun 21, 2019

    @wxdao
    Contributor

    Hi @scottrigby . May I know which release will include #5185's fix? I just encountered this problem when trying to remove resources definitions on istio chart.

  11. cc-stjm commented on Jul 26, 2019

    @cc-stjm

    This is supposed to be in 2.14.2 - but I can't get it to work.

    I'm following a very similar example to that at the top of the issue - the only difference I can see is that I'm trying to delete a value set in a subchart (in my case, logstash).

    I have tried:

    • setting logstash.livenessProbe.httpGet to null, ~ and {} in the main chart's values.yaml, or on the command line. In both cases, "helm template" shows that the original value is still there (i.e. I'm still getting httpGet set) - and this is consistent with what I see for "helm install"
    • setting logstash.livenessProbe.httpGet to "nil" - in this case the value does get overwritten, but to the string "nil" which isn't a valid value to use here, so kubernetes rejects the template.

    Have I misunderstood and this didn't make it into 2.14.2 - or is there still an issue?

    (Chart demonstrating this: demo.zip)

  12. bacongobbler commented on Jul 26, 2019

    @bacongobbler
    Member

    The patch was cherry-picked into 2.14.2 according to the release notes so it should be available.

  13. 30 remaining items

  14. BohdanKalytka commented on Dec 11, 2020

    @BohdanKalytka

    The issue is still present in 3.4.2, but only in certain situations.
    I have a chart with multiple sub-charts.
    When putting default into sub chart values null override does not work. If you move the same values into parent chart values it works as expected.
    This is reproducible only with sub-charts. When you put it in a single (flat) chart everything works fine.

  15. alexrashed commented on Dec 16, 2020

    @alexrashed

    I am experiencing the same problem with 3.4.2 when using subcharts (as described by @BohdanKalytka above).
    In my case I want to overwrite the securityContext when using the ElasticSearch helm chart in an OpenShift cluster.
    Is this issue going to be reopened, or should we create a new one?

  16. elliotkennedy commented on Dec 17, 2020

    @elliotkennedy

    Raised #9136

  17. MatteoInfi commented on Jul 13, 2021

    @MatteoInfi

    still bugged in 3.5.4

  18. armandleopold commented on Sep 28, 2021

    @armandleopold

    Still exist in

    HELM_VERSION="v3.6.3"
    

    Can someone reopen the issue and fix it please ?

  19. kineta-Jiang commented on Dec 21, 2021

    @kineta-Jiang

    Still exist in

    HELM_VERSION="v3.7.1"
    Can someone reopen the issue and fix it please ?

  20. sebastianblunt commented on Dec 21, 2021

    @sebastianblunt

    The reopened issue is #9136

  21. scalalang2 commented on Feb 21, 2022

    @scalalang2

    Still exist in v3.7.2

  22. hosswald commented on Aug 4, 2022

    @hosswald

    Still exists in v3.9.2

  23. kopylash commented on Feb 17, 2023

    @kopylash

    Still exists in 3.11.1
    Reproducible only with subcharts

  24. korniltsev commented on Sep 12, 2023

    @korniltsev

    still exists in 3.12.3

  25. korniltsev commented on Sep 12, 2023

    @korniltsev

    repro:
    pyroscope-folder.zip
    fsGroup and runAsUser null values are not removed

    helm upgrade release-1 pyroscope-folder  --dry-run  --install > run1   
    helm upgrade release-1 pyroscope-folder --values pyroscope-folder/values.yaml --dry-run  --install > run2 
    
    diff -u run1 run2
    --- run1        2023-09-12 18:26:31.238211712 +0700
    +++ run2        2023-09-12 18:27:28.071648302 +0700
    @@ -1,6 +1,6 @@
     Release "release-1" does not exist. Installing it now.
     NAME: release-1
    -LAST DEPLOYED: Tue Sep 12 18:26:26 2023
    +LAST DEPLOYED: Tue Sep 12 18:26:51 2023
     NAMESPACE: default
     STATUS: pending-install
     REVISION: 1
    @@ -194,9 +194,7 @@
         spec:
           serviceAccountName: release-1-pyroscope
           securityContext:
    -        fsGroup: 10001
             runAsNonRoot: true
    -        runAsUser: 10001
           containers:
             - name: "pyroscope"
               securityContext:
    
    
  26. ccmcbeck commented on Oct 25, 2023

    @ccmcbeck

    still exists in 3.12.3

    While I was unable to override a default subcharted value with foo: nil, I was able to override with foo: "".

  27. jobo-prod commented on Nov 27, 2023

    @jobo-prod

    Still having this issue in Helm v3.13.2. Unfortunately I cannot use @ccmcbeck's workaround, because the particular value is not fenced with an if in the template and the value must be of type integer.

    Overwriting the default value with null/nil (which does not work atm) is the only option I see here.

  28. rodrigoechaide commented on Dec 13, 2023

    @rodrigoechaide

    I have created a new issue because this problem persists in the latest version of Kubernetes.

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