Skip to content

Commit

Permalink
fail chart rendering in case of rule name collision
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewChubatiuk committed Sep 5, 2024
1 parent 85c65ca commit e87712c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions charts/victoria-metrics-common/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Next release

- Fixed protocol extraction with TLS enabled
- Allow overriding fullname from `global.fullnameOverride`

## 0.0.9

Expand Down
2 changes: 2 additions & 0 deletions charts/victoria-metrics-common/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ If release name contains chart name it will be used as a full name.
{{- $fullname = $Values.fullnameOverride -}}
{{- else if (dig $Chart.Name "fullnameOverride" "" ($Values.global)) -}}
{{- $fullname = (dig $Chart.Name "fullnameOverride" "" ($Values.global)) -}}
{{- else if ($Values.global).fullnameOverride -}}
{{- $fullname = $Values.global.fullnameOverride -}}
{{- else -}}
{{- $name := default $Chart.Name $Values.nameOverride -}}
{{- if contains $name $Release.Name -}}
Expand Down
2 changes: 1 addition & 1 deletion charts/victoria-metrics-k8s-stack/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Next release

- TODO
- Fail chart in case of rule name collision

## 0.25.15

Expand Down
8 changes: 7 additions & 1 deletion charts/victoria-metrics-k8s-stack/templates/rules/rule.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if .Values.defaultRules.create }}
{{- $existingRules := default list }}

{{- /*
Default rules alias
Expand Down Expand Up @@ -98,12 +99,17 @@ Filter out ignore rules
Check if group is enabled
*/}}
{{- if (and $rulesSpec (dig "create" true $group) $groupCondition) }}
{{- $ruleName := (include "victoria-metrics-k8s-stack.rulegroup.name" $ctx) }}
{{- if has $ruleName $existingRules }}
{{- fail "Rule name collision was met most likely due to truncated up to 63 symbols resource name. Please consider using shorter release name or set `fullnameOverride` for a shorter name prefix"}}
{{- end }}
{{- $existingRules = append $existingRules $ruleName }}
---
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMRule
metadata:
namespace: {{ include "vm.namespace" $ }}
name: {{ include "victoria-metrics-k8s-stack.rulegroup.name" $ctx }}
name: {{ $ruleName }}
{{- with (include "victoria-metrics-k8s-stack.rulegroup.labels" $ctx) }}
labels: {{ . | nindent 4 }}
{{- end }}
Expand Down
2 changes: 1 addition & 1 deletion hack/helm/victoria-metrics-k8s-stack/e2e/simple.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ global:
keyRef:
name: keyName
key: key
fullnameOverride: "vm-stack"
fullnameOverride: test
victoria-metrics-operator:
fullnameOverride: "vm-operator"
vmsingle:
Expand Down
1 change: 1 addition & 0 deletions hack/helm/victoria-metrics-k8s-stack/lint/simple.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
fullnameOverride: test
grafanaOperatorDashboardsFormat:
enabled: true
additionalVictoriaMetricsMap:
Expand Down

0 comments on commit e87712c

Please sign in to comment.