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 b35df2b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
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
9 changes: 8 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,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 }}
Expand Down

0 comments on commit b35df2b

Please sign in to comment.