From d791101782fb99c88a60e0c4f4a5420abf9f0279 Mon Sep 17 00:00:00 2001 From: abd-ulbasit Date: Thu, 22 Oct 2026 00:18:20 +0500 Subject: [PATCH] fix(cluster): let the low disk space alerts match WAL and tablespace PVCs The podSelector passed to the PrometheusRule templates ends with "$". The low disk space rules append "-wal" and "-tbs.*" to it, so those matchers render as "-([1-9][0-9]*)$-wal" and never match. A full WAL or tablespace volume does not raise CNPGClusterLowDiskSpaceWarning or CNPGClusterLowDiskSpaceCritical. Drop the "$". Prometheus anchors =~ matchers at both ends, so the other matchers built from podSelector (the pod matchers and the PGDATA PVC matchers) select the same series as before. Check the rendered WAL and tablespace matchers in the monitoring chainsaw test. Closes #966 Assisted-by: Claude Opus 5.5 Signed-off-by: abd-ulbasit --- charts/cluster/templates/prometheus-rule.yaml | 2 +- .../test/monitoring/01-monitoring_cluster-assert.yaml | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/charts/cluster/templates/prometheus-rule.yaml b/charts/cluster/templates/prometheus-rule.yaml index fc3f35cb4d..2af43498c2 100644 --- a/charts/cluster/templates/prometheus-rule.yaml +++ b/charts/cluster/templates/prometheus-rule.yaml @@ -17,7 +17,7 @@ spec: {{- $_ := set $dict "namespace" (include "cluster.namespace" .) -}} {{- $_ := set $dict "cluster" (include "cluster.fullname" .) -}} {{- $_ := set $dict "labels" (dict "job" "{{ $labels.job }}" "node" "{{ $labels.node }}" "pod" "{{ $labels.pod }}") -}} - {{- $_ := set $dict "podSelector" (printf "%s-([1-9][0-9]*)$" (include "cluster.fullname" .)) -}} + {{- $_ := set $dict "podSelector" (printf "%s-([1-9][0-9]*)" (include "cluster.fullname" .)) -}} {{- $_ := set $dict "Values" .Values -}} {{- $_ := set $dict "Template" .Template -}} {{- range $path, $_ := .Files.Glob "prometheus_rules/**.yaml" }} diff --git a/charts/cluster/test/monitoring/01-monitoring_cluster-assert.yaml b/charts/cluster/test/monitoring/01-monitoring_cluster-assert.yaml index ff2d676bcc..d5b561af79 100644 --- a/charts/cluster/test/monitoring/01-monitoring_cluster-assert.yaml +++ b/charts/cluster/test/monitoring/01-monitoring_cluster-assert.yaml @@ -120,6 +120,13 @@ spec: labels: environment: staging oncall: "false" + # the low disk space alerts must also match the WAL and tablespace PVCs + (rules[?alert == 'CNPGClusterLowDiskSpaceCritical'] | [0]): + (contains(expr, 'persistentvolumeclaim=~"monitoring-cluster-([1-9][0-9]*)-wal"')): true + (contains(expr, 'persistentvolumeclaim=~"monitoring-cluster-([1-9][0-9]*)-tbs.*"')): true + (rules[?alert == 'CNPGClusterLowDiskSpaceWarning'] | [0]): + (contains(expr, 'persistentvolumeclaim=~"monitoring-cluster-([1-9][0-9]*)-wal"')): true + (contains(expr, 'persistentvolumeclaim=~"monitoring-cluster-([1-9][0-9]*)-tbs.*"')): true --- apiVersion: v1 kind: ConfigMap