diff --git a/charts/victoria-metrics-k8s-stack/CHANGELOG.md b/charts/victoria-metrics-k8s-stack/CHANGELOG.md index ba5be39b6..6b4251b3b 100644 --- a/charts/victoria-metrics-k8s-stack/CHANGELOG.md +++ b/charts/victoria-metrics-k8s-stack/CHANGELOG.md @@ -2,7 +2,7 @@ ## Next release -- TODO +- Fail chart in case of rule name collision ## 0.25.15 diff --git a/charts/victoria-metrics-k8s-stack/templates/rules/rule.yaml b/charts/victoria-metrics-k8s-stack/templates/rules/rule.yaml index 22aece154..7a8a01e9c 100644 --- a/charts/victoria-metrics-k8s-stack/templates/rules/rule.yaml +++ b/charts/victoria-metrics-k8s-stack/templates/rules/rule.yaml @@ -1,4 +1,5 @@ {{- if .Values.defaultRules.create }} +{{- $existingRules := default list }} {{- /* Default rules alias @@ -98,12 +99,18 @@ 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 ($existingRules | join ",") }} + {{- fail "Rule name collision was met most likely due to truncated up to 63 symbols resource name. Please consider using `fullnameOverride` or `global.fullnameOverride` to set 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 }}