mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-02-22 15:19:12 +00:00
client-go, kubectl: Replace deprecated ErrWaitTimeout with recommended method (#132718)
* client-go: Replace depracted ErrWaitTimeout with recommended method * Fix UT and Integration tests * IT test
This commit is contained in:
committed by
GitHub
parent
cb33accc8f
commit
ffe306d679
@@ -595,7 +595,7 @@ func TestRetryWatcher(t *testing.T) {
|
||||
counter = atomic.LoadUint32(atomicCounter)
|
||||
return counter == tc.watchCount, nil
|
||||
})
|
||||
if err == wait.ErrWaitTimeout {
|
||||
if wait.Interrupted(err) {
|
||||
t.Errorf("expected %d watcher starts, but it has started %d times", tc.watchCount, counter)
|
||||
} else if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
@@ -86,7 +86,7 @@ func UntilWithoutRetry(ctx context.Context, watcher watch.Interface, conditions
|
||||
}
|
||||
|
||||
case <-ctx.Done():
|
||||
return lastEvent, wait.ErrWaitTimeout
|
||||
return lastEvent, wait.ErrorInterrupted(nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ func TestUntilMultipleConditionsFail(t *testing.T) {
|
||||
defer cancel()
|
||||
|
||||
lastEvent, err := UntilWithoutRetry(ctx, fw, conditions...)
|
||||
if err != wait.ErrWaitTimeout {
|
||||
if !wait.Interrupted(err) {
|
||||
t.Fatalf("expected ErrWaitTimeout error, got %#v", err)
|
||||
}
|
||||
if lastEvent == nil {
|
||||
@@ -209,7 +209,7 @@ func TestUntilWithSync(t *testing.T) {
|
||||
conditionFunc: func(e watch.Event) (bool, error) {
|
||||
return true, nil
|
||||
},
|
||||
expectedErr: wait.ErrWaitTimeout,
|
||||
expectedErr: wait.ErrorInterrupted(nil),
|
||||
expectedEvent: nil,
|
||||
},
|
||||
{
|
||||
|
||||
@@ -202,7 +202,7 @@ func WaitForCertificate(ctx context.Context, client clientset.Interface, reqName
|
||||
|
||||
// return if we've timed out
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, wait.ErrWaitTimeout
|
||||
return nil, wait.ErrorInterrupted(nil)
|
||||
}
|
||||
|
||||
// see if the v1beta1 API is available
|
||||
@@ -226,7 +226,7 @@ func WaitForCertificate(ctx context.Context, client clientset.Interface, reqName
|
||||
|
||||
// return if we've timed out
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, wait.ErrWaitTimeout
|
||||
return nil, wait.ErrorInterrupted(nil)
|
||||
}
|
||||
|
||||
// wait and try again
|
||||
@@ -306,8 +306,8 @@ func WaitForCertificate(ctx context.Context, client clientset.Interface, reqName
|
||||
return false, nil
|
||||
},
|
||||
)
|
||||
if err == wait.ErrWaitTimeout {
|
||||
return nil, wait.ErrWaitTimeout
|
||||
if wait.Interrupted(err) {
|
||||
return nil, wait.ErrorInterrupted(nil)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, formatError("cannot watch on the certificate signing request: %v", err)
|
||||
|
||||
@@ -59,7 +59,7 @@ func OnError(backoff wait.Backoff, retriable func(error) bool, fn func() error)
|
||||
return false, err
|
||||
}
|
||||
})
|
||||
if err == wait.ErrWaitTimeout {
|
||||
if wait.Interrupted(err) {
|
||||
err = lastErr
|
||||
}
|
||||
return err
|
||||
|
||||
@@ -60,7 +60,7 @@ func TestSimpleQueue(t *testing.T) {
|
||||
|
||||
return false, nil
|
||||
})
|
||||
if err != wait.ErrWaitTimeout {
|
||||
if !wait.Interrupted(err) {
|
||||
t.Errorf("expected timeout, got: %v", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ func getObjAndCheckCondition(ctx context.Context, info *resource.Info, o *WaitOp
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
if errors.Is(err, wait.ErrWaitTimeout) { // nolint:staticcheck // SA1019
|
||||
if wait.Interrupted(err) { // nolint:staticcheck // SA1019
|
||||
return result, false, errWaitTimeoutWithName
|
||||
}
|
||||
return result, false, err
|
||||
|
||||
@@ -113,7 +113,7 @@ func IsDeleted(ctx context.Context, info *resource.Info, o *WaitOptions) (runtim
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
if errors.Is(err, wait.ErrWaitTimeout) { // nolint:staticcheck // SA1019
|
||||
if wait.Interrupted(err) { // nolint:staticcheck // SA1019
|
||||
return gottenObj, false, errWaitTimeoutWithName
|
||||
}
|
||||
return gottenObj, false, err
|
||||
|
||||
@@ -259,7 +259,7 @@ func TestWatchRestartsIfTimeoutNotReached(t *testing.T) {
|
||||
t.Fatalf("Watch should have timed out but it exited without an error!")
|
||||
}
|
||||
|
||||
if err != wait.ErrWaitTimeout && tc.succeed {
|
||||
if !wait.Interrupted(err) && tc.succeed {
|
||||
t.Fatalf("Watch exited with error: %v!", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ import (
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
@@ -608,7 +607,7 @@ func (is *informerSpy) waitForEvents(t *testing.T, wantEvents bool) {
|
||||
t.Fatalf("wanted events, but got error: %v", err)
|
||||
}
|
||||
} else {
|
||||
if !errors.Is(err, wait.ErrWaitTimeout) {
|
||||
if !wait.Interrupted(err) {
|
||||
if err != nil {
|
||||
t.Fatalf("wanted no events, but got error: %v", err)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user