Skip to content

Commit

Permalink
Add -1 as a possible compliance value for the status metric
Browse files Browse the repository at this point in the history
ref: https://issues.redhat.com/browse/ACM-11504
Signed-off-by: Jason Zhang <jaszhang@redhat.com>
(cherry picked from commit e43515ba4e7775f5f44c98c1b3a0592a45ff3ecc)
  • Loading branch information
zyjjay authored and openshift-merge-bot[bot] committed May 15, 2024
1 parent 4857f5a commit fed04db
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion controllers/policymetrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions controllers/policymetrics/policymetrics_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fed04db

Please sign in to comment.