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

HelmRelease causes a line break on long values #3062

Open
ChristianRaoulis opened this issue Jun 14, 2024 · 1 comment
Open

HelmRelease causes a line break on long values #3062

ChristianRaoulis opened this issue Jun 14, 2024 · 1 comment
Labels
area/helm kind/bug Some behavior is incorrect or out of spec

Comments

@ChristianRaoulis
Copy link

ChristianRaoulis commented Jun 14, 2024

What happened?

I'm trying to add some prometheus rules to my rabbitmq bitnami helm chart and pulumi seems to add a \n on a point where it causes an unterminated quoted string error on pulumi up

Example

const rabbitMQ = new HelmRelease("rabbitmq", {
   chart:          "rabbitmq",
   version:        "14.1.2",
   repositoryOpts: {
      repo: "https://charts.bitnami.com/bitnami",
   },
   values:         {
      metrics: {
         enabled:        true,
         prometheusRule: {
            enabled:   true,
            rules:     [
               {
                  alert:       "RabbitmqInstancesDifferentVersions",
                  expr:        'count(count(rabbitmq_build_info) by (rabbitmq_version)) > 1',
                  for:         '60m',
                  labels:      {
                     severity: "warning",
                  },
                  annotations: {
                     summary:     'RabbitMQ instances running different versions (instance {{ "{{ $labels.instance }}" }})', // <-- this get's converted to "RabbitMQ instances running different versions (instance {{ \"{{ $labels.instance\n      }}\" }})"
                     description: 'Running different version of RabbitMQ in the same cluster, can lead to failure.\n   VALUE = {{ "{{ $value }}" }}\n LABELS = {{ "{{ $labels }}" }}',
                  },
               },
            ],
         },
      },
   },
});

Output of pulumi about

CLI          
Version      3.107.0
Go Version   go1.22.0
Go Compiler  gc

Plugins
NAME          VERSION
command       0.11.1
keycloak      5.3.2
kubernetes    4.13.1
mongodbatlas  3.16.0
nodejs        unknown
postgresql    3.11.1
random        4.16.2

Host     
OS       Microsoft Windows 11 Enterprise
Version  10.0.22631 Build 22631
Arch     x86_64

This project is written in nodejs: executable='C:\Users\A92615470\AppData\Local\pnpm\node.exe' version='v20.14.0'

Additional context

// In my arg 
RabbitMQ instances running different versions (instance {{ "{{ $labels.instance }}" }})
// In values.yaml
RabbitMQ instances running different versions (instance {{ "{{ $labels.instance\n      }}" }})

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@ChristianRaoulis ChristianRaoulis added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Jun 14, 2024
@rquitales
Copy link
Contributor

Hi @ChristianRaoulis it appears that this is related to an upstream bug regarding line splitting. Please see helm/helm#7704 for additional information.

Note that I am also able to reproduce this issue using Helm CLI (v3.15.2 - latest) and the following values.yaml file:

# helm install bitnami/rabbitmq --values ./values.yml --generate-name
metrics:
  enabled: true
  prometheusRule:
    enabled: true
    rules:
      - alert: RabbitmqInstancesDifferentVersions
        expr: count(count(rabbitmq_build_info) by (rabbitmq_version)) > 1
        for: 60m
        labels:
          severity: warning
        annotations:
          summary: RabbitMQ instances running different versions (instance {{ "{{ $labels.instance }}" }})
          description: |-
            Running different version of RabbitMQ in the same cluster, can lead to failure.
            VALUE = {{ "{{ $value }}" }}
            LABELS = {{ "{{ $labels }}" }}

As a workaround for now, you could employ the suggestion in helm/helm#7704 (comment) by declaring your custom values in a yaml file and referencing it using the valueYamlFiles field.

Example:

# index.ts
const chart = new k8s.helm.v3.Release(
  "rabbitmq",
  {
    chart: "rabbitmq",
    version: "14.1.2",
    repositoryOpts: {
      repo: "https://charts.bitnami.com/bitnami",
    },
    valueYamlFiles: [new pulumi.asset.FileAsset("./values.yml")],
  },
  { provider }
);
#values.yml
metrics:
  enabled: true
  prometheusRule:
    enabled: true
    rules:
      - alert: RabbitmqInstancesDifferentVersions
        expr: |
          count(count(rabbitmq_build_info) by (rabbitmq_version)) > 1
        for: 60m
        labels:
          severity: warning
        annotations:
          summary: |
            RabbitMQ instances running different versions (instance {{ "{{ $labels.instance }}" }})
          description: |
            Running different version of RabbitMQ in the same cluster, can lead to failure.
            VALUE = {{ "{{ $value }}" }}
            LABELS = {{ "{{ $labels }}" }}

Alternatively, you could force a string literal by adding a \n to the end of strings >80 characters.

const rabbitMQ = new HelmRelease("rabbitmq", {
   chart:          "rabbitmq",
   version:        "14.1.2",
   repositoryOpts: {
      repo: "https://charts.bitnami.com/bitnami",
   },
   values:         {
      metrics: {
         enabled:        true,
         prometheusRule: {
            enabled:   true,
            rules:     [
               {
                  alert:       "RabbitmqInstancesDifferentVersions",
                  expr:        'count(count(rabbitmq_build_info) by (rabbitmq_version)) > 1',
                  for:         '60m',
                  labels:      {
                     severity: "warning",
                  },
                  annotations: {
                     summary:     'RabbitMQ instances running different versions (instance {{ "{{ $labels.instance }}" }})\n',
                     description: 'Running different version of RabbitMQ in the same cluster, can lead to failure.\n   VALUE = {{ "{{ $value }}" }}\n LABELS = {{ "{{ $labels }}" }}',
                  },
               },
            ],
         },
      },
   },
});

In the meantime, I'll see what strategies we could implement within our provider to avoid this issue.

@rquitales rquitales added area/helm and removed needs-triage Needs attention from the triage team labels Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/helm kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

2 participants