Skip to content

Commit 4702f81

Browse files
committed
pkg/cvo/metrics: Serve cluster_version_available_updates when channel is set
Since 8b91189 (cvo: Add prometheus metrics to the CVO for current update state, 2018-11-05, #45), cluster_version_available_updates is only served when there are unconditionally-recommended updates and retrieval is succeeding. This makes it hard to understand at the fleet level when: cluster_operator_conditions{name="version", condition="RetrievedUpdates", reason="VersionNotFound"} == 0 is because of a misconfigured channel, or a misbehaving Update Service, or otherwise. We should always export cluster_version_available_updates whenever a channel is set, to make it easier to isolate the “because the cluster-admin has somehow selected a channel not compatible with their current version” (which we can’t do much about other than keep serving our existing CannotRetrieveUpdates alert) from the other possibilities (which we might be able to do something about).
1 parent 6d31e54 commit 4702f81

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

pkg/cvo/metrics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ func (m *operatorMetrics) Collect(ch chan<- prometheus.Metric) {
629629
ch <- g
630630
}
631631

632-
if len(cv.Spec.Upstream) > 0 || len(cv.Status.AvailableUpdates) > 0 || resourcemerge.IsOperatorStatusConditionTrue(cv.Status.Conditions, configv1.RetrievedUpdates) {
632+
if len(cv.Spec.Channel) > 0 {
633633
upstream := "<default>"
634634
if len(m.optr.updateService) > 0 {
635635
upstream = string(m.optr.updateService)

pkg/cvo/metrics_test.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,9 @@ func Test_operatorMetrics_Collect(t *testing.T) {
366366
Name: "test",
367367
CreationTimestamp: metav1.Time{Time: time.Unix(2, 0)},
368368
},
369+
Spec: configv1.ClusterVersionSpec{
370+
Channel: "test-channel",
371+
},
369372
Status: configv1.ClusterVersionStatus{
370373
AvailableUpdates: []configv1.Release{
371374
{Version: "1.0.1"},
@@ -382,7 +385,7 @@ func Test_operatorMetrics_Collect(t *testing.T) {
382385
}
383386
expectMetric(t, metrics[0], 2, map[string]string{"type": "initial", "version": "", "image": "", "from_version": ""})
384387
expectMetric(t, metrics[1], 2, map[string]string{"type": "cluster", "version": "", "image": "", "from_version": ""})
385-
expectMetric(t, metrics[2], 2, map[string]string{"upstream": "<default>", "channel": ""})
388+
expectMetric(t, metrics[2], 2, map[string]string{"upstream": "<default>", "channel": "test-channel"})
386389
expectMetric(t, metrics[3], 0, map[string]string{"type": "current", "version": "", "image": "", "from_version": ""})
387390
expectMetric(t, metrics[4], 1, map[string]string{"type": ""})
388391
},
@@ -398,6 +401,9 @@ func Test_operatorMetrics_Collect(t *testing.T) {
398401
Name: "test",
399402
CreationTimestamp: metav1.Time{Time: time.Unix(2, 0)},
400403
},
404+
Spec: configv1.ClusterVersionSpec{
405+
Channel: "test-channel",
406+
},
401407
Status: configv1.ClusterVersionStatus{
402408
Conditions: []configv1.ClusterOperatorStatusCondition{
403409
{Type: configv1.RetrievedUpdates, Status: configv1.ConditionTrue, Reason: "Because stuff"},
@@ -414,7 +420,7 @@ func Test_operatorMetrics_Collect(t *testing.T) {
414420
expectMetric(t, metrics[0], 2, map[string]string{"type": "initial", "version": "", "image": "", "from_version": ""})
415421
expectMetric(t, metrics[1], 2, map[string]string{"type": "cluster", "version": "", "image": "", "from_version": ""})
416422

417-
expectMetric(t, metrics[2], 0, map[string]string{"upstream": "<default>", "channel": ""})
423+
expectMetric(t, metrics[2], 0, map[string]string{"upstream": "<default>", "channel": "test-channel"})
418424
expectMetric(t, metrics[3], 1, map[string]string{"name": "version", "condition": "RetrievedUpdates", "reason": "Because stuff"})
419425
expectMetric(t, metrics[4], 0, map[string]string{"type": "current", "version": "", "image": "", "from_version": ""})
420426
expectMetric(t, metrics[5], 1, map[string]string{"type": ""})

0 commit comments

Comments
 (0)