Skip to content

Cannot remove objects in dependent charts by setting values to null #12991

@zsolt-marta-bitrise

Description

@zsolt-marta-bitrise

We're seeing that we cannot remove objects in dependent charts by setting the values to null , they will still get included in the result.

This used to work before, and this is causing apps deployed using ArgoCD to fail on probes getting introduced incorrectly (as they are defined in the dependent charts and cannot be nulled out).
This works well in ArgoCD 2.9.1, bot not in 2.9.2 which upgraded helm from 3.12.1 to 3.13.2, so the issue got introduced between those versions. I suspect this has to do something with this PR. The default template ProcessDependencies() got replaced with ProcessDependenciesWithMerge(), which ultimately does not remove null keys.

Related issues:

Issue

After running helm template . -f values.yaml in helm-issue (see setup below) and values.yaml:

helm-dep:
  port: null
  • Got:
...
 spec:
      containers:
        - image: nginx:alpine
          name: nginx
          resources: {}
          ports:
            - containerPort: 80
              protocol: TCP
              name: http
  • Want:
...
 spec:
      containers:
        - image: nginx:alpine
          name: nginx
          resources: {}

Please ignore that this is not functional this way, this is just to demonstrate the issue. In our real use case, this is causing probes getting incorrectly introduced, failing deployments in newer ArgoCD versions.


Note: we get the correct result if we do

helm-dep:
  port: ""

Minimal setup:

  • helm-issue/Chart.yaml:
---
apiVersion: v2
appVersion: "0.1.27"
description: A Helm chart that demonstrates nulling issue
name: helm-issue
version: "0.1.0"
dependencies:
  - name: helm-dep
    version: "0.1.0"
    repository: "file://../helm-dep"
  • helm-issue/values.yaml:
helm-dep:
  port: null
  • helm-dep/templates/deployment.yaml:
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: helmtest
  name: {{ .Release.Name }}
  namespace: {{ .Release.Namespace }}
spec:
  replicas: 1
  selector:
    matchLabels:
      app: helmtest
  template:
    metadata:
      labels:
        app: helmtest
    spec:
      containers:
        - image: nginx:alpine
          name: nginx
          resources: {}
          {{- with .Values.port }}
          ports:
              - containerPort: {{ .containerPort }}
                protocol: TCP
                name: {{ .name }}
          {{- end }}
  • helm-dep/Chart.yaml:
---
apiVersion: v2
appVersion: "0.1.27"
description: A Helm subchart that demonstrates nulling issue
name: helm-dep
version: "0.1.0"
  • helm-dep/values.yaml:
port:
  containerPort: 80
  name: http

(Of course, helm dependency update has to be run)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugCategorizes issue or PR as related to a bug.keep open

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions