From 5524f1651a24285830a81c5d1a4776cc4622f28d Mon Sep 17 00:00:00 2001 From: SataQiu Date: Thu, 24 Aug 2023 18:35:59 +0800 Subject: [PATCH] using wait.PollUntilContextTimeout instead of deprecated wait.Poll/PollWithContext/PollImmediate/PollImmediateWithContext methods for scheduler --- cmd/kube-scheduler/app/testing/testserver.go | 4 ++-- test/e2e/scheduling/events.go | 2 +- test/e2e/scheduling/limit_range.go | 2 +- test/e2e/scheduling/priorities.go | 2 +- test/integration/scheduler_perf/scheduler_perf_test.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/kube-scheduler/app/testing/testserver.go b/cmd/kube-scheduler/app/testing/testserver.go index c6f3b5ef5ff..857b3097db2 100644 --- a/cmd/kube-scheduler/app/testing/testserver.go +++ b/cmd/kube-scheduler/app/testing/testserver.go @@ -132,14 +132,14 @@ func StartTestServer(ctx context.Context, customFlags []string) (result TestServ if err != nil { return result, fmt.Errorf("failed to create a client: %v", err) } - err = wait.Poll(100*time.Millisecond, 30*time.Second, func() (bool, error) { + err = wait.PollUntilContextTimeout(ctx, 100*time.Millisecond, 30*time.Second, false, func(ctx context.Context) (bool, error) { select { case err := <-errCh: return false, err default: } - result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do(context.TODO()) + result := client.CoreV1().RESTClient().Get().AbsPath("/healthz").Do(ctx) status := 0 result.StatusCode(&status) if status == 200 { diff --git a/test/e2e/scheduling/events.go b/test/e2e/scheduling/events.go index a6df5ea0750..7f7cdb096d4 100644 --- a/test/e2e/scheduling/events.go +++ b/test/e2e/scheduling/events.go @@ -109,7 +109,7 @@ func observeEventAfterAction(ctx context.Context, c clientset.Interface, ns stri // Wait up 2 minutes polling every second. timeout := 2 * time.Minute interval := 1 * time.Second - err = wait.PollWithContext(ctx, interval, timeout, func(ctx context.Context) (bool, error) { + err = wait.PollUntilContextTimeout(ctx, interval, timeout, false, func(ctx context.Context) (bool, error) { return observedMatchingEvent, nil }) return err == nil, err diff --git a/test/e2e/scheduling/limit_range.go b/test/e2e/scheduling/limit_range.go index 946c9a757d0..8f180ca0734 100644 --- a/test/e2e/scheduling/limit_range.go +++ b/test/e2e/scheduling/limit_range.go @@ -326,7 +326,7 @@ var _ = SIGDescribe("LimitRange", func() { framework.ExpectNoError(err, "failed to delete the LimitRange by Collection") ginkgo.By(fmt.Sprintf("Confirm that the limitRange %q has been deleted", lrName)) - err = wait.PollImmediateWithContext(ctx, 1*time.Second, 10*time.Second, checkLimitRangeListQuantity(f, patchedLabelSelector, 0)) + err = wait.PollUntilContextTimeout(ctx, 1*time.Second, 10*time.Second, true, checkLimitRangeListQuantity(f, patchedLabelSelector, 0)) framework.ExpectNoError(err, "failed to count the required limitRanges") framework.Logf("LimitRange %q has been deleted.", lrName) diff --git a/test/e2e/scheduling/priorities.go b/test/e2e/scheduling/priorities.go index dd86a4c49f1..97c41bd0572 100644 --- a/test/e2e/scheduling/priorities.go +++ b/test/e2e/scheduling/priorities.go @@ -364,7 +364,7 @@ func createBalancedPodForNodes(ctx context.Context, f *framework.Framework, cs c if err != nil { framework.Logf("Failed to delete memory balanced pods: %v.", err) } else { - err := wait.PollImmediateWithContext(ctx, 2*time.Second, time.Minute, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, 2*time.Second, time.Minute, true, func(ctx context.Context) (bool, error) { podList, err := cs.CoreV1().Pods(ns).List(ctx, metav1.ListOptions{ LabelSelector: labels.SelectorFromSet(labels.Set(balancePodLabel)).String(), }) diff --git a/test/integration/scheduler_perf/scheduler_perf_test.go b/test/integration/scheduler_perf/scheduler_perf_test.go index 84aae101443..58b671b9c63 100644 --- a/test/integration/scheduler_perf/scheduler_perf_test.go +++ b/test/integration/scheduler_perf/scheduler_perf_test.go @@ -1312,7 +1312,7 @@ func createPods(ctx context.Context, tb testing.TB, namespace string, cpo *creat // namespace are scheduled. Times out after 10 minutes because even at the // lowest observed QPS of ~10 pods/sec, a 5000-node test should complete. func waitUntilPodsScheduledInNamespace(ctx context.Context, tb testing.TB, podInformer coreinformers.PodInformer, namespace string, wantCount int) error { - return wait.PollImmediate(1*time.Second, 10*time.Minute, func() (bool, error) { + return wait.PollUntilContextTimeout(ctx, 1*time.Second, 10*time.Minute, true, func(ctx context.Context) (bool, error) { select { case <-ctx.Done(): return true, ctx.Err()