diff --git a/hypershift-operator/controllers/hostedcluster/metrics/metrics.go b/hypershift-operator/controllers/hostedcluster/metrics/metrics.go index 97b897436709..e0d83b02cacb 100644 --- a/hypershift-operator/controllers/hostedcluster/metrics/metrics.go +++ b/hypershift-operator/controllers/hostedcluster/metrics/metrics.go @@ -423,7 +423,7 @@ func collectUpgradingDurationMetric(ch chan<- prometheus.Metric, clk clock.Clock func collectLimitedSupportMetric(ch chan<- prometheus.Metric, hcluster *hyperv1.HostedCluster, hclusterLabelValues []string) { limitedSupportValue := 0.0 - if _, ok := hcluster.Labels[hyperv1.LimitedSupportLabel]; ok { + if v, ok := hcluster.Labels[hyperv1.LimitedSupportLabel]; ok && v == "true" { limitedSupportValue = 1.0 } ch <- prometheus.MustNewConstMetric( diff --git a/hypershift-operator/controllers/hostedcluster/metrics/metrics_test.go b/hypershift-operator/controllers/hostedcluster/metrics/metrics_test.go index f6ee01445419..8f077294c4ab 100644 --- a/hypershift-operator/controllers/hostedcluster/metrics/metrics_test.go +++ b/hypershift-operator/controllers/hostedcluster/metrics/metrics_test.go @@ -383,10 +383,20 @@ func TestReportLimitedSuportEnabled(t *testing.T) { expected *dto.MetricFamily }{ { - name: "When limited support label is set, metric is reported as one", + name: "When limited support label is set to true, metric is reported as one", labels: map[string]string{hyperv1.LimitedSupportLabel: "true"}, expected: wrapExpectedValueAsMetric(1), }, + { + name: "When limited support label is set to false, metric is reported as zero", + labels: map[string]string{hyperv1.LimitedSupportLabel: "false"}, + expected: wrapExpectedValueAsMetric(0), + }, + { + name: "When limited support label is set to anything unsupported, metric is reported as zero", + labels: map[string]string{hyperv1.LimitedSupportLabel: "foo"}, + expected: wrapExpectedValueAsMetric(0), + }, { name: "When limited support label is not set, metric is reported as zero", labels: map[string]string{},