diff --git a/pkg/cvo/metrics.go b/pkg/cvo/metrics.go index 30d04302f..d26abe427 100644 --- a/pkg/cvo/metrics.go +++ b/pkg/cvo/metrics.go @@ -629,7 +629,7 @@ func (m *operatorMetrics) Collect(ch chan<- prometheus.Metric) { ch <- g } - if len(cv.Spec.Upstream) > 0 || len(cv.Status.AvailableUpdates) > 0 || resourcemerge.IsOperatorStatusConditionTrue(cv.Status.Conditions, configv1.RetrievedUpdates) { + if len(cv.Spec.Channel) > 0 { upstream := "" if len(m.optr.updateService) > 0 { upstream = string(m.optr.updateService) diff --git a/pkg/cvo/metrics_test.go b/pkg/cvo/metrics_test.go index f12852be3..5cefc18c0 100644 --- a/pkg/cvo/metrics_test.go +++ b/pkg/cvo/metrics_test.go @@ -366,6 +366,9 @@ func Test_operatorMetrics_Collect(t *testing.T) { Name: "test", CreationTimestamp: metav1.Time{Time: time.Unix(2, 0)}, }, + Spec: configv1.ClusterVersionSpec{ + Channel: "test-channel", + }, Status: configv1.ClusterVersionStatus{ AvailableUpdates: []configv1.Release{ {Version: "1.0.1"}, @@ -382,7 +385,7 @@ func Test_operatorMetrics_Collect(t *testing.T) { } expectMetric(t, metrics[0], 2, map[string]string{"type": "initial", "version": "", "image": "", "from_version": ""}) expectMetric(t, metrics[1], 2, map[string]string{"type": "cluster", "version": "", "image": "", "from_version": ""}) - expectMetric(t, metrics[2], 2, map[string]string{"upstream": "", "channel": ""}) + expectMetric(t, metrics[2], 2, map[string]string{"upstream": "", "channel": "test-channel"}) expectMetric(t, metrics[3], 0, map[string]string{"type": "current", "version": "", "image": "", "from_version": ""}) expectMetric(t, metrics[4], 1, map[string]string{"type": ""}) }, @@ -398,6 +401,9 @@ func Test_operatorMetrics_Collect(t *testing.T) { Name: "test", CreationTimestamp: metav1.Time{Time: time.Unix(2, 0)}, }, + Spec: configv1.ClusterVersionSpec{ + Channel: "test-channel", + }, Status: configv1.ClusterVersionStatus{ Conditions: []configv1.ClusterOperatorStatusCondition{ {Type: configv1.RetrievedUpdates, Status: configv1.ConditionTrue, Reason: "Because stuff"}, @@ -414,7 +420,7 @@ func Test_operatorMetrics_Collect(t *testing.T) { expectMetric(t, metrics[0], 2, map[string]string{"type": "initial", "version": "", "image": "", "from_version": ""}) expectMetric(t, metrics[1], 2, map[string]string{"type": "cluster", "version": "", "image": "", "from_version": ""}) - expectMetric(t, metrics[2], 0, map[string]string{"upstream": "", "channel": ""}) + expectMetric(t, metrics[2], 0, map[string]string{"upstream": "", "channel": "test-channel"}) expectMetric(t, metrics[3], 1, map[string]string{"name": "version", "condition": "RetrievedUpdates", "reason": "Because stuff"}) expectMetric(t, metrics[4], 0, map[string]string{"type": "current", "version": "", "image": "", "from_version": ""}) expectMetric(t, metrics[5], 1, map[string]string{"type": ""})