@@ -10,9 +10,9 @@ import (
10
10
"sync"
11
11
"time"
12
12
13
- "k8s.io/klog"
14
13
"github.com/prometheus/client_golang/prometheus"
15
14
"golang.org/x/time/rate"
15
+ "k8s.io/klog"
16
16
17
17
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
18
18
"k8s.io/apimachinery/pkg/util/errors"
@@ -751,12 +751,44 @@ func summarizeTaskGraphErrors(errs []error) error {
751
751
if len (errs ) == 1 {
752
752
return errs [0 ]
753
753
}
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
754
759
if err := newClusterOperatorsNotAvailable (errs ); err != nil {
755
760
return err
756
761
}
757
762
return newMultipleError (errs )
758
763
}
759
764
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
+
760
792
// newClusterOperatorsNotAvailable unifies multiple ClusterOperatorNotAvailable errors into
761
793
// a single error. It returns nil if the provided errors are not of the same type.
762
794
func newClusterOperatorsNotAvailable (errs []error ) error {
0 commit comments