-
Notifications
You must be signed in to change notification settings - Fork 7.2k
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
"Unexpected unclosed action in template clause" when trying to render templated string from values.yaml #7704
Comments
The issues is certainly with the line
in Could you try removing the |
* expr field in values.yaml |
Yes. This is the problematic piece. Everything else renders fine. The "bad linebreak" is inserted as soon as the line is longer than 70-80 characters.
…-------- Ursprüngliche Nachricht --------
Von: Josh Dolitsky <notifications@github.com>
Datum: 28.02.2020 21:24 (GMT+01:00)
An: helm/helm <helm@noreply.github.com>
Cc: David Heinrich <David.Heinrich@cortado.com>, Author <author@noreply.github.com>
Betreff: Re: [helm/helm] "Unexpected unclosed action in template clause" when trying to render templated string from values.yaml (#7704)
The issues is certainly with the line
rules: {{ tpl (toYaml .) $ | nindent 8 }}
in prometheusrule.yaml
Could you try removing the expr: field and see if you still get this error? I suspect thats the piece causing the error, and would be helpful to isolate it.
—
You are receiving this because you authored the thread.
Reply to this email directly,
view it on GitHub, or
unsubscribe.
|
Found this in the go-yaml repo: But even if this PR makes it into upstream it would still not be available in HELM, would it? As far as I understand Helm v2 uses https://github.com/ghodss/yaml (=go-yaml/v2 v2.2.2) and Helm v3 uses https://sigs.k8s.io/yaml (=go-yaml/v2 v2.2.8). |
The linebreak above should not have an impact. I'm actually wondering if this is a case of nested |
Well, the linebreak is the main problem. See also go-yaml/yaml#166. Under normal circumstances the linebreak "should" not have an impact, because it is valid yaml in any case. Unfortunately this does not take into account that certain strings (see https://godoc.org/text/template) cannot be split. However. When using something like this ...
templates/test.yaml:
The error message is: Error: render error in "foo/templates/test.yaml": template: foo/templates/test.yaml:4:16: executing "foo/templates/test.yaml" at <tpl (toYaml .) $>: error calling tpl: Error during tpl function execution for "- foo: test1\n foo2: test2\n foo3: foo_foo_foo_foo_foo_foo_foo_foo_foo_foo_foo_foo_foo_bar=\"{{ \"something is\n here\" }}\"\n": parse error in "foo/templates/test.yaml": template: foo/templates/test.yaml:3: unexpected unterminated quoted string in command It's a different error message, but the underlying problem is the same. As a workaround I am currently using yaml literal style for all templated strings. At least in my case it works as expected:
|
As far as I understand this PR could solve the issue. It was merged into go-yaml:v2 and go-yaml:v3, but is not released yet. |
@DaveOHenry It has been released as part of v2.3.0 on 7th of May 😃 |
Unfortunately Helm v2 uses https://github.com/ghodss/yaml (=go-yaml/v2 v2.2.2) and Helm v3 uses https://sigs.k8s.io/yaml (=go-yaml/v2 v2.2.8) 😕 |
So thankfully you can update subdependencies without that dependency itself being updated - I've made a PR that does this, and a unit test demonstrating the fix! |
using Helm v3.3.4 , issue still exists. |
what is the solution for this one ? I am having same issue with Helm v3.4.1. Please help ! Error: parse error at (mulesoft-probe/templates/PrometheusRule.yaml:28): unclosed action spec: |
For us it was Linux/Windows compatible issues. |
still no luck . its failing when i add avg_over_time () in the expr
|
The expression is too long. Unfortunately Helm splits the line and this breaks the Go template. Use yaml literal style for templated strings like:
|
Thanks ! This worked for me . |
Any update on this ? i am using helm2. tpl function on templates from values yaml is not working.
deployment yaml -
deployment yaml -
tpl is works with simple Values/Release objects. Values yaml -
deployment yaml -
|
@adasari : Did you try the workaround by changing your values to yaml literals?
|
@DaveOHenry literals working. I have confirmed in my original comment. |
I hit this issue while trying to create a configmap from a file using I was able to fix this by using helm variables in
I was referring to the same variable from Values multiple times in the |
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. |
ping |
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. |
can this issue reopened again? it is not fixed yet. |
Many charts currently support Prometheus Operator by optionally adding "prometheusRule" objects to the cluster. A user can then just add the rules in his "values.yaml". The supplied values can be templated strings and will be used by a "prometheusrule.yaml" template. This works for simple rules, but in most cases the chart will just refuse to render properly. The funny thing is, that even the example alerts that can be found in the values.yaml files of many charts are not working.
I don't know where the problem exactly is, but it looks like something is trying to pretty print the values by inserting a "\n" at a position where it should not be and this breaks the template in most cases (see
"{{ template \"test.fullname\"\n . }}
in the complete error message below). I already tried all kinds of workarounds like removing whitespaces, playing with single and double quotes, yaml multiline ... nothing seems to work.values.yaml:
prometheusrule.yaml:
Output of
helm template .
:Error: template: test/templates/prometheusrule.yaml:21:16: executing "test/templates/prometheusrule.yaml" at <tpl (toYaml .) $>: error calling tpl: error during tpl function execution for "- alert: MyTestAlert\n annotations:\n description: The {{ template \"test.fullname\" . }} has a problem. The value is\n {{ \"{{ $value }}\" }}\n summary: Something {{ \"{{ $value }}\" }}\n expr: my_test_alert_with_a_long_name_kjlgnkjfdg{service=\"{{ template \"test.fullname\"\n . }}-mymetricsservice\"} / 3600 > 1\n for: 1m\n labels:\n severity: critical": parse error at (test/templates/prometheusrule.yaml:6): unexpected unclosed action in template clause
Output of
helm version
:version.BuildInfo{Version:"v3.1.1",` GitCommit:"afe70585407b420d0097d07b21c47dc511525ac8", GitTreeState:"clean", GoVersion:"go1.13.8"}
The text was updated successfully, but these errors were encountered: