Skip to content

Commit 6c36937

Browse files
committed
Bug 1884334: UpdateError: add and use Progressing field
1 parent 84b3884 commit 6c36937

File tree

5 files changed

+112
-87
lines changed

5 files changed

+112
-87
lines changed

pkg/cvo/internal/operatorstatus.go

+19-15
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,11 @@ func waitForOperatorStatusToBeDone(ctx context.Context, interval time.Duration,
128128
actual, err := client.Get(ctx, expected.Name)
129129
if err != nil {
130130
lastErr = &payload.UpdateError{
131-
Nested: err,
132-
Reason: "ClusterOperatorNotAvailable",
133-
Message: fmt.Sprintf("Cluster operator %s has not yet reported success", expected.Name),
134-
Name: expected.Name,
131+
Nested: err,
132+
Progressing: true,
133+
Reason: "ClusterOperatorNotAvailable",
134+
Message: fmt.Sprintf("Cluster operator %s has not yet reported success", expected.Name),
135+
Name: expected.Name,
135136
}
136137
return false, nil
137138
}
@@ -160,10 +161,11 @@ func waitForOperatorStatusToBeDone(ctx context.Context, interval time.Duration,
160161

161162
message := fmt.Sprintf("Cluster operator %s is still updating", actual.Name)
162163
lastErr = &payload.UpdateError{
163-
Nested: errors.New(lowerFirst(message)),
164-
Reason: "ClusterOperatorNotAvailable",
165-
Message: message,
166-
Name: actual.Name,
164+
Nested: errors.New(lowerFirst(message)),
165+
Progressing: true,
166+
Reason: "ClusterOperatorNotAvailable",
167+
Message: message,
168+
Name: actual.Name,
167169
}
168170
return false, nil
169171
}
@@ -220,10 +222,11 @@ func waitForOperatorStatusToBeDone(ctx context.Context, interval time.Duration,
220222
message = fmt.Sprintf("Cluster operator %s is reporting a failure: %s", actual.Name, condition.Message)
221223
}
222224
lastErr = &payload.UpdateError{
223-
Nested: errors.New(lowerFirst(message)),
224-
Reason: "ClusterOperatorDegraded",
225-
Message: message,
226-
Name: actual.Name,
225+
Nested: errors.New(lowerFirst(message)),
226+
Progressing: false,
227+
Reason: "ClusterOperatorDegraded",
228+
Message: message,
229+
Name: actual.Name,
227230
}
228231
return false, nil
229232
}
@@ -232,9 +235,10 @@ func waitForOperatorStatusToBeDone(ctx context.Context, interval time.Duration,
232235
Nested: fmt.Errorf("cluster operator %s is not done; it is available=%v, progressing=%v, degraded=%v",
233236
actual.Name, available, progressing, degraded,
234237
),
235-
Reason: "ClusterOperatorNotAvailable",
236-
Message: fmt.Sprintf("Cluster operator %s has not yet reported success", actual.Name),
237-
Name: actual.Name,
238+
Progressing: progressing,
239+
Reason: "ClusterOperatorNotAvailable",
240+
Message: fmt.Sprintf("Cluster operator %s has not yet reported success", actual.Name),
241+
Name: actual.Name,
238242
}
239243
return false, nil
240244
}, ctx.Done())

pkg/cvo/internal/operatorstatus_test.go

+75-60
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
4343
},
4444
},
4545
expErr: &payload.UpdateError{
46-
Nested: apierrors.NewNotFound(schema.GroupResource{"", "clusteroperator"}, "test-co"),
47-
Reason: "ClusterOperatorNotAvailable",
48-
Message: "Cluster operator test-co has not yet reported success",
49-
Name: "test-co",
46+
Nested: apierrors.NewNotFound(schema.GroupResource{"", "clusteroperator"}, "test-co"),
47+
Progressing: true,
48+
Reason: "ClusterOperatorNotAvailable",
49+
Message: "Cluster operator test-co has not yet reported success",
50+
Name: "test-co",
5051
},
5152
}, {
5253
name: "cluster operator reporting no versions with no operands",
@@ -62,10 +63,11 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
6263
},
6364
},
6465
expErr: &payload.UpdateError{
65-
Nested: fmt.Errorf("cluster operator test-co is still updating"),
66-
Reason: "ClusterOperatorNotAvailable",
67-
Message: "Cluster operator test-co is still updating",
68-
Name: "test-co",
66+
Nested: fmt.Errorf("cluster operator test-co is still updating"),
67+
Progressing: true,
68+
Reason: "ClusterOperatorNotAvailable",
69+
Message: "Cluster operator test-co is still updating",
70+
Name: "test-co",
6971
},
7072
}, {
7173
name: "cluster operator reporting no versions",
@@ -83,10 +85,11 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
8385
},
8486
},
8587
expErr: &payload.UpdateError{
86-
Nested: fmt.Errorf("cluster operator test-co is still updating"),
87-
Reason: "ClusterOperatorNotAvailable",
88-
Message: "Cluster operator test-co is still updating",
89-
Name: "test-co",
88+
Nested: fmt.Errorf("cluster operator test-co is still updating"),
89+
Progressing: true,
90+
Reason: "ClusterOperatorNotAvailable",
91+
Message: "Cluster operator test-co is still updating",
92+
Name: "test-co",
9093
},
9194
}, {
9295
name: "cluster operator reporting no versions for operand",
@@ -109,10 +112,11 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
109112
},
110113
},
111114
expErr: &payload.UpdateError{
112-
Nested: fmt.Errorf("cluster operator test-co is still updating"),
113-
Reason: "ClusterOperatorNotAvailable",
114-
Message: "Cluster operator test-co is still updating",
115-
Name: "test-co",
115+
Nested: fmt.Errorf("cluster operator test-co is still updating"),
116+
Progressing: true,
117+
Reason: "ClusterOperatorNotAvailable",
118+
Message: "Cluster operator test-co is still updating",
119+
Name: "test-co",
116120
},
117121
}, {
118122
name: "cluster operator reporting old versions",
@@ -137,10 +141,11 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
137141
},
138142
},
139143
expErr: &payload.UpdateError{
140-
Nested: fmt.Errorf("cluster operator test-co is still updating"),
141-
Reason: "ClusterOperatorNotAvailable",
142-
Message: "Cluster operator test-co is still updating",
143-
Name: "test-co",
144+
Nested: fmt.Errorf("cluster operator test-co is still updating"),
145+
Progressing: true,
146+
Reason: "ClusterOperatorNotAvailable",
147+
Message: "Cluster operator test-co is still updating",
148+
Name: "test-co",
144149
},
145150
}, {
146151
name: "cluster operator reporting mix of desired and old versions",
@@ -165,10 +170,11 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
165170
},
166171
},
167172
expErr: &payload.UpdateError{
168-
Nested: fmt.Errorf("cluster operator test-co is still updating"),
169-
Reason: "ClusterOperatorNotAvailable",
170-
Message: "Cluster operator test-co is still updating",
171-
Name: "test-co",
173+
Nested: fmt.Errorf("cluster operator test-co is still updating"),
174+
Progressing: true,
175+
Reason: "ClusterOperatorNotAvailable",
176+
Message: "Cluster operator test-co is still updating",
177+
Name: "test-co",
172178
},
173179
}, {
174180
name: "cluster operator reporting desired operator and old versions for 2 operands",
@@ -197,10 +203,11 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
197203
},
198204
},
199205
expErr: &payload.UpdateError{
200-
Nested: fmt.Errorf("cluster operator test-co is still updating"),
201-
Reason: "ClusterOperatorNotAvailable",
202-
Message: "Cluster operator test-co is still updating",
203-
Name: "test-co",
206+
Nested: fmt.Errorf("cluster operator test-co is still updating"),
207+
Progressing: true,
208+
Reason: "ClusterOperatorNotAvailable",
209+
Message: "Cluster operator test-co is still updating",
210+
Name: "test-co",
204211
},
205212
}, {
206213
name: "cluster operator reporting desired operator and mix of old and desired versions for 2 operands",
@@ -229,10 +236,11 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
229236
},
230237
},
231238
expErr: &payload.UpdateError{
232-
Nested: fmt.Errorf("cluster operator test-co is still updating"),
233-
Reason: "ClusterOperatorNotAvailable",
234-
Message: "Cluster operator test-co is still updating",
235-
Name: "test-co",
239+
Nested: fmt.Errorf("cluster operator test-co is still updating"),
240+
Progressing: true,
241+
Reason: "ClusterOperatorNotAvailable",
242+
Message: "Cluster operator test-co is still updating",
243+
Name: "test-co",
236244
},
237245
}, {
238246
name: "cluster operator reporting desired versions and no conditions",
@@ -257,10 +265,11 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
257265
},
258266
},
259267
expErr: &payload.UpdateError{
260-
Nested: fmt.Errorf("cluster operator test-co is not done; it is available=false, progressing=true, degraded=true"),
261-
Reason: "ClusterOperatorNotAvailable",
262-
Message: "Cluster operator test-co has not yet reported success",
263-
Name: "test-co",
268+
Nested: fmt.Errorf("cluster operator test-co is not done; it is available=false, progressing=true, degraded=true"),
269+
Progressing: true,
270+
Reason: "ClusterOperatorNotAvailable",
271+
Message: "Cluster operator test-co has not yet reported success",
272+
Name: "test-co",
264273
},
265274
}, {
266275
name: "cluster operator reporting progressing=true",
@@ -286,10 +295,11 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
286295
},
287296
},
288297
expErr: &payload.UpdateError{
289-
Nested: fmt.Errorf("cluster operator test-co is not done; it is available=false, progressing=true, degraded=true"),
290-
Reason: "ClusterOperatorNotAvailable",
291-
Message: "Cluster operator test-co has not yet reported success",
292-
Name: "test-co",
298+
Nested: fmt.Errorf("cluster operator test-co is not done; it is available=false, progressing=true, degraded=true"),
299+
Progressing: true,
300+
Reason: "ClusterOperatorNotAvailable",
301+
Message: "Cluster operator test-co has not yet reported success",
302+
Name: "test-co",
293303
},
294304
}, {
295305
name: "cluster operator reporting degraded=true",
@@ -315,10 +325,11 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
315325
},
316326
},
317327
expErr: &payload.UpdateError{
318-
Nested: fmt.Errorf("cluster operator test-co is reporting a failure: random error"),
319-
Reason: "ClusterOperatorDegraded",
320-
Message: "Cluster operator test-co is reporting a failure: random error",
321-
Name: "test-co",
328+
Nested: fmt.Errorf("cluster operator test-co is reporting a failure: random error"),
329+
Progressing: false,
330+
Reason: "ClusterOperatorDegraded",
331+
Message: "Cluster operator test-co is reporting a failure: random error",
332+
Name: "test-co",
322333
},
323334
}, {
324335
name: "cluster operator reporting available=true progressing=true",
@@ -344,10 +355,11 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
344355
},
345356
},
346357
expErr: &payload.UpdateError{
347-
Nested: fmt.Errorf("cluster operator test-co is not done; it is available=true, progressing=true, degraded=true"),
348-
Reason: "ClusterOperatorNotAvailable",
349-
Message: "Cluster operator test-co has not yet reported success",
350-
Name: "test-co",
358+
Nested: fmt.Errorf("cluster operator test-co is not done; it is available=true, progressing=true, degraded=true"),
359+
Progressing: true,
360+
Reason: "ClusterOperatorNotAvailable",
361+
Message: "Cluster operator test-co has not yet reported success",
362+
Name: "test-co",
351363
},
352364
}, {
353365
name: "cluster operator reporting available=true degraded=true",
@@ -373,10 +385,11 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
373385
},
374386
},
375387
expErr: &payload.UpdateError{
376-
Nested: fmt.Errorf("cluster operator test-co is reporting a failure: random error"),
377-
Reason: "ClusterOperatorDegraded",
378-
Message: "Cluster operator test-co is reporting a failure: random error",
379-
Name: "test-co",
388+
Nested: fmt.Errorf("cluster operator test-co is reporting a failure: random error"),
389+
Progressing: false,
390+
Reason: "ClusterOperatorDegraded",
391+
Message: "Cluster operator test-co is reporting a failure: random error",
392+
Name: "test-co",
380393
},
381394
}, {
382395
name: "cluster operator reporting available=true progressing=true degraded=true",
@@ -402,10 +415,11 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
402415
},
403416
},
404417
expErr: &payload.UpdateError{
405-
Nested: fmt.Errorf("cluster operator test-co is reporting a failure: random error"),
406-
Reason: "ClusterOperatorDegraded",
407-
Message: "Cluster operator test-co is reporting a failure: random error",
408-
Name: "test-co",
418+
Nested: fmt.Errorf("cluster operator test-co is reporting a failure: random error"),
419+
Progressing: false,
420+
Reason: "ClusterOperatorDegraded",
421+
Message: "Cluster operator test-co is reporting a failure: random error",
422+
Name: "test-co",
409423
},
410424
}, {
411425
name: "cluster operator reporting available=true no progressing or degraded",
@@ -431,10 +445,11 @@ func Test_waitForOperatorStatusToBeDone(t *testing.T) {
431445
},
432446
},
433447
expErr: &payload.UpdateError{
434-
Nested: fmt.Errorf("cluster operator test-co is not done; it is available=true, progressing=true, degraded=true"),
435-
Reason: "ClusterOperatorNotAvailable",
436-
Message: "Cluster operator test-co has not yet reported success",
437-
Name: "test-co",
448+
Nested: fmt.Errorf("cluster operator test-co is not done; it is available=true, progressing=true, degraded=true"),
449+
Progressing: true,
450+
Reason: "ClusterOperatorNotAvailable",
451+
Message: "Cluster operator test-co has not yet reported success",
452+
Name: "test-co",
438453
},
439454
}, {
440455
name: "cluster operator reporting available=true progressing=false degraded=false",

pkg/cvo/status.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,16 @@ func (optr *Operator) syncStatus(ctx context.Context, original, config *configv1
347347
// unavailable AND the general payload task making progress towards its goal. An operator is given 40 minutes since
348348
// its last update to go ready, or an hour has elapsed since the update began, before the condition is ignored.
349349
func convertErrorToProgressing(history []configv1.UpdateHistory, now time.Time, status *SyncWorkerStatus) (reason string, message string, ok bool) {
350+
uErr, ok := status.Failure.(*payload.UpdateError)
350351
if len(history) == 0 || status.Failure == nil || status.Reconciling || status.LastProgress.IsZero() {
352+
if ok && uErr.Progressing {
353+
return "", "", true
354+
}
351355
return "", "", false
352356
}
353357
if now.Sub(status.LastProgress) > 40*time.Minute || now.Sub(history[0].StartedTime.Time) > time.Hour {
354358
return "", "", false
355359
}
356-
uErr, ok := status.Failure.(*payload.UpdateError)
357360
if !ok {
358361
return "", "", false
359362
}

pkg/cvo/sync_worker.go

+9-7
Original file line numberDiff line numberDiff line change
@@ -940,10 +940,11 @@ func newClusterOperatorsNotAvailable(errs []error) error {
940940
sort.Strings(names)
941941
name := strings.Join(names, ", ")
942942
return &payload.UpdateError{
943-
Nested: errors.NewAggregate(errs),
944-
Reason: "ClusterOperatorsNotAvailable",
945-
Message: fmt.Sprintf("Some cluster operators are still updating: %s", name),
946-
Name: name,
943+
Nested: errors.NewAggregate(errs),
944+
Progressing: true,
945+
Reason: "ClusterOperatorsNotAvailable",
946+
Message: fmt.Sprintf("Some cluster operators are still updating: %s", name),
947+
Name: name,
947948
}
948949
}
949950

@@ -986,9 +987,10 @@ func newMultipleError(errs []error) error {
986987
return errs[0]
987988
}
988989
return &payload.UpdateError{
989-
Nested: errors.NewAggregate(errs),
990-
Reason: "MultipleErrors",
991-
Message: fmt.Sprintf("Multiple errors are preventing progress:\n* %s", strings.Join(messages, "\n* ")),
990+
Nested: errors.NewAggregate(errs),
991+
Progressing: true,
992+
Reason: "MultipleErrors",
993+
Message: fmt.Sprintf("Multiple errors are preventing progress:\n* %s", strings.Join(messages, "\n* ")),
992994
}
993995
}
994996

pkg/payload/task.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,11 @@ func (st *Task) Run(ctx context.Context, version string, builder ResourceBuilder
114114

115115
// UpdateError is a wrapper for errors that occur during a payload sync.
116116
type UpdateError struct {
117-
Nested error
118-
Reason string
119-
Message string
120-
Name string
117+
Nested error
118+
Progressing bool
119+
Reason string
120+
Message string
121+
Name string
121122

122123
Task *Task
123124
}

0 commit comments

Comments
 (0)