bitnami / charts

Bitnami Helm Charts
https://bitnami.com
Other
8.84k stars 9.13k forks source link

[bitnami/grafana] Using remplated `resources` string causes coalesce warning #29340

Open bpfoster opened 1 week ago

bpfoster commented 1 week ago

Name and Version

bitnami/grafana 11.3.19

What architecture are you using?

None

What steps will reproduce the bug?

I see that the resources values are being rendered: https://github.com/bitnami/charts/blob/3d8b5c97a8562b27877833726b542c985ccb7359/bitnami/grafana/templates/deployment.yaml#L290

If I set resources to a string that I want to get rendered, I get a warning during helm deployment.

Are you using any custom parameters or values?

Something similar to:

grafana:
  grafana:
    resources: |
      {{- if .Values.global.resourcesDisabled }}
        {}
      {{- else }}
        requests:
          cpu: 12m
      {{- end }}

What is the expected behavior?

The value is rendered and used without error

What do you see instead?

coalesce.go:286: warning: cannot overwrite table with non table for grafana.grafana.resources (map[])
coalesce.go:286: warning: cannot overwrite table with non table for grafana.grafana.resources (map[])

Additional information

I think this may be because the resources object is initialized in the chart as an empty dict: https://github.com/bitnami/charts/blob/eb13e5212410771560fd9e064f6ce0fb057e67c5/bitnami/grafana/values.yaml#L449

If it is initialized to nil, this error does not appear to happen. I believe this will preserve the same behavior.

If you agree on this issue, it affects many charts.

javsalgar commented 1 week ago

Hi,

The issue is that you are setting the resources as a string, instead of a dict. This change of types is the reason of the warning. As this is a very special use of the resources value, I believe we should maintain it as {}, as it will be more helpful for users

bpfoster commented 1 week ago

Thanks @javsalgar . I understand.

The chart calling render indicates that this is an expected use case, so as a user I think it is confusing to attempt to use it as such but receive a warning that cannot be resolved.