From 4dc8a30ce27f385cf99c882bb2eb02812df3890c Mon Sep 17 00:00:00 2001 From: Sergey Kurkin Date: Fri, 19 Dec 2025 03:29:19 +0300 Subject: [PATCH] add check value group.rules Signed-off-by: Sergey Kurkin --- charts/helm_lib/Chart.yaml | 2 +- .../templates/_monitoring_prometheus_rules.tpl | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/charts/helm_lib/Chart.yaml b/charts/helm_lib/Chart.yaml index 84b95d9..c51e620 100644 --- a/charts/helm_lib/Chart.yaml +++ b/charts/helm_lib/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v2 type: library name: deckhouse_lib_helm -version: 1.68.1 +version: 1.68.2 description: "Helm utils template definitions for Deckhouse modules." diff --git a/charts/helm_lib/templates/_monitoring_prometheus_rules.tpl b/charts/helm_lib/templates/_monitoring_prometheus_rules.tpl index cc08cf4..86c75bb 100644 --- a/charts/helm_lib/templates/_monitoring_prometheus_rules.tpl +++ b/charts/helm_lib/templates/_monitoring_prometheus_rules.tpl @@ -11,7 +11,7 @@ {{- if gt (len .) 3 }} {{- $currentDir = index . 3 }} {{- else }} {{- $currentDir = $rootDir }} {{- end }} {{- if gt (len .) 4 }} {{- $fileList = index . 4 }} {{- end }} - + {{- $currentDirIndex := (sub ($currentDir | splitList "/" | len) 1) }} {{- $rootDirIndex := (sub ($rootDir | splitList "/" | len) 1) }} {{- $folderNamesIndex := (add1 $rootDirIndex) }} @@ -22,7 +22,7 @@ {{- if gt (len $fileList) 0 }} {{- $shouldProcess = has $path $fileList }} {{- end }} - + {{- if $shouldProcess }} {{- $fileName := ($path | splitList "/" | last ) }} {{- $definition := "" }} @@ -62,9 +62,10 @@ {{- $useObservabilityRules := has "observability.deckhouse.io/v1alpha1/ClusterObservabilityMetricsRulesGroup" $context.Values.global.discovery.apiVersions }} {{- if and $hasObservabilityModule $useObservabilityRules }} {{- range $idx, $group := $definitionStruct.Rules }} - {{- $_ := unset $group "name" }} - {{- $resourceName = $resourceName | replace "propagated-" "" }} - {{- $groupResourceName := printf "%s-%d" $resourceName $idx }} + {{- if $group.rules }} + {{- $_ := unset $group "name" }} + {{- $resourceName = $resourceName | replace "propagated-" "" }} + {{- $groupResourceName := printf "%s-%d" $resourceName $idx }} --- apiVersion: observability.deckhouse.io/v1alpha1 kind: {{ $propagated | ternary "ClusterObservabilityPropagatedMetricsRulesGroup" "ClusterObservabilityMetricsRulesGroup" }} @@ -73,6 +74,7 @@ metadata: {{- include "helm_lib_module_labels" (list $context (dict "app" "prometheus" "prometheus" "main" "component" "rules")) | nindent 2 }} spec: {{- $group | toYaml | nindent 2 }} + {{- end }} {{- end }} {{- else }} {{- if $definitionStruct.Rules }} @@ -87,7 +89,7 @@ metadata: spec: groups: {{- $definition | nindent 4 }} - {{- end }} + {{- end }} {{- end }} {{- end }} {{- end }} @@ -130,4 +132,4 @@ spec: {{- else -}} {{ $timeout }}s {{- end }} -{{- end }} \ No newline at end of file +{{- end }}