VictoriaMetrics / helm-charts

Helm charts for VictoriaMetrics, VictoriaLogs and ecosystem
https://victoriametrics.github.io/helm-charts/
Apache License 2.0
334 stars 326 forks source link

bug: victoria-logs-single does not work as subchart due to problematic `vm.probe` function #1578

Closed GreyLilac09 closed 1 hour ago

GreyLilac09 commented 2 hours ago

Chart name and version chart: victoria-logs-single version: 0.6.5

Describe the bug Running victoria-logs-single with default values.yaml in a subchart does not work due to vm.probe failure

helm.go:84: [debug] template: <redacted>/charts/victoria-logs/templates/server-statefulset.yaml:61:30: executing "<redacted>/charts/victoria-logs/templates/server-statefulset.yaml" at <include "vm.probe" (dict "app" $app "type" "readiness")>: error calling include: template: <redacted>/charts/victoria-logs/charts/victoria-metrics-common/templates/_pod.tpl:64:6: executing "vm.probe" at <tpl (toYaml $probe) .>: error calling tpl: cannot retrieve Template.Basepath from values inside tpl function: failureThreshold: 3
httpGet:
  path: /health
  port: http
  scheme: HTTP
initialDelaySeconds: 5
periodSeconds: 15
timeoutSeconds: 5: "BasePath" is not a value

Definition of vm.probe:

{{- /*
Render probe
*/ -}}
{{- define "vm.probe" -}}
  {{- /* undefined value */ -}}
  {{- $null := (fromYaml "value: null").value -}}
  {{- $probe := dig .type (default dict) .app.probe -}}
  {{- $probeType := "" -}}
  {{- $defaultProbe := default dict -}}
  {{- if ne (dig "httpGet" $null $probe) $null -}}
    {{- /* httpGet probe */ -}}
    {{- $defaultProbe = dict "path" (include "vm.probe.http.path" .) "scheme" (include "vm.probe.http.scheme" .) "port" (include "vm.probe.port" .) -}}
    {{- $probeType = "httpGet" -}}
  {{- else if ne (dig "tcpSocket" $null $probe) $null -}}
    {{- /* tcpSocket probe */ -}}
    {{- $defaultProbe = dict "port" (include "vm.probe.port" .) -}}
    {{- $probeType = "tcpSocket" -}}
  {{- end -}}
  {{- $defaultProbe = ternary (default dict) (dict $probeType $defaultProbe) (empty $probeType) -}}
  {{- $probe = mergeOverwrite $defaultProbe $probe -}}
  {{- range $key, $value := $probe -}}
    {{- if and (has (kindOf $value) (list "object" "map")) (ne $key $probeType) -}}
      {{- $_ := unset $probe $key -}}
    {{- end -}}
  {{- end -}}
  {{- tpl (toYaml $probe) . -}}
{{- end -}}

I highly suspect the error is caused by this line: {{- tpl (toYaml $probe) . -}} as the . does not reflect the global context

Custom values Please provide only custom values (excluding default ones): Chart.yaml

apiVersion: v2
name: ...
description: ...
type: application
version: 0.1.0
appVersion: "0.1.0"

dependencies:
  - name: victoria-logs-single
    version: 0.6.5
    repository: https://victoriametrics.github.io/helm-charts/

values.yaml

victoria-logs-single: {}
AndrewChubatiuk commented 1 hour ago

hey @GreyLilac09 helm 3.14+ is required

GreyLilac09 commented 1 hour ago

I see, I was on helm v3.9. Is there a workaround or earlier version for earlier helm versions?

AndrewChubatiuk commented 1 hour ago

no workarounds, upgrade is required

AndrewChubatiuk commented 1 hour ago

pre 0.6.0 versions do not require new helm