fix: imageurl without quotes#884
Open
krishnaGajabi wants to merge 1 commit into
Open
Conversation
image url containing {{ }} is being interpreted as a function on mayastor helm chart
Signed-off-by: krishnaGajabi <gajbikrishna23@gmail.com>
There was a problem hiding this comment.
Pull request overview
Fixes Helm rendering failures when an image registry contains {{ ... }} by avoiding tpl evaluation of initContainer YAML (which previously interpreted those braces as Go template functions), and aligns the pre-upgrade hook image field formatting with the rest of the chart.
Changes:
- Quote the pre-upgrade hook
image:value so rendered YAML remains valid even when registry strings contain{/}. - Update
render_init_containersto render onlycommandentries viatplwhile emitting the rest of the container YAML withouttpl, preventing accidental template evaluation of image strings. - Factor default initContainer image construction into a dedicated
render_init_container_imagehelper.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| chart/templates/pre-upgrade-hook.yaml | Quotes the pre-upgrade hook image string to avoid invalid YAML when registry values contain special characters. |
| chart/templates/_helpers.tpl | Stops tpl-rendering the full initContainer YAML; selectively tpl-renders command only and centralizes default initContainer image generation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
408
to
410
| {{- end -}} | ||
| {{- tpl ($containers | toYaml) .context }} | ||
| {{- $containers | toYaml }} | ||
| {{- end -}} |
Member
There was a problem hiding this comment.
I think this is ok since only the command needs templating?
@niladrih
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue:
image url containing {{ }} is being interpreted as a function on mayastor helm chart
Root Cause:
image url being rendered using tpl which treats it as helm function
Steps to Reproduce:
values.yaml
Command :
helm template chartsdirectory -f values.yamlError:
`Error: template: mayastor/templates/mayastor/agents/ha/ha-node-daemonset.yaml:31:12: executing "mayastor/templates/mayastor/agents/ha/ha-node-daemonset.yaml" at <include "base_init_ha_node_containers" .>: error calling include: template: mayastor/templates/_helpers.tpl:34:8: executing "base_init_ha_node_containers" at <include "render_init_containers" (dict "value" .Values.base.initHaNodeContainers.containers "context" $)>: error calling include: template: mayastor/templates/_helpers.tpl:405:8: executing "render_init_containers" at <tpl ($containers | toYaml) .context>: error calling tpl: cannot parse template "- command:\n - sh\n - -c\n - trap "exit 1" TERM; until nc -vzw 5 {{ .Release.Name }}-agent-core 50052; do date;\n echo "Waiting for agent-cluster-grpc services..."; sleep 1; done;\n image: '{{ my_registry }}/my-org//openebs/alpine-sh:4.5.0'\n imagePullPolicy: IfNotPresent\n name: agent-cluster-grpc-probe": template: gotpl:6: function "my_registry" not defined
Use --debug flag to render out invalid YAML
(END)`
Solution:
Only render the initcontainer command with tpl and eveyrthing else wihout it.
This PR also fixes preupgrade hook image url which had no quotes in previous versions.