Skip to content
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

Helm renderer doesn't abort or function early #11070

Closed
Scarjit opened this issue Jun 22, 2022 · 4 comments
Closed

Helm renderer doesn't abort or function early #11070

Scarjit opened this issue Jun 22, 2022 · 4 comments

Comments

@Scarjit
Copy link

Scarjit commented Jun 22, 2022

When evaluating this yaml file helm crashes.

---
{{if or .Values.mqtttopostgresql.enabled .Values._000_commonConfig.datastorage.enabled }}


{{if or (not .Values.mqtttopostgresql.pdb) (and .Values.mqtttopostgresql.pdb (.Values.mqtttopostgresql.pdb.enabled | default true))}}

apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
  name: {{include "united-manufacturing-hub.fullname" .}}-mqtttopostgresql-pdb
spec:
  minAvailable: {{.Values.mqtttopostgresql.pdb.minAvailable | default 1}}
  selector:
    matchLabels:
      name: {{include "united-manufacturing-hub.fullname" .}}-mqtttopostgresql

{{end}}
{{end}}

.Values.mqtttopostgresql.enabled is true, same for .Values._000_commonConfig.datastorage.enabled

.Values.mqtttopostgresql.pdb is nil, therefor the or operator should do an early return, since not nil should return true

(venv) PS E:\UMH\UMHStack\deployment\united-manufacturing-hub> helm install united-manufacturing-hub . -n united-manufacturing-hub --dry-run --debug > test.yaml
install.go:178: [debug] Original chart version: ""
install.go:195: [debug] CHART PATH: E:\UMH\UMHStack\deployment\united-manufacturing-hub

Error: INSTALLATION FAILED: template: united-manufacturing-hub/templates/mqtttopostgresql/pdb.yaml:5:85: executing "united-manufacturing-hub/templates/mqtttopostgresql/pdb.yaml" at <.Values.mqtttopostgresql.pdb.enabled>: nil pointer evaluating interface {}.enabled      
helm.go:84: [debug] template: united-manufacturing-hub/templates/mqtttopostgresql/pdb.yaml:5:85: executing "united-manufacturing-hub/templates/mqtttopostgresql/pdb.yaml" at <.Values.mqtttopostgresql.pdb.enabled>: nil pointer evaluating interface {}.enabled
INSTALLATION FAILED
main.newInstallCmd.func2
        helm.sh/helm/v3/cmd/helm/install.go:127
github.com/spf13/cobra.(*Command).execute
        github.com/spf13/cobra@v1.4.0/command.go:856
github.com/spf13/cobra.(*Command).ExecuteC
        github.com/spf13/cobra@v1.4.0/command.go:974
github.com/spf13/cobra.(*Command).Execute
        github.com/spf13/cobra@v1.4.0/command.go:902
main.main
        helm.sh/helm/v3/cmd/helm/helm.go:83
runtime.main
        runtime/proc.go:255
runtime.goexit
        runtime/asm_amd64.s:1581

Is there any other method to do this conditional check, based on the check if pdb is defined ?

System Info

Output of helm version:

version.BuildInfo{Version:"v3.9.0", GitCommit:"7ceeda6c585217a19a1131663d8cd1f7d641b2a7", GitTreeState:"clean", GoVersion:"go1.17.5"}

Output of kubectl version:

WARNING: This version information is deprecated and will be replaced with the output from kubectl version --short.  Use --output=yaml|json to get the full version.
Client Version: version.Info{Major:"1", Minor:"24", GitVersion:"v1.24.1", GitCommit:"3ddd0f45aa91e2f30c70734b175631bec5b5825a", GitTreeState:"clean", BuildDate:"2022-05-24T12:26:19Z", GoVersion:"go1.18.2", Compiler:"gc", Platform:"windows/amd64"}
Kustomize Version: v4.5.4
Server Version: version.Info{Major:"1", Minor:"23", GitVersion:"v1.23.3", GitCommit:"816c97ab8cff8a1c72eccca1026f7820e93e0d25", GitTreeState:"clean", BuildDate:"2022-01-25T21:19:12Z", GoVersion:"go1.17.6", Compiler:"gc", Platform:"linux/amd64"}

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

minikube
@Scarjit
Copy link
Author

Scarjit commented Jun 22, 2022

The same behavior can be observed with an simplified expression:

{{if or true (and false (.Values.mqtttopostgresql.pdb.enabled | default true))}}

@phil9909
Copy link
Contributor

Should be fixed by upgrading to go 1.18.

There is already a PR for this #10806

@phil9909
Copy link
Contributor

PR #10806 has been merged now.

You test it with the latest canary release of Helm. Details on that can be found at https://helm.sh/docs/intro/install/#from-canary-builds. The canary builds are rebuilt every time a change lands on the main branch.

@github-actions
Copy link

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.

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

No branches or pull requests

3 participants