Skip to content

Commit 4dbfd8a

Browse files
authored
Merge pull request #168 from deckhouse/fix/check-null-in-observabilitymetricsgroup
add check null in ClusterObservabilityMetricsRulesGroup
2 parents 8fedcc6 + 4dc8a30 commit 4dbfd8a

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

charts/helm_lib/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apiVersion: v2
22
type: library
33
name: deckhouse_lib_helm
4-
version: 1.68.1
4+
version: 1.68.2
55
description: "Helm utils template definitions for Deckhouse modules."

charts/helm_lib/templates/_monitoring_prometheus_rules.tpl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
{{- if gt (len .) 3 }} {{- $currentDir = index . 3 }} {{- else }} {{- $currentDir = $rootDir }} {{- end }}
1313
{{- if gt (len .) 4 }} {{- $fileList = index . 4 }} {{- end }}
14-
14+
1515
{{- $currentDirIndex := (sub ($currentDir | splitList "/" | len) 1) }}
1616
{{- $rootDirIndex := (sub ($rootDir | splitList "/" | len) 1) }}
1717
{{- $folderNamesIndex := (add1 $rootDirIndex) }}
@@ -22,7 +22,7 @@
2222
{{- if gt (len $fileList) 0 }}
2323
{{- $shouldProcess = has $path $fileList }}
2424
{{- end }}
25-
25+
2626
{{- if $shouldProcess }}
2727
{{- $fileName := ($path | splitList "/" | last ) }}
2828
{{- $definition := "" }}
@@ -62,9 +62,10 @@
6262
{{- $useObservabilityRules := has "observability.deckhouse.io/v1alpha1/ClusterObservabilityMetricsRulesGroup" $context.Values.global.discovery.apiVersions }}
6363
{{- if and $hasObservabilityModule $useObservabilityRules }}
6464
{{- range $idx, $group := $definitionStruct.Rules }}
65-
{{- $_ := unset $group "name" }}
66-
{{- $resourceName = $resourceName | replace "propagated-" "" }}
67-
{{- $groupResourceName := printf "%s-%d" $resourceName $idx }}
65+
{{- if $group.rules }}
66+
{{- $_ := unset $group "name" }}
67+
{{- $resourceName = $resourceName | replace "propagated-" "" }}
68+
{{- $groupResourceName := printf "%s-%d" $resourceName $idx }}
6869
---
6970
apiVersion: observability.deckhouse.io/v1alpha1
7071
kind: {{ $propagated | ternary "ClusterObservabilityPropagatedMetricsRulesGroup" "ClusterObservabilityMetricsRulesGroup" }}
@@ -73,6 +74,7 @@ metadata:
7374
{{- include "helm_lib_module_labels" (list $context (dict "app" "prometheus" "prometheus" "main" "component" "rules")) | nindent 2 }}
7475
spec:
7576
{{- $group | toYaml | nindent 2 }}
77+
{{- end }}
7678
{{- end }}
7779
{{- else }}
7880
{{- if $definitionStruct.Rules }}
@@ -87,7 +89,7 @@ metadata:
8789
spec:
8890
groups:
8991
{{- $definition | nindent 4 }}
90-
{{- end }}
92+
{{- end }}
9193
{{- end }}
9294
{{- end }}
9395
{{- end }}
@@ -130,4 +132,4 @@ spec:
130132
{{- else -}}
131133
{{ $timeout }}s
132134
{{- end }}
133-
{{- end }}
135+
{{- end }}

0 commit comments

Comments
 (0)