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" )