From ef235c4eac82f81c8928042c07dbe02cfa80711b Mon Sep 17 00:00:00 2001 From: wlq1212 Date: Mon, 4 Sep 2023 21:42:10 +0800 Subject: [PATCH] e2e_framework:stop using deprecated wait.ErrwaitTimeout --- test/e2e/common/node/node_lease.go | 5 +++-- test/e2e/framework/autoscaling/autoscaling_utils.go | 2 +- test/e2e/framework/node/helper.go | 2 +- test/e2e/framework/node/wait.go | 2 +- test/e2e/framework/replicaset/wait.go | 4 ++-- test/e2e/framework/resource/resources.go | 4 ++-- test/e2e/framework/service/util.go | 2 +- test/e2e/lifecycle/bootstrap/util.go | 2 +- test/e2e/network/service.go | 2 +- 9 files changed, 13 insertions(+), 12 deletions(-) diff --git a/test/e2e/common/node/node_lease.go b/test/e2e/common/node/node_lease.go index d320a90deb0..e1a671d9581 100644 --- a/test/e2e/common/node/node_lease.go +++ b/test/e2e/common/node/node_lease.go @@ -27,10 +27,11 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" clientset "k8s.io/client-go/kubernetes" + admissionapi "k8s.io/pod-security-admission/api" + "k8s.io/kubernetes/test/e2e/framework" e2enode "k8s.io/kubernetes/test/e2e/framework/node" testutils "k8s.io/kubernetes/test/utils" - admissionapi "k8s.io/pod-security-admission/api" "github.com/google/go-cmp/cmp" "github.com/onsi/ginkgo/v2" @@ -170,7 +171,7 @@ var _ = SIGDescribe("NodeLease", func() { return false, fmt.Errorf("node status heartbeat changed in %s (with no other status changes), was waiting for %s", currentHeartbeatTime.Sub(lastHeartbeatTime), leaseDuration) }) // a timeout is acceptable, since it means we waited 5 minutes and didn't see any unwarranted node status updates - if err != nil && err != wait.ErrWaitTimeout { + if !wait.Interrupted(err) { framework.ExpectNoError(err, "error waiting for infrequent nodestatus update") } diff --git a/test/e2e/framework/autoscaling/autoscaling_utils.go b/test/e2e/framework/autoscaling/autoscaling_utils.go index d52ce3bb07e..886acb25c92 100644 --- a/test/e2e/framework/autoscaling/autoscaling_utils.go +++ b/test/e2e/framework/autoscaling/autoscaling_utils.go @@ -524,7 +524,7 @@ func (rc *ResourceConsumer) EnsureDesiredReplicasInRange(ctx context.Context, mi } }) // The call above always returns an error, but if it is timeout, it's OK (condition satisfied all the time). - if err == wait.ErrWaitTimeout { + if wait.Interrupted(err) { framework.Logf("Number of replicas was stable over %v", duration) return } diff --git a/test/e2e/framework/node/helper.go b/test/e2e/framework/node/helper.go index 90a9dbb59a2..301d2cd7853 100644 --- a/test/e2e/framework/node/helper.go +++ b/test/e2e/framework/node/helper.go @@ -141,7 +141,7 @@ func allNodesReady(ctx context.Context, c clientset.Interface, timeout time.Dura return len(notReady) <= framework.TestContext.AllowedNotReadyNodes, nil }) - if err != nil && err != wait.ErrWaitTimeout { + if err != nil && !wait.Interrupted(err) { return err } diff --git a/test/e2e/framework/node/wait.go b/test/e2e/framework/node/wait.go index cc0294230df..91aaec4efe4 100644 --- a/test/e2e/framework/node/wait.go +++ b/test/e2e/framework/node/wait.go @@ -96,7 +96,7 @@ func WaitForTotalHealthy(ctx context.Context, c clientset.Interface, timeout tim return len(notReady) == 0 && len(missingPodsPerNode) == 0, nil }) - if err != nil && err != wait.ErrWaitTimeout { + if err != nil && !wait.Interrupted(err) { return err } diff --git a/test/e2e/framework/replicaset/wait.go b/test/e2e/framework/replicaset/wait.go index 6cbb879ad0c..49719c27f37 100644 --- a/test/e2e/framework/replicaset/wait.go +++ b/test/e2e/framework/replicaset/wait.go @@ -37,7 +37,7 @@ func WaitForReadyReplicaSet(ctx context.Context, c clientset.Interface, ns, name } return *(rs.Spec.Replicas) == rs.Status.Replicas && *(rs.Spec.Replicas) == rs.Status.ReadyReplicas, nil }) - if err == wait.ErrWaitTimeout { + if wait.Interrupted(err) { err = fmt.Errorf("replicaset %q never became ready", name) } return err @@ -59,7 +59,7 @@ func WaitForReplicaSetTargetAvailableReplicasWithTimeout(ctx context.Context, c } return rs.Status.ObservedGeneration >= desiredGeneration && rs.Status.AvailableReplicas == targetReplicaNum, nil }) - if err == wait.ErrWaitTimeout { + if wait.Interrupted(err) { err = fmt.Errorf("replicaset %q never had desired number of .status.availableReplicas", replicaSet.Name) } return err diff --git a/test/e2e/framework/resource/resources.go b/test/e2e/framework/resource/resources.go index 3e17ddcb4a4..9957aec2785 100644 --- a/test/e2e/framework/resource/resources.go +++ b/test/e2e/framework/resource/resources.go @@ -182,7 +182,7 @@ func waitForPodsGone(ctx context.Context, ps *testutils.PodStore, interval, time return false, nil }) - if err == wait.ErrWaitTimeout { + if wait.Interrupted(err) { for _, pod := range pods { framework.Logf("ERROR: Pod %q still exists. Node: %q", pod.Name, pod.Spec.NodeName) } @@ -206,7 +206,7 @@ func waitForPodsInactive(ctx context.Context, ps *testutils.PodStore, interval, return true, nil }) - if err == wait.ErrWaitTimeout { + if wait.Interrupted(err) { for _, pod := range activePods { framework.Logf("ERROR: Pod %q running on %q is still active", pod.Name, pod.Spec.NodeName) } diff --git a/test/e2e/framework/service/util.go b/test/e2e/framework/service/util.go index 5b809acd075..72007ad5908 100644 --- a/test/e2e/framework/service/util.go +++ b/test/e2e/framework/service/util.go @@ -45,7 +45,7 @@ func TestReachableHTTPWithRetriableErrorCodes(ctx context.Context, host string, } if err := wait.PollImmediateWithContext(ctx, framework.Poll, timeout, pollfn); err != nil { - if err == wait.ErrWaitTimeout { + if wait.Interrupted(err) { framework.Failf("Could not reach HTTP service through %v:%v after %v", host, port, timeout) } else { framework.Failf("Failed to reach HTTP service through %v:%v: %v", host, port, err) diff --git a/test/e2e/lifecycle/bootstrap/util.go b/test/e2e/lifecycle/bootstrap/util.go index 1d8d84b02e9..af3770f043f 100644 --- a/test/e2e/lifecycle/bootstrap/util.go +++ b/test/e2e/lifecycle/bootstrap/util.go @@ -159,7 +159,7 @@ func WaitForBootstrapTokenSecretNotDisappear(c clientset.Interface, tokenID stri } return true, err }) - if err == wait.ErrWaitTimeout { + if wait.Interrupted(err) { return nil } return err diff --git a/test/e2e/network/service.go b/test/e2e/network/service.go index 2cd64c3f893..e77f44880bd 100644 --- a/test/e2e/network/service.go +++ b/test/e2e/network/service.go @@ -210,7 +210,7 @@ func checkAffinity(ctx context.Context, cs clientset.Interface, execPod *v1.Pod, return false, nil }); pollErr != nil { trackerFulfilled, _ := tracker.checkHostTrace(AffinityConfirmCount) - if pollErr != wait.ErrWaitTimeout { + if !wait.Interrupted(pollErr) { checkAffinityFailed(tracker, pollErr.Error()) return false }