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

Folded multi-line string converted to normal multi-line string and additional newlines added #383

Closed
alamont opened this issue Dec 15, 2021 · 4 comments
Labels
blocked/upstream Blocked by an upstream dependency or issue bug Something isn't working

Comments

@alamont
Copy link

alamont commented Dec 15, 2021

I'm having an issue where a folded multi-line string (>) is rendered as a normal multi-line string (|). Also when using include an additional newline is created which causes my command to fail.

The relevant part of the template looks like this:

...
command: ["sh", "-c"]
args:
  - |
    {{- include "pulsar.toolset.zookeeper.tls.settings" . | nindent 12 }}
    bin/pulsar initialize-cluster-metadata \
      --cluster {{ template "pulsar.cluster.name" . }} \
      --zookeeper {{ template "pulsar.zookeeper.connect" . }}{{ .Values.metadataPrefix }} \
      {{- if .Values.pulsar_metadata.configurationStore }}
      --configuration-store {{ template "pulsar.configurationStore.connect" . }}{{ .Values.pulsar_metadata.configurationStoreMetadataPrefix }} \
      {{- end }}
      {{- if not .Values.pulsar_metadata.configurationStore }}
      --configuration-store {{ template "pulsar.zookeeper.connect" . }}{{ .Values.metadataPrefix }} \
      {{- end }}
      --web-service-url http://{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}.{{ template "pulsar.namespace" . }}.svc.{{ .Values.clusterDomain }}:{{ .Values.broker.ports.http }}/ \
      --web-service-url-tls https://{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}.{{ template "pulsar.namespace" . }}.svc.{{ .Values.clusterDomain }}:{{ .Values.broker.ports.https }}/ \
      --broker-service-url pulsar://{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}.{{ template "pulsar.namespace" . }}.svc.{{ .Values.clusterDomain }}:{{ .Values.broker.ports.pulsar }}/ \
      --broker-service-url-tls pulsar+ssl://{{ template "pulsar.fullname" . }}-{{ .Values.broker.component }}.{{ template "pulsar.namespace" . }}.svc.{{ .Values.clusterDomain }}:{{ .Values.broker.ports.pulsarssl }}/ || true;
...

If I render this locally with helm 3.7.1 I get the expected result:

...
command: ["sh", "-c"]
args:
  - >
    /pulsar/keytool/keytool.sh toolset ${HOSTNAME}.pulsar-test-toolset.pulsar.svc.cluster.local true;
    bin/pulsar initialize-cluster-metadata \
      --cluster pulsar-test \
      --zookeeper pulsar-test-zookeeper:2281 \
      --configuration-store pulsar-test-zookeeper:2281 \
      --web-service-url http://pulsar-test-broker.pulsar.svc.cluster.local:8080/ \
      --web-service-url-tls https://pulsar-test-broker.pulsar.svc.cluster.local:8443/ \
      --broker-service-url pulsar://pulsar-test-broker.pulsar.svc.cluster.local:6650/ \
      --broker-service-url-tls pulsar+ssl://pulsar-test-broker.pulsar.svc.cluster.local:6651/ || true;
...

However, if I deploy with Flux the output looks like this:

...
- args:
  - |
    /pulsar/keytool/keytool.sh toolset ${HOSTNAME}.pulsar-toolset.pulsar.svc.cluster.local true; bin/pulsar initialize-cluster-metadata \
  
      --cluster pulsar \
      --zookeeper pulsar-zookeeper:2281 \
      --configuration-store pulsar-zookeeper:2281 \
      --web-service-url http://pulsar-broker.pulsar.svc.cluster.local:8080/ \
      --web-service-url-tls https://pulsar-broker.pulsar.svc.cluster.local:8443/ \
      --broker-service-url pulsar://pulsar-broker.pulsar.svc.cluster.local:6650/ \
      --broker-service-url-tls pulsar+ssl://pulsar-broker.pulsar.svc.cluster.local:6651/ || true;
  command:
  - sh
  - -c
...

Notice that bin/pulsar initialize-cluster-metadata \ is not rendered on a new line and that there is an empty line after that. Of course, this causes the script to fail.

Could this be a configuration issue? Considering the command line has also changed from command: ["sh", "-c"] to

command:
  - sh
  - -c
@alamont
Copy link
Author

alamont commented Dec 16, 2021

It may be related to this issue: kubernetes-sigs/kustomize#947

@stefanprodan stefanprodan added blocked/upstream Blocked by an upstream dependency or issue bug Something isn't working labels Dec 16, 2021
@rickhlx
Copy link

rickhlx commented Jun 4, 2022

Looks like this is still an issue. Why does helm-controller depend on Kustomize to do it's rendering? Is there a way to bypass this?

@hiddeco
Copy link
Member

hiddeco commented Jun 7, 2022

We use Kustomize for post rendering, and piggy back on this to inject original labels which we use to track resources that have been deployed by Flux https://github.com/fluxcd/helm-controller/blob/main/internal/runner/post_renderer_origin_labels.go. It can not be bypassed.

@stefanprodan
Copy link
Member

This has been fixed by #817 and will be included in the Flux 2.2.0 (December).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked/upstream Blocked by an upstream dependency or issue bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants