Skip to content

Commit 3c13a83

Browse files
committed
OTA-1626: Handle unknown operators
Following up [1], the function `parseClusterOperatorNames` raises up an error if it gets unknown operators which is a result of CVO's producing a malformed message. It leads to a failure associated to component "Cluster Version Operator". [1]. #30269 (comment)
1 parent 0734d3a commit 3c13a83

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

pkg/monitortests/clusterversionoperator/clusterversionchecker/monitortest.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,6 @@ func (w *monitor) noFailingUnknownCondition(intervals monitorapi.Intervals) []*j
158158

159159
for _, coName := range sets.List(violations) {
160160
bzComponent := platformidentification.GetBugzillaComponentForOperator(coName)
161-
if bzComponent == "Unknown" {
162-
bzComponent = coName
163-
}
164-
165161
m := 30
166162
if coName == "machine-config" {
167163
m = 3 * m
@@ -202,6 +198,9 @@ func parseClusterOperatorNames(message string) (sets.Set[string], error) {
202198
ret.Insert(strings.TrimSpace(coName))
203199
}
204200
}
201+
if diff := sets.List(ret.Difference(sets.New[string](platformidentification.KnownOperators.List()...))); len(diff) > 0 {
202+
return nil, fmt.Errorf("found unknown operator names %q from %q", strings.Join(diff, ", "), message)
203+
}
205204
if len(ret) == 0 {
206205
return nil, fmt.Errorf("failed to parse cluster operator names from %q", message)
207206
}

pkg/monitortests/clusterversionoperator/clusterversionchecker/monitortest_test.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ func Test_parseClusterOperatorNames(t *testing.T) {
3535
{
3636
name: "one CO timeout",
3737
reason: "SlowClusterOperator",
38-
message: "waiting on co-timeout over 30 minutes which is longer than expected",
39-
expected: sets.New[string]("co-timeout"),
38+
message: "waiting on network over 30 minutes which is longer than expected",
39+
expected: sets.New[string]("network"),
4040
},
4141
{
4242
name: "mco timeout",
@@ -53,20 +53,26 @@ func Test_parseClusterOperatorNames(t *testing.T) {
5353
{
5454
name: "two COs timeout",
5555
reason: "SlowClusterOperator",
56-
message: "waiting on co-timeout, co-bar-timeout over 30 minutes which is longer than expected",
57-
expected: sets.New[string]("co-timeout", "co-bar-timeout"),
56+
message: "waiting on console, network over 30 minutes which is longer than expected",
57+
expected: sets.New[string]("console", "network"),
5858
},
5959
{
6060
name: "one CO and mco timeout",
6161
reason: "SlowClusterOperator",
62-
message: "waiting on co-timeout over 30 minutes and machine-config over 90 minutes which is longer than expected",
63-
expected: sets.New[string]("machine-config", "co-timeout"),
62+
message: "waiting on network over 30 minutes and machine-config over 90 minutes which is longer than expected",
63+
expected: sets.New[string]("machine-config", "network"),
6464
},
6565
{
6666
name: "three COs timeout",
6767
reason: "SlowClusterOperator",
68-
message: "waiting on co-timeout, co-bar-timeout over 30 minutes and machine-config over 90 minutes which is longer than expected",
69-
expected: sets.New[string]("machine-config", "co-timeout", "co-bar-timeout"),
68+
message: "waiting on console, network over 30 minutes and machine-config over 90 minutes which is longer than expected",
69+
expected: sets.New[string]("machine-config", "console", "network"),
70+
},
71+
{
72+
name: "unknown operators",
73+
reason: "SlowClusterOperator",
74+
message: "waiting on unknown, bar, network over 30 minutes and machine-config over 90 minutes which is longer than expected",
75+
expectedErr: fmt.Errorf(`found unknown operator names "bar, unknown" from "changed to Some=Unknown: SlowClusterOperator: waiting on unknown, bar, network over 30 minutes and machine-config over 90 minutes which is longer than expected"`),
7076
},
7177
}
7278

0 commit comments

Comments
 (0)