Skip to content

Loki helm chart: Template error in ingester StatefulSet when storageClass is set in persistence claims (v6.47.0+) #20230

@dschaaff

Description

@dschaaff

Helm template rendering fails in the loki chart when storageClass is specified in ingester.persistence.claims (and likely other components using the same persistence pattern). The error occurs because volumeAttributesClassName is checked inside a with .storageClass block, which changes the Go template context (.) to the storageClass string value. Attempting to access .volumeAttributesClassName on a string type fails.

  Template error:
  Error: template: loki/templates/ingester/statefulset-ingester-zone-b.yaml:237:17:
  executing "loki/templates/ingester/statefulset-ingester-zone-b.yaml" at <.volumeAttributesClassName>:
  can't evaluate field volumeAttributesClassName in type string

The buggy template logic (line ~235-240):

  {{- with .storageClass }}
  storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }}
  {{- with .volumeAttributesClassName }}   # BUG: context is now the storageClass string
  volumeAttributesClassName: {{ . }}
  {{- end }}
  {{- end }}

To Reproduce

  1. Helm chart version: 6.48.0 (bug introduced in 6.47.0, works in 6.46.x)
  2. Create values file with:
deploymentMode: Distributed
ingester:
  replicas: 3
  persistence:
    enabled: true
    claims:
      - name: data
        storageClass: gp3  # Any non-null value triggers the bug
        size: 50Gi
        accessModes:
          - ReadWriteOnce
  1. Run: helm template grafana/loki --version 6.48.0 -f values.yaml

Expected behavior

Template renders successfully with the specified storageClass applied to the PersistentVolumeClaim.

Environment:

  • Infrastructure: Kubernetes (EKS)
  • Deployment tool: Helm 3

Screenshots, Promtail config, or terminal output

Error: template: loki/templates/ingester/statefulset-ingester-zone-b.yaml:237:17: executing "loki/templates/ingester/statefulset-ingester-zone-b.yaml" at <.volumeAttributesClassName>: can't evaluate field volumeAttributesClassName in type string```

Suggested fix:

Move the volumeAttributesClassName block outside the storageClass with block:

{{- with .storageClass }}
storageClassName: {{ if (eq "-" .) }}""{{ else }}{{ . }}{{ end }}
{{- end }}
{{- with .volumeAttributesClassName }}
volumeAttributesClassName: {{ . }}
{{- end }}

  Affected templates likely include all ingester zone StatefulSets and possibly compactor, pattern-ingester, and other components using the same persistence claim pattern.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions