For the following helmfile:
repositories:
- name: "monochart-repo"
url: "git+ssh://[email protected]/slaterx/helm-monochart@stable/mono?ref=master&sparse=0"
helmDefaults:
timeout: 1800
environments:
staging:
values:
- {{ env "STAGING_YAML" | default "values/staging.yaml" }}
releases:
- name: {{ .Environment.Name }}
namespace: {{ .Namespace }}
chart: monochart-repo/monochart
version: !!string 0.1.0
atomic: true
wait: true
labels:
app: {{ .Environment.Name }}
values:
- name: {{ .Environment.Name }}
crontab:
enabled: true
pod:
command:
args: ["/bin/runtime-init", "rake", "'web:migrate'"]
When running the following command:
helmfile --log-level=debug --environment=staging --namespace=some-namespace --file staging.yaml diff
Returns the following error:
err: release "staging" in "staging.yaml" failed: failed processing release staging: helm exited with status 1:
2020/04/18 18:44:58 YAML unmarshal error: yaml: line 21: found unexpected ':'
Can't unmarshal # Source: monochart/templates/cronjob.yml
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: staging
namespace: staging
spec:
concurrencyPolicy: Replace
failedJobsHistoryLimit: 1
jobTemplate:
spec:
template:
metadata:
annotations:
iam.amazonaws.com/role: false
sidecar.istio.io/inject: "false"
labels:
name: staging
spec:
containers:
- command:
- [/bin/runtime-init rake web:migrate]
- [/bin/bash]
- true
image: (...)/(...):(...)
imagePullPolicy: Always
name: staging
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
dnsPolicy: ClusterFirst
restartPolicy: Always
schedulerName: default-scheduler
terminationGracePeriodSeconds: 60
schedule: "0 0 * * *"
successfulJobsHistoryLimit: 3
suspend: false
Error: plugin "diff" exited with error
I think that it is complaining about "web:migrate". But I tried quoting and double-quoting without success. Renaming the function isn't an option, unfortunately.
I am using the following versions:
➜ helm version
version.BuildInfo{Version:"v3.1.0", GitCommit:"b29d20baf09943e134c2fa5e1e1cab3bf93315fa", GitTreeState:"clean", GoVersion:"go1.13.8"}
➜ helmfile --version
helmfile version v0.99.1
Shouldn't it be
values:
- name: {{ .Environment.Name }}
crontab:
enabled: true
pod:
command:
- "/bin/runtime-init"
- "rake"
- "web:migrate"
according to the cronjob template?
Nice catch, the command parameter is missing its value:
values:
- name: {{ .Environment.Name }}
crontab:
enabled: true
pod:
command: ["/bin/bash"]
args: ["/bin/runtime-init", "rake", "'web:migrate'"]
The args go to /bin/bash.
I don't get it 🤔 I thought you didn't need args when you put args in the command array.
Yeah, getting rid of args did the trick:
values:
- name: {{ .Environment.Name }}
crontab:
enabled: true
pod:
command: ["/bin/bash", "/bin/runtime-init", "rake", "'web:migrate'"]
So, why did the args bit were unable to parse the string with the :?
Happy to create a PR if you think it's a bug :)
Cuz you were passing an json object whose sole key is args and its value is ["/bin/runtime-init", "rake", "'web:migrate'"].
That turns this:
- command:
{{- range $cmd := .Values.pod.command }}
- {{ $cmd }}
{{- end }}
into
- command:
- <Go string representation of the yaml/json object>
which sems to result in
- command:
- [/bin/runtime-ini rake web:migrate]
So it's basically an user error. When the chart requires each element of args to be a string, you must give it strings, not objects.
Perfectly explained! Thanks a lot!
Most helpful comment
Perfectly explained! Thanks a lot!