@@ -293,8 +293,37 @@ func updateClusterVersionStatus(cvStatus *configv1.ClusterVersionStatus, status
293
293
})
294
294
}
295
295
296
- progressReason , progressMessage , skipFailure := convertErrorToProgressing (cvStatus .History , now .Time , status )
296
+ failure := status .Failure
297
+ failingReason , failingMessage := getReasonMessageFromError (failure )
298
+ var skipFailure bool
299
+ var progressReason , progressMessage string
300
+ if ! status .Reconciling && len (cvStatus .History ) != 0 {
301
+ progressReason , progressMessage , skipFailure = convertErrorToProgressing (now .Time , failure )
302
+ failure = filterErrorForFailingCondition (failure , payload .UpdateEffectNone )
303
+ filteredFailingReason , filteredFailingMessage := getReasonMessageFromError (failure )
304
+ if failingReason != filteredFailingReason {
305
+ klog .Infof ("Filtered failure reason changed from '%s' to '%s'" , failingReason , filteredFailingReason )
306
+ }
307
+ if failingMessage != filteredFailingMessage {
308
+ klog .Infof ("Filtered failure message changed from '%s' to '%s'" , failingMessage , filteredFailingMessage )
309
+ }
310
+ failingReason , failingMessage = filteredFailingReason , filteredFailingMessage
311
+ }
312
+
313
+ // set the failing condition
314
+ failingCondition := configv1.ClusterOperatorStatusCondition {
315
+ Type : ClusterStatusFailing ,
316
+ Status : configv1 .ConditionFalse ,
317
+ LastTransitionTime : now ,
318
+ }
319
+ if failure != nil && ! skipFailure {
320
+ failingCondition .Status = configv1 .ConditionTrue
321
+ failingCondition .Reason = failingReason
322
+ failingCondition .Message = failingMessage
323
+ }
324
+ resourcemerge .SetOperatorStatusCondition (& cvStatus .Conditions , failingCondition )
297
325
326
+ // update progressing
298
327
if err := status .Failure ; err != nil && ! skipFailure {
299
328
var reason string
300
329
msg := progressMessage
@@ -307,16 +336,6 @@ func updateClusterVersionStatus(cvStatus *configv1.ClusterVersionStatus, status
307
336
msg = "an error occurred"
308
337
}
309
338
310
- // set the failing condition
311
- resourcemerge .SetOperatorStatusCondition (& cvStatus .Conditions , configv1.ClusterOperatorStatusCondition {
312
- Type : ClusterStatusFailing ,
313
- Status : configv1 .ConditionTrue ,
314
- Reason : reason ,
315
- Message : err .Error (),
316
- LastTransitionTime : now ,
317
- })
318
-
319
- // update progressing
320
339
if status .Reconciling {
321
340
resourcemerge .SetOperatorStatusCondition (& cvStatus .Conditions , configv1.ClusterOperatorStatusCondition {
322
341
Type : configv1 .OperatorProgressing ,
@@ -336,9 +355,6 @@ func updateClusterVersionStatus(cvStatus *configv1.ClusterVersionStatus, status
336
355
}
337
356
338
357
} else {
339
- // clear the failure condition
340
- resourcemerge .SetOperatorStatusCondition (& cvStatus .Conditions , configv1.ClusterOperatorStatusCondition {Type : ClusterStatusFailing , Status : configv1 .ConditionFalse , LastTransitionTime : now })
341
-
342
358
// update progressing
343
359
if status .Reconciling {
344
360
message := fmt .Sprintf ("Cluster version is %s" , version )
@@ -413,6 +429,48 @@ func updateClusterVersionStatus(cvStatus *configv1.ClusterVersionStatus, status
413
429
}
414
430
}
415
431
432
+ // getReasonMessageFromError returns the reason and the message from an error.
433
+ // If the reason or message is not available, an empty string is returned.
434
+ func getReasonMessageFromError (err error ) (reason , message string ) {
435
+ if uErr , ok := err .(* payload.UpdateError ); ok {
436
+ reason = uErr .Reason
437
+ }
438
+ if err != nil {
439
+ message = err .Error ()
440
+ }
441
+ return reason , message
442
+ }
443
+
444
+ // filterErrorForFailingCondition filters out update errors based on the given
445
+ // updateEffect from a MultipleError error. If the err has the reason
446
+ // MultipleErrors, its immediate nested errors are filtered out and the error
447
+ // is recreated. If all nested errors are filtered out, nil is returned.
448
+ func filterErrorForFailingCondition (err error , updateEffect payload.UpdateEffectType ) error {
449
+ if err == nil {
450
+ return nil
451
+ }
452
+ if uErr , ok := err .(* payload.UpdateError ); ok && uErr .Reason == "MultipleErrors" {
453
+ if nested , ok := uErr .Nested .(interface { Errors () []error }); ok {
454
+ filtered := nested .Errors ()
455
+ filtered = filterOutUpdateErrors (filtered , updateEffect )
456
+ return newMultipleError (filtered )
457
+ }
458
+ }
459
+ return err
460
+ }
461
+
462
+ // filterOutUpdateErrors filters out update errors of the given effect.
463
+ func filterOutUpdateErrors (errs []error , updateEffect payload.UpdateEffectType ) []error {
464
+ filtered := make ([]error , 0 , len (errs ))
465
+ for _ , err := range errs {
466
+ if uErr , ok := err .(* payload.UpdateError ); ok && uErr .UpdateEffect == updateEffect {
467
+ continue
468
+ }
469
+ filtered = append (filtered , err )
470
+ }
471
+ return filtered
472
+ }
473
+
416
474
func setImplicitlyEnabledCapabilitiesCondition (cvStatus * configv1.ClusterVersionStatus , implicitlyEnabled []configv1.ClusterVersionCapability ,
417
475
now metav1.Time ) {
418
476
@@ -479,11 +537,11 @@ func setDesiredReleaseAcceptedCondition(cvStatus *configv1.ClusterVersionStatus,
479
537
// how an update error is interpreted. An error may simply need to be reported but does not indicate the update is
480
538
// failing. An error may indicate the update is failing or that if the error continues for a defined interval the
481
539
// update is failing.
482
- func convertErrorToProgressing (history []configv1. UpdateHistory , now time.Time , status * SyncWorkerStatus ) (reason string , message string , ok bool ) {
483
- if len ( history ) == 0 || status . Failure == nil || status . Reconciling {
540
+ func convertErrorToProgressing (now time.Time , statusFailure error ) (reason string , message string , ok bool ) {
541
+ if statusFailure == nil {
484
542
return "" , "" , false
485
543
}
486
- uErr , ok := status . Failure .(* payload.UpdateError )
544
+ uErr , ok := statusFailure .(* payload.UpdateError )
487
545
if ! ok {
488
546
return "" , "" , false
489
547
}
0 commit comments