From 753cfe181182b24de86d2178532d1767e9d50d66 Mon Sep 17 00:00:00 2001 From: Mayuka Channankaiah <57181320+mayuka-c@users.noreply.github.com> Date: Thu, 24 Jul 2025 20:26:27 +0530 Subject: [PATCH] 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 Kubernetes-commit: ffe306d67958297202e9492ea644b42c0e7e694d --- tools/watch/retrywatcher_test.go | 2 +- tools/watch/until.go | 2 +- tools/watch/until_test.go | 4 ++-- util/certificate/csr/csr.go | 8 ++++---- util/retry/util.go | 2 +- util/workqueue/delaying_queue_test.go | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/tools/watch/retrywatcher_test.go b/tools/watch/retrywatcher_test.go index 307b8da3..b831cace 100644 --- a/tools/watch/retrywatcher_test.go +++ b/tools/watch/retrywatcher_test.go @@ -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) diff --git a/tools/watch/until.go b/tools/watch/until.go index 03ceaf00..7a9b34a8 100644 --- a/tools/watch/until.go +++ b/tools/watch/until.go @@ -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) } } } diff --git a/tools/watch/until_test.go b/tools/watch/until_test.go index a9367a81..d2194fbd 100644 --- a/tools/watch/until_test.go +++ b/tools/watch/until_test.go @@ -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, }, { diff --git a/util/certificate/csr/csr.go b/util/certificate/csr/csr.go index 2b4dd423..1cd996c0 100644 --- a/util/certificate/csr/csr.go +++ b/util/certificate/csr/csr.go @@ -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) diff --git a/util/retry/util.go b/util/retry/util.go index 0c6e504a..57d3cd49 100644 --- a/util/retry/util.go +++ b/util/retry/util.go @@ -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 diff --git a/util/workqueue/delaying_queue_test.go b/util/workqueue/delaying_queue_test.go index 3c50709b..491040b2 100644 --- a/util/workqueue/delaying_queue_test.go +++ b/util/workqueue/delaying_queue_test.go @@ -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) }