Closed arm4b closed 4 years ago
CC'ing @icanhazbroccoli as it looks like https://github.com/helm/helm/pull/6010 caused a regression. Perhaps we need to update int
and other functions to accept json.Number
?
@bacongobbler indeed, it's a miss from my side. Mind if I start working on a fix?
Yes please.
Was just going to report this too!
❯ helm template . --execute templates/test.yaml --set=replicas=1
---
# Source: platform-helm-at-service/templates/test.yaml
original: 1
int: 0
intOnNumber: 1
original: {{ .Values.replicas }}
int: {{ int .Values.replicas }}
intOnNumber: {{ int 1 }}
fixed in #6749.
:tada: Thanks for a quick fix!
Hopefully we'll see v2.15.1
release soonish.
v2.15.1
released.
Oh this problem also exists in helm 3:
Error: template: rancher/templates/deployment.yaml:76:7: executing "rancher/templates/deployment.yaml" at <gt .Values.auditLog.level 0.0>: error calling gt: incompatible types for comparison
Happens when installing with:
rancher_helm_chart_version="2.3.3"
rancher_server_domain="server.rancher.test"
kubectl create namespace cattle-system
helm install \
rancher \
rancher/rancher \
--namespace cattle-system \
--version $rancher_helm_chart_version \
--set "hostname=$rancher_server_domain" \
--set ingress.tls.source=secret \
--set privateCA=true \
--set auditLog.level=3 \
--set replicas=1
@rgl this is a slightly different problem, which goes as deep as golang text/template internals. In a nutshell: comparison functions expect operands to come in compatible formats. Once it gets a int-like and float-like argument tuple, it panics. Maybe this ref would be helpful: https://golang.org/src/text/template/funcs.go#L513.
I would suggest using an explicit type casting here (using int and float helpers).
@icanhazbroccoli how do I do an explicit type casting from the helm cli?
@rgl either --set auditLog.level=3.0
or it's the templates that have to be modified :-(
Doing --set auditLog.level=3.0
brakes the rancher installation somehow. Will push for the templates to be changed instead. Thanks for the pointer!
The regression found in CI/CD nightly builds when relying on latest Helm which is now
v2.15
(since Friday? :trollface:)In new Helm
v2.15
there seems to be some changes in values types.Helm Values:
Helm Template:
Will produce:
0
inv2.15
3
inv2.14
After closer look,
.Values.replicas
is now of typejson.Number
inv2.15
, previously wasfloat64
inv2.14
. This means some previously worked cast/conversions in many user's templates and charts would fail. For reference: https://github.com/helm/charts/search?q=int+.Values.&unscoped_q=int+.Values https://github.com/helm/charts/search?q=until&unscoped_q=untilWorkaround
Workaround for Helm
v2.15
templates is to cast to string first before converting to int:Output of
helm version
:v2.15.0
Cloud Provider/Platform (AKS, GKE, Minikube etc.):
minikube
Fixes https://github.com/StackStorm/stackstorm-ha/issues/89 Closes https://github.com/StackStorm/stackstorm-ha/pull/91