From fc25af7f5481df8e2b8ffd284a648e1cd65ea416 Mon Sep 17 00:00:00 2001 From: "wen.rui" Date: Mon, 4 Sep 2023 21:31:59 +0800 Subject: [PATCH] using wait.Interrupted instead of deprecated wait.ErrWaitTimeout for apps --- test/e2e/apps/daemon_set.go | 2 +- test/e2e/apps/deployment.go | 8 ++++---- test/e2e/apps/job.go | 3 ++- test/e2e/apps/rc.go | 11 ++++++----- test/e2e/apps/replica_set.go | 6 +++--- test/e2e/apps/statefulset.go | 4 ++-- test/e2e/apps/ttl_after_finished.go | 2 +- 7 files changed, 19 insertions(+), 17 deletions(-) diff --git a/test/e2e/apps/daemon_set.go b/test/e2e/apps/daemon_set.go index c7d139fc18d..2b5a897c512 100644 --- a/test/e2e/apps/daemon_set.go +++ b/test/e2e/apps/daemon_set.go @@ -105,7 +105,7 @@ func updateDaemonSetWithRetries(ctx context.Context, c clientset.Interface, name updateErr = err return false, nil }) - if pollErr == wait.ErrWaitTimeout { + if wait.Interrupted(pollErr) { pollErr = fmt.Errorf("couldn't apply the provided updated to DaemonSet %q: %v", name, updateErr) } return ds, pollErr diff --git a/test/e2e/apps/deployment.go b/test/e2e/apps/deployment.go index 1dc86de1673..bf38577a2de 100644 --- a/test/e2e/apps/deployment.go +++ b/test/e2e/apps/deployment.go @@ -1554,7 +1554,7 @@ func watchRecreateDeployment(ctx context.Context, c clientset.Interface, d *apps ctxUntil, cancel := context.WithTimeout(ctx, 2*time.Minute) defer cancel() _, err := watchtools.Until(ctxUntil, d.ResourceVersion, w, condition) - if err == wait.ErrWaitTimeout { + if wait.Interrupted(err) { err = fmt.Errorf("deployment %q never completed: %#v", d.Name, status) } return err @@ -1578,7 +1578,7 @@ func waitForDeploymentOldRSsNum(ctx context.Context, c clientset.Interface, ns, } return len(oldRSs) == desiredRSNum, nil }) - if pollErr == wait.ErrWaitTimeout { + if wait.Interrupted(pollErr) { pollErr = fmt.Errorf("%d old replica sets were not cleaned up for deployment %q", len(oldRSs)-desiredRSNum, deploymentName) testutil.LogReplicaSetsOfDeployment(d, oldRSs, nil, framework.Logf) } @@ -1595,7 +1595,7 @@ func waitForReplicaSetDesiredReplicas(ctx context.Context, rsClient appsclient.R } return rs.Status.ObservedGeneration >= desiredGeneration && rs.Status.Replicas == *(replicaSet.Spec.Replicas) && rs.Status.Replicas == *(rs.Spec.Replicas), nil }) - if err == wait.ErrWaitTimeout { + if wait.Interrupted(err) { err = fmt.Errorf("replicaset %q never had desired number of replicas", replicaSet.Name) } return err @@ -1611,7 +1611,7 @@ func waitForReplicaSetTargetSpecReplicas(ctx context.Context, c clientset.Interf } return rs.Status.ObservedGeneration >= desiredGeneration && *rs.Spec.Replicas == targetReplicaNum, nil }) - if err == wait.ErrWaitTimeout { + if wait.Interrupted(err) { err = fmt.Errorf("replicaset %q never had desired number of .spec.replicas", replicaSet.Name) } return err diff --git a/test/e2e/apps/job.go b/test/e2e/apps/job.go index a35d10e0900..88b15c6efa4 100644 --- a/test/e2e/apps/job.go +++ b/test/e2e/apps/job.go @@ -19,6 +19,7 @@ package apps import ( "context" "encoding/json" + "errors" "fmt" "strconv" "time" @@ -286,7 +287,7 @@ var _ = SIGDescribe("Job", func() { return false, err } return len(pods.Items) > 0, nil - }), wait.ErrWaitTimeout) + }), wait.ErrorInterrupted(errors.New("timed out waiting for the condition"))) ginkgo.By("Checking Job status to observe Suspended state") job, err = e2ejob.GetJob(ctx, f.ClientSet, f.Namespace.Name, job.Name) diff --git a/test/e2e/apps/rc.go b/test/e2e/apps/rc.go index d20e6d709c7..5939c34c5f4 100644 --- a/test/e2e/apps/rc.go +++ b/test/e2e/apps/rc.go @@ -19,6 +19,7 @@ package apps import ( "context" "encoding/json" + "errors" "fmt" "time" @@ -554,7 +555,7 @@ func testReplicationControllerConditionCheck(ctx context.Context, f *framework.F quantity := resource.MustParse("2") return (&podQuota).Cmp(quantity) == 0, nil }) - if err == wait.ErrWaitTimeout { + if wait.Interrupted(err) { err = fmt.Errorf("resource quota %q never synced", name) } framework.ExpectNoError(err) @@ -581,7 +582,7 @@ func testReplicationControllerConditionCheck(ctx context.Context, f *framework.F cond := replication.GetCondition(rc.Status, v1.ReplicationControllerReplicaFailure) return cond != nil, nil }) - if err == wait.ErrWaitTimeout { + if wait.Interrupted(err) { err = fmt.Errorf("rc manager never added the failure condition for rc %q: %#v", name, conditions) } framework.ExpectNoError(err) @@ -610,7 +611,7 @@ func testReplicationControllerConditionCheck(ctx context.Context, f *framework.F cond := replication.GetCondition(rc.Status, v1.ReplicationControllerReplicaFailure) return cond == nil, nil }) - if err == wait.ErrWaitTimeout { + if wait.Interrupted(err) { err = fmt.Errorf("rc manager never removed the failure condition for rc %q: %#v", name, conditions) } framework.ExpectNoError(err) @@ -732,7 +733,7 @@ func updateReplicationControllerWithRetries(ctx context.Context, c clientset.Int updateErr = err return false, nil }) - if pollErr == wait.ErrWaitTimeout { + if wait.Interrupted(pollErr) { pollErr = fmt.Errorf("couldn't apply the provided updated to rc %q: %v", name, updateErr) } return rc, pollErr @@ -778,7 +779,7 @@ func watchUntilWithoutRetry(ctx context.Context, watcher watch.Interface, condit } case <-ctx.Done(): - return lastEvent, wait.ErrWaitTimeout + return lastEvent, wait.ErrorInterrupted(errors.New("timed out waiting for the condition")) } } } diff --git a/test/e2e/apps/replica_set.go b/test/e2e/apps/replica_set.go index 007f048681b..e72f40a1b70 100644 --- a/test/e2e/apps/replica_set.go +++ b/test/e2e/apps/replica_set.go @@ -251,7 +251,7 @@ func testReplicaSetConditionCheck(ctx context.Context, f *framework.Framework) { podQuota := quota.Status.Hard[v1.ResourcePods] return (&podQuota).Cmp(quantity) == 0, nil }) - if err == wait.ErrWaitTimeout { + if wait.Interrupted(err) { err = fmt.Errorf("resource quota %q never synced", name) } framework.ExpectNoError(err) @@ -279,7 +279,7 @@ func testReplicaSetConditionCheck(ctx context.Context, f *framework.Framework) { return cond != nil, nil }) - if err == wait.ErrWaitTimeout { + if wait.Interrupted(err) { err = fmt.Errorf("rs controller never added the failure condition for replica set %q: %#v", name, conditions) } framework.ExpectNoError(err) @@ -308,7 +308,7 @@ func testReplicaSetConditionCheck(ctx context.Context, f *framework.Framework) { cond := replicaset.GetCondition(rs.Status, appsv1.ReplicaSetReplicaFailure) return cond == nil, nil }) - if err == wait.ErrWaitTimeout { + if wait.Interrupted(err) { err = fmt.Errorf("rs controller never removed the failure condition for rs %q: %#v", name, conditions) } framework.ExpectNoError(err) diff --git a/test/e2e/apps/statefulset.go b/test/e2e/apps/statefulset.go index dc7b4e87176..a837e4fb1a9 100644 --- a/test/e2e/apps/statefulset.go +++ b/test/e2e/apps/statefulset.go @@ -1836,7 +1836,7 @@ func pollReadWithTimeout(ctx context.Context, statefulPod statefulPodTester, sta return true, nil }) - if err == wait.ErrWaitTimeout { + if wait.Interrupted(err) { return fmt.Errorf("timed out when trying to read value for key %v from stateful pod %d", key, statefulPodNumber) } return err @@ -2058,7 +2058,7 @@ func updateStatefulSetWithRetries(ctx context.Context, c clientset.Interface, na updateErr = err return false, nil }) - if pollErr == wait.ErrWaitTimeout { + if wait.Interrupted(pollErr) { pollErr = fmt.Errorf("couldn't apply the provided updated to stateful set %q: %v", name, updateErr) } return statefulSet, pollErr diff --git a/test/e2e/apps/ttl_after_finished.go b/test/e2e/apps/ttl_after_finished.go index 864f6a1e9fa..0df43338f4f 100644 --- a/test/e2e/apps/ttl_after_finished.go +++ b/test/e2e/apps/ttl_after_finished.go @@ -138,7 +138,7 @@ func updateJobWithRetries(ctx context.Context, c clientset.Interface, namespace, updateErr = err return false, nil }) - if pollErr == wait.ErrWaitTimeout { + if wait.Interrupted(pollErr) { pollErr = fmt.Errorf("couldn't apply the provided updated to job %q: %v", name, updateErr) } return job, pollErr