From 858665f07c839a2c2198fd5bf04e0c0872147b2a Mon Sep 17 00:00:00 2001 From: Gerard Ryan Date: Wed, 11 Dec 2019 15:03:35 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=20Don't=20add=20"db=20down"=20rule?= =?UTF-8?q?=20if=20no=20Postgresql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JIRA: https://issues.redhat.com/browse/INTLY-4497 --- CHANGELOG.md | 4 +++ .../unifiedpushserver/unifiedpushserver.go | 26 ++++++++++++------- version/version.go | 2 +- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9716743b..5054a734 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## Unreleased +## [0.4.1] - 2019-12-11 +### Fixed +- UnifiedPushDatabaseDown alert always fired if using external database + ## [0.4.0] - 2019-12-03 ### Added - UnifiedpushServer CRs can contain coordinates for an external PostgreSQL database diff --git a/pkg/controller/unifiedpushserver/unifiedpushserver.go b/pkg/controller/unifiedpushserver/unifiedpushserver.go index 37080be0..4df6703d 100644 --- a/pkg/controller/unifiedpushserver/unifiedpushserver.go +++ b/pkg/controller/unifiedpushserver/unifiedpushserver.go @@ -407,16 +407,6 @@ func reconcilePrometheusRule(prometheusRule *monitoringv1.PrometheusRule, cr *pu Labels: critical, Annotations: unifiedPushConsoleDownAnnotations, }, - { - Alert: "UnifiedPushDatabaseDown", - Expr: intstr.IntOrString{ - Type: intstr.String, - StrVal: fmt.Sprintf("absent(kube_pod_container_status_running{namespace=\"%s\",container=\"postgresql\"} == 1)", namespace), - }, - For: "5m", - Labels: critical, - Annotations: unifiedPushDatabaseDownAnnotations, - }, { Alert: "UnifiedPushJavaHeapThresholdExceeded", Expr: intstr.IntOrString{ @@ -471,6 +461,22 @@ func reconcilePrometheusRule(prometheusRule *monitoringv1.PrometheusRule, cr *pu }, }, } + + // Don't add UnifiedPushDatabaseDown rule if there's no Postgresql + if !cr.Spec.ExternalDB { + rule := monitoringv1.Rule{ + Alert: "UnifiedPushDatabaseDown", + Expr: intstr.IntOrString{ + Type: intstr.String, + StrVal: fmt.Sprintf("absent(kube_pod_container_status_running{namespace=\"%s\",container=\"postgresql\"} == 1)", namespace), + }, + For: "5m", + Labels: critical, + Annotations: unifiedPushDatabaseDownAnnotations, + } + + prometheusRule.Spec.Groups[0].Rules = append(prometheusRule.Spec.Groups[0].Rules, rule) + } } func reconcileServiceMonitor(serviceMonitor *monitoringv1.ServiceMonitor) { diff --git a/version/version.go b/version/version.go index ea6f0bcf..64c7cd26 100644 --- a/version/version.go +++ b/version/version.go @@ -1,5 +1,5 @@ package version var ( - Version = "0.4.0" + Version = "0.4.1" )