Skip to content

Commit 677c97e

Browse files
committed
Address comments from review
1 parent 471c90c commit 677c97e

File tree

4 files changed

+25
-31
lines changed

4 files changed

+25
-31
lines changed

pkg/monitor/monitorapi/identification_operator.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,17 @@ func GetOperatorConditionStatus(interval Interval) *configv1.ClusterOperatorStat
2828
return condition
2929
}
3030

31-
// GetOperatorConditionHumanMessage constructs a human-readable message from a given ClusterOperatorStatusCondition
32-
func GetOperatorConditionHumanMessage(s *configv1.ClusterOperatorStatusCondition) string {
31+
// GetOperatorConditionHumanMessage constructs a human-readable message from a given ClusterOperatorStatusCondition with a given prefix
32+
func GetOperatorConditionHumanMessage(s *configv1.ClusterOperatorStatusCondition, prefix string) string {
3333
if s == nil {
3434
return ""
3535
}
3636
switch {
3737
case len(s.Reason) > 0 && len(s.Message) > 0:
38-
return fmt.Sprintf("changed %s to %s: %s: %s", s.Type, s.Status, s.Reason, s.Message)
38+
return fmt.Sprintf("%s%s=%s: %s: %s", prefix, s.Type, s.Status, s.Reason, s.Message)
3939
case len(s.Message) > 0:
40-
return fmt.Sprintf("changed %s to %s: %s", s.Type, s.Status, s.Message)
40+
return fmt.Sprintf("%s%s=%s: %s", prefix, s.Type, s.Status, s.Message)
4141
default:
42-
return fmt.Sprintf("changed %s to %s", s.Type, s.Status)
42+
return fmt.Sprintf("%s%s=%s", prefix, s.Type, s.Status)
4343
}
4444
}

pkg/monitortests/clusterversionoperator/clusterversionchecker/monitortest.go

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -156,31 +156,25 @@ func (w *monitor) noFailingUnknownCondition(intervals monitorapi.Intervals) []*j
156156

157157
ret := []*junitapi.JUnitTestCase{noFailures}
158158

159-
except := func(coName string) string {
160-
return ""
161-
}
162-
163159
for _, coName := range sets.List(violations) {
164-
if reason := except(coName); reason == "" {
165-
bzComponent := platformidentification.GetBugzillaComponentForOperator(coName)
166-
if bzComponent == "Unknown" {
167-
bzComponent = coName
168-
}
160+
bzComponent := platformidentification.GetBugzillaComponentForOperator(coName)
161+
if bzComponent == "Unknown" {
162+
bzComponent = coName
163+
}
169164

170-
m := 30
171-
if coName == "machine-config" {
172-
m = 3 * m
173-
}
174-
output := fmt.Sprintf("Cluster Operator %s has not completed version change after %d minutes", coName, m)
175-
ret = append(ret, &junitapi.JUnitTestCase{
176-
Name: fmt.Sprintf("[bz-%v] clusteroperator/%v must complete version change under %d minutes", bzComponent, coName, m),
177-
Duration: duration,
178-
FailureOutput: &junitapi.FailureOutput{
179-
Output: output,
180-
Message: output,
181-
},
182-
})
165+
m := 30
166+
if coName == "machine-config" {
167+
m = 3 * m
183168
}
169+
output := fmt.Sprintf("Cluster Operator %s has not completed version change after %d minutes", coName, m)
170+
ret = append(ret, &junitapi.JUnitTestCase{
171+
Name: fmt.Sprintf("[bz-%v] clusteroperator/%v must complete version change under %d minutes", bzComponent, coName, m),
172+
Duration: duration,
173+
FailureOutput: &junitapi.FailureOutput{
174+
Output: output,
175+
Message: output,
176+
},
177+
})
184178
}
185179

186180
return ret

pkg/monitortests/clusterversionoperator/clusterversionchecker/monitortest_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ func Test_parseClusterOperatorNames(t *testing.T) {
2525
name: "unexpected",
2626
reason: "reason",
2727
message: "unexpected",
28-
expectedErr: fmt.Errorf("failed to parse cluster operator names from %q", "changed Some to Unknown: reason: unexpected"),
28+
expectedErr: fmt.Errorf("failed to parse cluster operator names from %q", "changed to Some=Unknown: reason: unexpected"),
2929
},
3030
{
3131
name: "legit waiting on",
3232
message: "Working towards 1.2.3: waiting on co-not-timeout",
33-
expectedErr: fmt.Errorf("failed to parse cluster operator names from %q", "changed Some to Unknown: Working towards 1.2.3: waiting on co-not-timeout"),
33+
expectedErr: fmt.Errorf("failed to parse cluster operator names from %q", "changed to Some=Unknown: Working towards 1.2.3: waiting on co-not-timeout"),
3434
},
3535
{
3636
name: "one CO timeout",
@@ -78,7 +78,7 @@ func Test_parseClusterOperatorNames(t *testing.T) {
7878
Status: configv1.ConditionUnknown,
7979
Message: tc.message,
8080
Reason: tc.reason,
81-
})
81+
}, "changed to ")
8282
actual, actuallErr := parseClusterOperatorNames(msg)
8383
if diff := cmp.Diff(tc.expectedErr, actuallErr, cmp.FilterValues(func(x, y interface{}) bool {
8484
_, ok1 := x.(error)

pkg/monitortests/testframework/watchclusteroperators/operator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func startClusterOperatorMonitoring(ctx context.Context, m monitorapi.RecorderWr
192192
monitorapi.AnnotationStatus: string(s.Status),
193193
monitorapi.AnnotationReason: s.Reason,
194194
}).
195-
HumanMessage(monitorapi.GetOperatorConditionHumanMessage(s))).BuildNow())
195+
HumanMessage(monitorapi.GetOperatorConditionHumanMessage(s, "changed to "))).BuildNow())
196196
}
197197
}
198198
return intervals

0 commit comments

Comments
 (0)