pulumi-kubernetes icon indicating copy to clipboard operation
pulumi-kubernetes copied to clipboard

Empty array value ignored in Helm Chart

Open kwohlfahrt opened this issue 2 years ago • 2 comments

What happened?

I tried to deploy a helm chart, setting a config key to an empty array value (i.e. []). The key was omitted entirely.

Steps to reproduce

Only the second step is really needed, but doing the first one makes the output of pulumi preview --diff show the issue clearly.

Deploy a Helm chart, where a key is set to a non-empty value. For example, this one:

new k8s.helm.v3.Release(
  "aws-efs-csi-driver",
  {
    chart: "aws-efs-csi-driver",
    version: "2.2.7",
    repositoryOpts: { repo: "https://kubernetes-sigs.github.io/aws-efs-csi-driver" },
    values: { node: { tolerations: [{key: "foo"}] } },
  },
);

Then, set the key to an empty value:

new k8s.helm.v3.Release(
  "aws-efs-csi-driver",
  {
    chart: "aws-efs-csi-driver",
    version: "2.2.7",
    repositoryOpts: { repo: "https://kubernetes-sigs.github.io/aws-efs-csi-driver" },
    values: { node: { tolerations: [] } }, // THIS LINE CHANGED!
  },
);

Preview the second change, with pulumi preview --diff.

Expected Behavior

I expect to see the tolerations key replaced with an empty array, probably like so (though I can't generate actual output due to this bug):

  pulumi:pulumi:Stack: (same)
    [urn=urn:pulumi:kai::k8s::pulumi:pulumi:Stack::k8s-kai]
    ~ kubernetes:helm.sh/v3:Release: (update)
        [id=aws/aws-efs-csi-driver-bd73cca4]
        [urn=urn:pulumi:kai::k8s::kubernetes:helm.sh/v3:Release::aws-efs-csi-driver]
        [provider=urn:pulumi:kai::k8s::pulumi:providers:kubernetes::k8s::3c98ce34-0966-4049-9301-d9ec94fa8194]
      ~ values: {
          ~ node: {
              ~ tolerations: [
              -     [0]: {
                      - key: "foo"
                    }
                ]
            }
        }

Actual Behavior

The tolerations key is deleted entirely (note the symbol in front of tolerations is a -, I expected a ~).

  pulumi:pulumi:Stack: (same)
    [urn=urn:pulumi:kai::k8s::pulumi:pulumi:Stack::k8s-kai]
    ~ kubernetes:helm.sh/v3:Release: (update)
        [id=aws/aws-efs-csi-driver-bd73cca4]
        [urn=urn:pulumi:kai::k8s::kubernetes:helm.sh/v3:Release::aws-efs-csi-driver]
        [provider=urn:pulumi:kai::k8s::pulumi:providers:kubernetes::k8s::3c98ce34-0966-4049-9301-d9ec94fa8194]
      ~ values: {
          ~ node: {
              - tolerations: [
              -     [0]: {
                      - key: "foo"
                    }
                ]
            }
        }

Versions used

CLI          
Version      3.36.0
Go Version   go1.17.11
Go Compiler  gc

Plugins
NAME        VERSION
aws         5.10.0
kubernetes  3.20.0
nodejs      unknown
tls         4.6.0

Host     
OS       darwin
Version  12.4
Arch     arm64

This project is written in nodejs: executable='/Users/kai/.nix-profile/bin/node' version='v16.15.0'

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/kwohlfahrt
User           kwohlfahrt
Organizations  kwohlfahrt, CHARM-Tx

Dependencies:
NAME                VERSION
@pulumi/aws         5.10.0
@pulumi/kubernetes  3.20.0
@pulumi/pulumi      3.36.0
@pulumi/tls         4.6.0
@types/node         14.18.22
ts-node             10.9.1
typescript          4.7.4
zod                 3.17.3

Pulumi locates its logs in /var/folders/3b/r11hff0x1335_th38vhwwmbh0000gn/T/ by default

Additional context

This may be caused by the same underlying issue as #2034.

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

kwohlfahrt avatar Jul 18 '22 17:07 kwohlfahrt

Thanks for the bug report! This seems to be caused due to our exclusion of nulls in values: https://github.com/pulumi/pulumi-kubernetes/blob/51823626f0627b74c7c6566f1e7ce7da998a1861/provider/pkg/provider/helm_release.go#L1285. We can probably relax this but will need to test and validate that is true.

viveklak avatar Jul 19 '22 21:07 viveklak

This issue is affecting me as I attempt to use Pulumi to manage helm deployments of Apache Superset. That chart has an ingress.tls value that must be set even if it is empty.

Noting the comment above, I thought I'd see if I could get a patch working to allow one to optionally pass null values through mergeMaps. I'm unable to get tests passing on the master branch at the moment (though the build and install steps all seem to work fine), so I definitely haven't figured out how I can install and test the patched branch locally.

However, I figured I'd put this link up- if anyone has any advice or comments, I'm all ears. Please bear with me as I am not a Go developer :)

https://github.com/cdibble/pulumi-kubernetes/pull/1/files

cdibble avatar Sep 27 '22 23:09 cdibble

This was fixed in https://github.com/pulumi/pulumi-kubernetes/pull/2220 -- thanks to @cdibble for the PR!

lblackstone avatar Nov 15 '22 00:11 lblackstone