Skip to content

Commit 1632b29

Browse files
authored
Revert "OTA-1546: Add a metric and an alert for conditional risk conditions"
1 parent 7092376 commit 1632b29

3 files changed

Lines changed: 0 additions & 169 deletions

File tree

install/0000_90_cluster-version-operator_02_prometheusrule-TechPreviewNoUpgrade.yaml

Lines changed: 0 additions & 26 deletions
This file was deleted.

pkg/cvo/metrics.go

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515

1616
corev1 "k8s.io/api/core/v1"
1717
apierrors "k8s.io/apimachinery/pkg/api/errors"
18-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1918
"k8s.io/apimachinery/pkg/labels"
2019
"k8s.io/apimachinery/pkg/util/sets"
2120
"k8s.io/apiserver/pkg/server/dynamiccertificates"
@@ -55,7 +54,6 @@ type operatorMetrics struct {
5554
capability *prometheus.GaugeVec
5655
clusterOperatorUp *prometheus.GaugeVec
5756
clusterOperatorConditions *prometheus.GaugeVec
58-
clusterVersionRiskConditions *prometheus.GaugeVec
5957
clusterOperatorConditionTransitions *prometheus.GaugeVec
6058
clusterInstaller *prometheus.GaugeVec
6159
clusterVersionOperatorUpdateRetrievalTimestampSeconds *prometheus.GaugeVec
@@ -106,10 +104,6 @@ penultimate completed version for 'completed'.
106104
Name: "cluster_operator_conditions",
107105
Help: "Report the conditions for active cluster operators. 0 is False and 1 is True.",
108106
}, []string{"name", "condition", "reason"}),
109-
clusterVersionRiskConditions: prometheus.NewGaugeVec(prometheus.GaugeOpts{
110-
Name: "cluster_version_risk_conditions",
111-
Help: "Report the risk conditions for the cluster version. -1 is Unknown, 0 is False and 1 is True.",
112-
}, []string{"condition", "risk", "reason"}),
113107
clusterOperatorConditionTransitions: prometheus.NewGaugeVec(prometheus.GaugeOpts{
114108
Name: "cluster_operator_condition_transitions",
115109
Help: "Reports the number of times that a condition on a cluster operator changes status",
@@ -495,7 +489,6 @@ func (m *operatorMetrics) Describe(ch chan<- *prometheus.Desc) {
495489
ch <- m.capability.WithLabelValues("").Desc()
496490
ch <- m.clusterOperatorUp.WithLabelValues("", "", "").Desc()
497491
ch <- m.clusterOperatorConditions.WithLabelValues("", "", "").Desc()
498-
ch <- m.clusterVersionRiskConditions.WithLabelValues("", "", "").Desc()
499492
ch <- m.clusterOperatorConditionTransitions.WithLabelValues("", "").Desc()
500493
ch <- m.clusterInstaller.WithLabelValues("", "", "").Desc()
501494
ch <- m.clusterVersionOperatorUpdateRetrievalTimestampSeconds.WithLabelValues("").Desc()
@@ -517,26 +510,6 @@ func (m *operatorMetrics) collectConditionalUpdates(ch chan<- prometheus.Metric,
517510
}
518511
}
519512

520-
func (m *operatorMetrics) collectConditionalUpdateRisks(ch chan<- prometheus.Metric, risks []configv1.ConditionalUpdateRisk) {
521-
for _, risk := range risks {
522-
for _, condition := range risk.Conditions {
523-
if condition.Type != internal.ConditionalUpdateRiskConditionTypeApplies {
524-
continue
525-
}
526-
527-
g := m.clusterVersionRiskConditions.WithLabelValues(condition.Type, risk.Name, condition.Reason)
528-
switch condition.Status {
529-
case metav1.ConditionTrue:
530-
g.Set(1)
531-
case metav1.ConditionUnknown:
532-
g.Set(-1)
533-
}
534-
// We do not need to do g.Set(0) as it is done when g is initialized
535-
ch <- g
536-
}
537-
}
538-
}
539-
540513
// Collect collects metrics from the operator into the channel ch
541514
func (m *operatorMetrics) Collect(ch chan<- prometheus.Metric) {
542515
current := m.optr.currentVersion()
@@ -682,9 +655,6 @@ func (m *operatorMetrics) Collect(ch chan<- prometheus.Metric) {
682655
}
683656

684657
m.collectConditionalUpdates(ch, cv.Status.ConditionalUpdates)
685-
if m.optr.shouldReconcileAcceptRisks() {
686-
m.collectConditionalUpdateRisks(ch, cv.Status.ConditionalUpdateRisks)
687-
}
688658
}
689659

690660
g := m.version.WithLabelValues("current", current.Version, current.Image, completed.Version)

pkg/cvo/metrics_test.go

Lines changed: 0 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
configv1 "github.com/openshift/api/config/v1"
2626
"github.com/openshift/library-go/pkg/crypto"
2727

28-
"github.com/openshift/cluster-version-operator/pkg/featuregates"
2928
"github.com/openshift/cluster-version-operator/pkg/internal"
3029
)
3130

@@ -670,7 +669,6 @@ func Test_operatorMetrics_Collect(t *testing.T) {
670669
}
671670
for _, tt := range tests {
672671
t.Run(tt.name, func(t *testing.T) {
673-
tt.optr.enabledCVOFeatureGates = featuregates.DefaultCvoGates("version")
674672
tt.optr.eventRecorder = record.NewFakeRecorder(100)
675673
if tt.optr.cvLister == nil {
676674
tt.optr.cvLister = &cvLister{}
@@ -977,117 +975,6 @@ func TestCollectUnknownConditionalUpdates(t *testing.T) {
977975
}
978976
}
979977

980-
func Test_collectConditionalUpdateRisks(t *testing.T) {
981-
type valueWithLabels struct {
982-
value float64
983-
labels map[string]string
984-
}
985-
testCases := []struct {
986-
name string
987-
risks []configv1.ConditionalUpdateRisk
988-
expected []valueWithLabels
989-
}{
990-
{
991-
name: "no conditional updates",
992-
expected: []valueWithLabels{},
993-
},
994-
{
995-
name: "unknown type",
996-
risks: []configv1.ConditionalUpdateRisk{
997-
{
998-
Name: "RiskX",
999-
Conditions: []metav1.Condition{{
1000-
Type: internal.ConditionalUpdateConditionTypeRecommended,
1001-
Status: metav1.ConditionFalse,
1002-
Reason: "ReasonA",
1003-
Message: "Risk does not apply",
1004-
}},
1005-
},
1006-
},
1007-
},
1008-
{
1009-
name: "apply false",
1010-
risks: []configv1.ConditionalUpdateRisk{
1011-
{
1012-
Name: "RiskX",
1013-
Conditions: []metav1.Condition{{
1014-
Type: internal.ConditionalUpdateRiskConditionTypeApplies,
1015-
Status: metav1.ConditionFalse,
1016-
Reason: "ReasonA",
1017-
Message: "Risk does not apply",
1018-
}},
1019-
},
1020-
},
1021-
expected: []valueWithLabels{{
1022-
labels: map[string]string{"condition": "Applies", "risk": "RiskX", "reason": "ReasonA"},
1023-
}},
1024-
},
1025-
{
1026-
name: "apply true",
1027-
risks: []configv1.ConditionalUpdateRisk{
1028-
{
1029-
Name: "RiskX",
1030-
Conditions: []metav1.Condition{{
1031-
Type: internal.ConditionalUpdateRiskConditionTypeApplies,
1032-
Status: metav1.ConditionTrue,
1033-
Reason: "ReasonA",
1034-
Message: "Risk does not apply",
1035-
}},
1036-
},
1037-
},
1038-
expected: []valueWithLabels{{
1039-
value: 1,
1040-
labels: map[string]string{"condition": "Applies", "risk": "RiskX", "reason": "ReasonA"},
1041-
}},
1042-
},
1043-
{
1044-
name: "apply unknown",
1045-
risks: []configv1.ConditionalUpdateRisk{
1046-
{
1047-
Name: "RiskX",
1048-
Conditions: []metav1.Condition{{
1049-
Type: internal.ConditionalUpdateRiskConditionTypeApplies,
1050-
Status: metav1.ConditionUnknown,
1051-
Reason: "ReasonA",
1052-
Message: "Risk does not apply",
1053-
}},
1054-
},
1055-
},
1056-
expected: []valueWithLabels{{
1057-
value: -1,
1058-
labels: map[string]string{"condition": "Applies", "risk": "RiskX", "reason": "ReasonA"},
1059-
}},
1060-
},
1061-
}
1062-
1063-
for _, tc := range testCases {
1064-
tc := tc
1065-
t.Run(tc.name, func(t *testing.T) {
1066-
optr := &Operator{}
1067-
m := newOperatorMetrics(optr)
1068-
ch := make(chan prometheus.Metric)
1069-
1070-
go func() {
1071-
m.collectConditionalUpdateRisks(ch, tc.risks)
1072-
close(ch)
1073-
}()
1074-
1075-
var collected []prometheus.Metric
1076-
for item := range ch {
1077-
collected = append(collected, item)
1078-
}
1079-
1080-
if lenC, lenE := len(collected), len(tc.expected); lenC != lenE {
1081-
1082-
t.Fatalf("Expected %d metrics, got %d metrics\nGot metrics: %s", lenE, lenC, spew.Sdump(collected))
1083-
}
1084-
for i := range tc.expected {
1085-
expectMetric(t, collected[i], tc.expected[i].value, tc.expected[i].labels)
1086-
}
1087-
})
1088-
}
1089-
}
1090-
1091978
func expectMetric(t *testing.T, metric prometheus.Metric, value float64, labels map[string]string) {
1092979
t.Helper()
1093980
var d dto.Metric

0 commit comments

Comments
 (0)