grafana / helm-charts

Apache License 2.0
1.59k stars 2.24k forks source link

[loki] 6.6.3 template failure with using imagePullSecret #3168

Open MathiasRudolphSec opened 2 months ago

MathiasRudolphSec commented 2 months ago

When setting a imagePullSecret the template fails to render.

Error: template: loki/templates/results-cache/statefulset-results-cache.yaml:1:4: executing "loki/templates/results-cache/statefulset-results-cache.yaml" at <include "loki.memcached.statefulSet" (dict "ctx" $ "valuesSection" "resultsCache" "component" "results-cache")>: error calling include: template: loki/templates/memcached/_memcached-statefulset.tpl:75:17: executing "loki.memcached.statefulSet" at <$.ctx.Values.image.pullSecrets>: nil pointer evaluating interface {}.pullSecrets
helm.go:84: [debug] template: loki/templates/results-cache/statefulset-results-cache.yaml:1:4: executing "loki/templates/results-cache/statefulset-results-cache.yaml" at <include "loki.memcached.statefulSet" (dict "ctx" $ "valuesSection" "resultsCache" "component" "results-cache")>: error calling include: template: loki/templates/memcached/_memcached-statefulset.tpl:75:17: executing "loki.memcached.statefulSet" at <$.ctx.Values.image.pullSecrets>: nil pointer evaluating interface {}.pullSecrets

in templates/memcached/_memcached-statefulset.tpl:75:17 the relevant code is:

      {{- if $.ctx.Values.imagePullSecrets }}
      imagePullSecrets:
      {{- range $.ctx.Values.image.pullSecrets }}
        - name: {{ . }}
      {{- end }}
      {{- end }}

The range tries to access image.pullSecret which maybe a typo? When fixed to imagePullSecret the template renders successfully.

The following values file reproduces the bug:

# -- Image pull secrets for Docker images
imagePullSecrets:
  - "image-pull-secret"

deploymentMode: SingleBinary

loki:
  # https://grafana.com/docs/loki/latest/configure/#limits_config
  limits_config:
    # Retention period to apply to stored data, only applies if retention_enabled is
    # true in the compactor config. As of version 2.8.0, a zero value of 0 or 0s
    # disables retention. In previous releases, Loki did not properly honor a zero
    # value to disable retention and a really large value should be used instead.
    retention_period: 168h # 7d
    # Limit how far back in time series data and metadata can be queried, up until
    # lookback duration ago. This limit is enforced in the query frontend, the
    # querier and the ruler. If the requested time range is outside the allowed
    # range, the request will not fail, but will be modified to only query data
    # within the allowed time range. The default value of 0 does not set a limit.
    max_query_lookback: 168h # 7d
  commonConfig:
    replication_factor: 1
  storage:
    type: 'filesystem'
  # https://grafana.com/docs/loki/latest/configure/#schema_config
  schemaConfig:
    configs:
      - from: 2020-01-01
        store: tsdb
        object_store: filesystem
        schema: v13
        index:
          prefix: index_
          period: 24h
        chunks:
          prefix: chunks_
          period: 24h
  # https://grafana.com/docs/loki/latest/configure/#compactor
  compactor:
    retention_enabled: true
    delete_request_store: filesystem

Tried with helm template --debug -f values.yaml loki/

Sheikh-Abubaker commented 2 months ago

loki chart is no longer maintained here, it is maintained in the loki repo: https://github.com/grafana/loki/tree/main/production/helm/loki

but apart from this I'll fix it by opening a PR.