From 01347baa0528f63dfebe2cb3e6073ae2755de8cc Mon Sep 17 00:00:00 2001 From: Jason Zhang Date: Tue, 14 May 2024 15:46:24 -0400 Subject: [PATCH] Add -1 as a possible compliance value for the status metric ref: https://issues.redhat.com/browse/ACM-11504 Signed-off-by: Jason Zhang (cherry picked from commit e43515ba4e7775f5f44c98c1b3a0592a45ff3ecc) --- controllers/policymetrics/metrics.go | 2 +- controllers/policymetrics/policymetrics_controller.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/controllers/policymetrics/metrics.go b/controllers/policymetrics/metrics.go index c9b57ed3..0db69cc2 100644 --- a/controllers/policymetrics/metrics.go +++ b/controllers/policymetrics/metrics.go @@ -11,7 +11,7 @@ import ( var policyStatusGauge = prometheus.NewGaugeVec( prometheus.GaugeOpts{ Name: "policy_governance_info", - Help: "The compliance status of the named policy. 0 == Compliant. 1 == NonCompliant", + Help: "The compliance status of the named policy. 0 == Compliant. 1 == NonCompliant. -1 == Unknown/Pending", }, []string{ "type", // "root" or "propagated" diff --git a/controllers/policymetrics/policymetrics_controller.go b/controllers/policymetrics/policymetrics_controller.go index 3b569040..1b4ae670 100644 --- a/controllers/policymetrics/policymetrics_controller.go +++ b/controllers/policymetrics/policymetrics_controller.go @@ -130,6 +130,8 @@ func (r *MetricReconciler) Reconcile(ctx context.Context, request ctrl.Request) statusMetric.Set(0) } else if pol.Status.ComplianceState == policiesv1.NonCompliant { statusMetric.Set(1) + } else { + statusMetric.Set(-1) } return reconcile.Result{}, nil