Skip to content

Commit bdd4545

Browse files
status: Hide generic operator status in favor of more specific errors
When upgrading and a sync loop exits, we often see: * Operator A not upgraded yet * Operator B not upgraded yet * Operator C not upgraded yet * Some more specific error * Operator D not upgraded yet Since the not available messages carry little value and are expected when we are processing parallel output, if we have one or more errors during sync that are not the generic error, only report those. This focuses the user's attention on the actual problem, rather than distracting them with noise. In the ideal case, the user immediately sees "router is totally broken" vs "a, b, c, d, e, router is broken, f".
1 parent bf81bf0 commit bdd4545

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

pkg/cvo/sync_worker.go

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import (
1010
"sync"
1111
"time"
1212

13-
"k8s.io/klog"
1413
"github.com/prometheus/client_golang/prometheus"
1514
"golang.org/x/time/rate"
15+
"k8s.io/klog"
1616

1717
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1818
"k8s.io/apimachinery/pkg/util/errors"
@@ -751,12 +751,44 @@ func summarizeTaskGraphErrors(errs []error) error {
751751
if len(errs) == 1 {
752752
return errs[0]
753753
}
754+
// hide the generic "not available yet" when there are more specific errors present
755+
if filtered := filterErrors(errs, isClusterOperatorNotAvailable); len(filtered) > 0 {
756+
return newMultipleError(filtered)
757+
}
758+
// if we're only waiting for operators, condense the error down to a singleton
754759
if err := newClusterOperatorsNotAvailable(errs); err != nil {
755760
return err
756761
}
757762
return newMultipleError(errs)
758763
}
759764

765+
// filterErrors returns only the errors in errs which are false for all fns.
766+
func filterErrors(errs []error, fns ...func(err error) bool) []error {
767+
var filtered []error
768+
for _, err := range errs {
769+
if errorMatches(err, fns...) {
770+
continue
771+
}
772+
filtered = append(filtered, err)
773+
}
774+
return filtered
775+
}
776+
777+
func errorMatches(err error, fns ...func(err error) bool) bool {
778+
for _, fn := range fns {
779+
if fn(err) {
780+
return true
781+
}
782+
}
783+
return false
784+
}
785+
786+
// isClusterOperatorNotAvailable returns true if this is a ClusterOperatorNotAvailable error
787+
func isClusterOperatorNotAvailable(err error) bool {
788+
uErr, ok := err.(*payload.UpdateError)
789+
return ok && uErr != nil && uErr.Reason == "ClusterOperatorNotAvailable"
790+
}
791+
760792
// newClusterOperatorsNotAvailable unifies multiple ClusterOperatorNotAvailable errors into
761793
// a single error. It returns nil if the provided errors are not of the same type.
762794
func newClusterOperatorsNotAvailable(errs []error) error {

0 commit comments

Comments
 (0)