mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
Merge pull request #114578 from ardaguclu/wrap-ctx-error-until
Embed context deadline exceeded in error to let errors.Is can work
This commit is contained in:
commit
b704b96565
@ -136,7 +136,7 @@ func UntilWithSync(ctx context.Context, lw cache.ListerWatcher, objType runtime.
|
|||||||
|
|
||||||
if precondition != nil {
|
if precondition != nil {
|
||||||
if !cache.WaitForCacheSync(ctx.Done(), informer.HasSynced) {
|
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)
|
done, err := precondition(indexer)
|
||||||
|
@ -19,6 +19,7 @@ package watch
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -227,7 +228,7 @@ func TestUntilWithSync(t *testing.T) {
|
|||||||
conditionFunc: func(e watch.Event) (bool, error) {
|
conditionFunc: func(e watch.Event) (bool, error) {
|
||||||
return true, nil
|
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,
|
expectedEvent: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user