Merge pull request #114578 from ardaguclu/wrap-ctx-error-until

Embed context deadline exceeded in error to let errors.Is can work

Kubernetes-commit: b704b96565249fe451d9d023f7f743efc1cc90fe
This commit is contained in:
Kubernetes Publisher 2022-12-20 08:59:43 -08:00
commit bc218e478a
4 changed files with 7 additions and 6 deletions

4
go.mod
View File

@ -24,7 +24,7 @@ require (
golang.org/x/term v0.3.0
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8
google.golang.org/protobuf v1.28.1
k8s.io/api v0.0.0-20221219010528-ad1a499d6e1d
k8s.io/api v0.0.0-20221219201544-dadaafeebc9c
k8s.io/apimachinery v0.0.0-20221218214745-cc480d329650
k8s.io/klog/v2 v2.80.1
k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280
@ -59,6 +59,6 @@ require (
)
replace (
k8s.io/api => k8s.io/api v0.0.0-20221219010528-ad1a499d6e1d
k8s.io/api => k8s.io/api v0.0.0-20221219201544-dadaafeebc9c
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20221218214745-cc480d329650
)

4
go.sum
View File

@ -476,8 +476,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
k8s.io/api v0.0.0-20221219010528-ad1a499d6e1d h1:pLcGP0OWdNnJdcHC/z7Igu/otNTq0VmiYjhO350ZY78=
k8s.io/api v0.0.0-20221219010528-ad1a499d6e1d/go.mod h1:duiNr/01XR5q9e9KOuBRyaJ4Fo4tatH5EcaDCWcLhRI=
k8s.io/api v0.0.0-20221219201544-dadaafeebc9c h1:nLDoJEkmuSiiLkZq905pjb4g7+4/vVhYR4xpAvf2vDc=
k8s.io/api v0.0.0-20221219201544-dadaafeebc9c/go.mod h1:duiNr/01XR5q9e9KOuBRyaJ4Fo4tatH5EcaDCWcLhRI=
k8s.io/apimachinery v0.0.0-20221218214745-cc480d329650 h1:j8J1YsXNcg2kTBShe5PCLQxE2DWldFTNyk/Xa71GXjs=
k8s.io/apimachinery v0.0.0-20221218214745-cc480d329650/go.mod h1:tnPmbONNJ7ByJNz9+n9kMjNP8ON+1qoAIIC70lztu74=
k8s.io/klog/v2 v2.80.1 h1:atnLQ121W371wYYFawwYx1aEY2eUfs4l3J72wtgAwV4=

View File

@ -136,7 +136,7 @@ func UntilWithSync(ctx context.Context, lw cache.ListerWatcher, objType runtime.
if precondition != nil {
if !cache.WaitForCacheSync(ctx.Done(), informer.HasSynced) {
return nil, fmt.Errorf("UntilWithSync: unable to sync caches: %v", ctx.Err())
return nil, fmt.Errorf("UntilWithSync: unable to sync caches: %w", ctx.Err())
}
done, err := precondition(indexer)

View File

@ -19,6 +19,7 @@ package watch
import (
"context"
"errors"
"fmt"
"reflect"
"strings"
"testing"
@ -227,7 +228,7 @@ func TestUntilWithSync(t *testing.T) {
conditionFunc: func(e watch.Event) (bool, error) {
return true, nil
},
expectedErr: errors.New("UntilWithSync: unable to sync caches: context deadline exceeded"),
expectedErr: fmt.Errorf("UntilWithSync: unable to sync caches: %w", context.DeadlineExceeded),
expectedEvent: nil,
},
{