Skip to content

Commit 6809180

Browse files
authored
Merge pull request kubernetes#124785 from kerthcet/cleanup/deprecate-wait-pull
Avoid to use deprecated wait.Poll in scheduler tests
2 parents 5732a8b + f5b6f79 commit 6809180

File tree

9 files changed

+52
-57
lines changed

9 files changed

+52
-57
lines changed

test/integration/node/lifecycle_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ func TestTaintBasedEvictions(t *testing.T) {
436436
}
437437
}
438438

439-
if err := testutils.WaitForNodeTaints(cs, nodes[nodeIndex], test.nodeTaints); err != nil {
439+
if err := testutils.WaitForNodeTaints(testCtx.Ctx, cs, nodes[nodeIndex], test.nodeTaints); err != nil {
440440
t.Errorf("Failed to taint node %q, err: %v", klog.KObj(nodes[nodeIndex]), err)
441441
}
442442

test/integration/scheduler/eventhandler/eventhandler_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ func TestUpdateNodeEvent(t *testing.T) {
114114
t.Fatalf("Creating pod error: %v", err)
115115
}
116116

117-
if err := testutils.WaitForPodUnschedulable(testCtx.ClientSet, pod); err != nil {
117+
if err := testutils.WaitForPodUnschedulable(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
118118
t.Fatalf("Pod %v got scheduled: %v", pod.Name, err)
119119
}
120120
node, err = testCtx.ClientSet.CoreV1().Nodes().Get(testCtx.Ctx, node.Name, metav1.GetOptions{})

test/integration/scheduler/filters/filters_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2158,7 +2158,7 @@ func TestUnschedulablePodBecomesSchedulable(t *testing.T) {
21582158
if err != nil {
21592159
t.Fatal(err)
21602160
}
2161-
if err := waitForPodUnschedulable(testCtx.ClientSet, pod); err != nil {
2161+
if err := waitForPodUnschedulable(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
21622162
t.Errorf("Pod %v got scheduled: %v", pod.Name, err)
21632163
}
21642164
if err := tt.update(testCtx.ClientSet, testCtx.NS.Name); err != nil {

test/integration/scheduler/plugins/plugins_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ func TestPreFilterPlugin(t *testing.T) {
681681
}
682682

683683
if test.reject {
684-
if err = testutils.WaitForPodUnschedulable(testCtx.ClientSet, pod); err != nil {
684+
if err = testutils.WaitForPodUnschedulable(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
685685
t.Errorf("Didn't expect the pod to be scheduled. error: %v", err)
686686
}
687687
} else if test.fail {
@@ -1152,7 +1152,7 @@ func TestPrebindPlugin(t *testing.T) {
11521152
t.Errorf("Expected a scheduling error, but didn't get it. error: %v", err)
11531153
}
11541154
} else if test.reject {
1155-
if err = testutils.WaitForPodUnschedulable(testCtx.ClientSet, pod); err != nil {
1155+
if err = testutils.WaitForPodUnschedulable(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
11561156
t.Errorf("Expected the pod to be unschedulable")
11571157
}
11581158
} else if err = testutils.WaitForPodToSchedule(testCtx.ClientSet, pod); err != nil {
@@ -1384,7 +1384,7 @@ func TestUnReservePermitPlugins(t *testing.T) {
13841384
}
13851385

13861386
if test.reject {
1387-
if err = testutils.WaitForPodUnschedulable(testCtx.ClientSet, pod); err != nil {
1387+
if err = testutils.WaitForPodUnschedulable(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
13881388
t.Errorf("Didn't expect the pod to be scheduled. error: %v", err)
13891389
}
13901390

@@ -1456,7 +1456,7 @@ func TestUnReservePreBindPlugins(t *testing.T) {
14561456
}
14571457

14581458
if test.wantReject {
1459-
if err = testutils.WaitForPodUnschedulable(testCtx.ClientSet, pod); err != nil {
1459+
if err = testutils.WaitForPodUnschedulable(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
14601460
t.Errorf("Expected a reasons other than Unschedulable, but got: %v", err)
14611461
}
14621462

@@ -1902,7 +1902,7 @@ func TestPermitPlugin(t *testing.T) {
19021902
}
19031903
} else {
19041904
if test.reject || test.timeout {
1905-
if err = testutils.WaitForPodUnschedulable(testCtx.ClientSet, pod); err != nil {
1905+
if err = testutils.WaitForPodUnschedulable(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
19061906
t.Errorf("Didn't expect the pod to be scheduled. error: %v", err)
19071907
}
19081908
} else {
@@ -2068,10 +2068,10 @@ func TestCoSchedulingWithPermitPlugin(t *testing.T) {
20682068
}
20692069

20702070
if test.waitReject {
2071-
if err = testutils.WaitForPodUnschedulable(testCtx.ClientSet, podA); err != nil {
2071+
if err = testutils.WaitForPodUnschedulable(testCtx.Ctx, testCtx.ClientSet, podA); err != nil {
20722072
t.Errorf("Didn't expect the first pod to be scheduled. error: %v", err)
20732073
}
2074-
if err = testutils.WaitForPodUnschedulable(testCtx.ClientSet, podB); err != nil {
2074+
if err = testutils.WaitForPodUnschedulable(testCtx.Ctx, testCtx.ClientSet, podB); err != nil {
20752075
t.Errorf("Didn't expect the second pod to be scheduled. error: %v", err)
20762076
}
20772077
if !((permitPlugin.waitingPod == podA.Name && permitPlugin.rejectingPod == podB.Name) ||
@@ -2263,7 +2263,7 @@ func TestPreEnqueuePlugin(t *testing.T) {
22632263
t.Errorf("Expected the enqueuePlugin plugin to be called at least once, but got 0")
22642264
}
22652265
} else {
2266-
if err := testutils.WaitForPodSchedulingGated(testCtx.ClientSet, pod, 10*time.Second); err != nil {
2266+
if err := testutils.WaitForPodSchedulingGated(testCtx.Ctx, testCtx.ClientSet, pod, 10*time.Second); err != nil {
22672267
t.Errorf("Expected the pod to be scheduling waiting, but got: %v", err)
22682268
}
22692269
// Also verify preFilterPlugin is not called.
@@ -2575,7 +2575,7 @@ func TestActivatePods(t *testing.T) {
25752575

25762576
// Wait for the 2 executor pods to be unschedulable.
25772577
for _, pod := range pods {
2578-
if err := testutils.WaitForPodUnschedulable(cs, pod); err != nil {
2578+
if err := testutils.WaitForPodUnschedulable(testCtx.Ctx, cs, pod); err != nil {
25792579
t.Errorf("Failed to wait for Pod %v to be unschedulable: %v", pod.Name, err)
25802580
}
25812581
}
@@ -2721,7 +2721,7 @@ func TestSchedulingGatesPluginEventsToRegister(t *testing.T) {
27212721
return
27222722
}
27232723

2724-
if err := testutils.WaitForPodSchedulingGated(testCtx.ClientSet, gatedPod, 10*time.Second); err != nil {
2724+
if err := testutils.WaitForPodSchedulingGated(testCtx.Ctx, testCtx.ClientSet, gatedPod, 10*time.Second); err != nil {
27252725
t.Errorf("Expected the pod to be gated, but got: %v", err)
27262726
return
27272727
}
@@ -2761,7 +2761,7 @@ func TestSchedulingGatesPluginEventsToRegister(t *testing.T) {
27612761
}
27622762

27632763
// Pod should still be unschedulable because scheduling gates still exist, theoretically, it's a waste rescheduling.
2764-
if err := testutils.WaitForPodSchedulingGated(testCtx.ClientSet, gatedPod, 10*time.Second); err != nil {
2764+
if err := testutils.WaitForPodSchedulingGated(testCtx.Ctx, testCtx.ClientSet, gatedPod, 10*time.Second); err != nil {
27652765
t.Errorf("Expected the pod to be gated, but got: %v", err)
27662766
return
27672767
}

test/integration/scheduler/preemption/preemption_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ func TestDisablePreemption(t *testing.T) {
679679
t.Errorf("Error while creating high priority pod: %v", err)
680680
}
681681
// Ensure preemptor should keep unschedulable.
682-
if err := waitForPodUnschedulable(cs, preemptor); err != nil {
682+
if err := waitForPodUnschedulable(testCtx.Ctx, cs, preemptor); err != nil {
683683
t.Errorf("Preemptor %v should not become scheduled", preemptor.Name)
684684
}
685685

test/integration/scheduler/rescheduling_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ func TestReScheduling(t *testing.T) {
223223
t.Errorf("Expected a scheduling error, but got: %v", err)
224224
}
225225
} else {
226-
if err = testutils.WaitForPodUnschedulable(testCtx.ClientSet, pod); err != nil {
226+
if err = testutils.WaitForPodUnschedulable(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
227227
t.Errorf("Didn't expect the pod to be scheduled. error: %v", err)
228228
}
229229
}
@@ -244,7 +244,7 @@ func TestReScheduling(t *testing.T) {
244244
t.Errorf("Expected a scheduling error, but got: %v", err)
245245
}
246246
} else {
247-
if err = testutils.WaitForPodUnschedulable(testCtx.ClientSet, pod); err != nil {
247+
if err = testutils.WaitForPodUnschedulable(testCtx.Ctx, testCtx.ClientSet, pod); err != nil {
248248
t.Errorf("Didn't expect the pod to be scheduled. error: %v", err)
249249
}
250250
}

test/integration/scheduler/scheduler_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func TestUnschedulableNodes(t *testing.T) {
106106
if _, err := c.CoreV1().Nodes().Update(context.TODO(), n, metav1.UpdateOptions{}); err != nil {
107107
t.Fatalf("Failed to update node with unschedulable=true: %v", err)
108108
}
109-
err = testutils.WaitForReflection(t, nodeLister, nodeKey, func(node interface{}) bool {
109+
err = testutils.WaitForReflection(testCtx.Ctx, t, nodeLister, nodeKey, func(node interface{}) bool {
110110
// An unschedulable node should still be present in the store
111111
// Nodes that are unschedulable or that are not ready or
112112
// have their disk full (Node.Spec.Conditions) are excluded
@@ -122,7 +122,7 @@ func TestUnschedulableNodes(t *testing.T) {
122122
if _, err := c.CoreV1().Nodes().Update(context.TODO(), n, metav1.UpdateOptions{}); err != nil {
123123
t.Fatalf("Failed to update node with unschedulable=false: %v", err)
124124
}
125-
err = testutils.WaitForReflection(t, nodeLister, nodeKey, func(node interface{}) bool {
125+
err = testutils.WaitForReflection(testCtx.Ctx, t, nodeLister, nodeKey, func(node interface{}) bool {
126126
return node != nil && node.(*v1.Node).Spec.Unschedulable == false
127127
})
128128
if err != nil {
@@ -518,7 +518,7 @@ func TestSchedulerInformers(t *testing.T) {
518518
}
519519
}
520520
// Ensure nodes are present in scheduler cache.
521-
if err := testutils.WaitForNodesInCache(testCtx.Scheduler, len(test.nodes)); err != nil {
521+
if err := testutils.WaitForNodesInCache(testCtx.Ctx, testCtx.Scheduler, len(test.nodes)); err != nil {
522522
t.Fatal(err)
523523
}
524524

@@ -535,7 +535,7 @@ func TestSchedulerInformers(t *testing.T) {
535535
if err != nil {
536536
t.Errorf("Error while creating new pod: %v", err)
537537
}
538-
if err := testutils.WaitForPodUnschedulable(cs, unschedulable); err != nil {
538+
if err := testutils.WaitForPodUnschedulable(testCtx.Ctx, cs, unschedulable); err != nil {
539539
t.Errorf("Pod %v got scheduled: %v", unschedulable.Name, err)
540540
}
541541

@@ -597,7 +597,7 @@ func TestNodeEvents(t *testing.T) {
597597
t.Fatalf("Failed to create pod %v: %v", pod2.Name, err)
598598
}
599599

600-
if err := testutils.WaitForPodUnschedulable(testCtx.ClientSet, pod2); err != nil {
600+
if err := testutils.WaitForPodUnschedulable(testCtx.Ctx, testCtx.ClientSet, pod2); err != nil {
601601
t.Errorf("Pod %v got scheduled: %v", pod2.Name, err)
602602
}
603603

@@ -630,7 +630,7 @@ func TestNodeEvents(t *testing.T) {
630630
}
631631

632632
// 3.2 pod2 still unschedulable
633-
if err := testutils.WaitForPodUnschedulable(testCtx.ClientSet, pod2); err != nil {
633+
if err := testutils.WaitForPodUnschedulable(testCtx.Ctx, testCtx.ClientSet, pod2); err != nil {
634634
t.Errorf("Pod %v got scheduled: %v", pod2.Name, err)
635635
}
636636

test/integration/scheduler/taint/taint_test.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ import (
3535
testutils "k8s.io/kubernetes/test/integration/util"
3636
)
3737

38-
// imported from testutils
39-
var (
40-
waitForPodUnschedulable = testutils.WaitForPodUnschedulable
41-
)
42-
4338
func newPod(nsName, name string, req, limit v1.ResourceList) *v1.Pod {
4439
return &v1.Pod{
4540
ObjectMeta: metav1.ObjectMeta{
@@ -526,7 +521,7 @@ func TestTaintNodeByCondition(t *testing.T) {
526521
if _, err := cs.CoreV1().Nodes().Create(testCtx.Ctx, node, metav1.CreateOptions{}); err != nil {
527522
t.Errorf("Failed to create node, err: %v", err)
528523
}
529-
if err := testutils.WaitForNodeTaints(cs, node, test.expectedTaints); err != nil {
524+
if err := testutils.WaitForNodeTaints(testCtx.Ctx, cs, node, test.expectedTaints); err != nil {
530525
node, err = cs.CoreV1().Nodes().Get(testCtx.Ctx, node.Name, metav1.GetOptions{})
531526
if err != nil {
532527
t.Errorf("Failed to get node <%s>", node.Name)
@@ -555,7 +550,7 @@ func TestTaintNodeByCondition(t *testing.T) {
555550
pod.Namespace, pod.Name, err)
556551
}
557552
} else {
558-
if err := waitForPodUnschedulable(cs, createdPod); err != nil {
553+
if err := testutils.WaitForPodUnschedulable(testCtx.Ctx, cs, createdPod); err != nil {
559554
t.Errorf("Unschedulable pod %s/%s gets scheduled on the node, err: %v",
560555
pod.Namespace, pod.Name, err)
561556
}
@@ -564,7 +559,7 @@ func TestTaintNodeByCondition(t *testing.T) {
564559

565560
testutils.CleanupPods(testCtx.Ctx, cs, t, pods)
566561
testutils.CleanupNodes(cs, t)
567-
testutils.WaitForSchedulerCacheCleanup(testCtx.Scheduler, t)
562+
testutils.WaitForSchedulerCacheCleanup(testCtx.Ctx, testCtx.Scheduler, t)
568563
})
569564
}
570565
}

test/integration/util/util.go

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -431,15 +431,15 @@ func RemoveTaintOffNode(cs clientset.Interface, nodeName string, taint v1.Taint)
431431

432432
// WaitForNodeTaints waits for a node to have the target taints and returns
433433
// an error if it does not have taints within the given timeout.
434-
func WaitForNodeTaints(cs clientset.Interface, node *v1.Node, taints []v1.Taint) error {
435-
return wait.Poll(100*time.Millisecond, 30*time.Second, NodeTainted(cs, node.Name, taints))
434+
func WaitForNodeTaints(ctx context.Context, cs clientset.Interface, node *v1.Node, taints []v1.Taint) error {
435+
return wait.PollUntilContextTimeout(ctx, 100*time.Millisecond, 30*time.Second, false, NodeTainted(ctx, cs, node.Name, taints))
436436
}
437437

438438
// NodeTainted return a condition function that returns true if the given node contains
439439
// the taints.
440-
func NodeTainted(cs clientset.Interface, nodeName string, taints []v1.Taint) wait.ConditionFunc {
441-
return func() (bool, error) {
442-
node, err := cs.CoreV1().Nodes().Get(context.TODO(), nodeName, metav1.GetOptions{})
440+
func NodeTainted(ctx context.Context, cs clientset.Interface, nodeName string, taints []v1.Taint) wait.ConditionWithContextFunc {
441+
return func(context.Context) (bool, error) {
442+
node, err := cs.CoreV1().Nodes().Get(ctx, nodeName, metav1.GetOptions{})
443443
if err != nil {
444444
return false, err
445445
}
@@ -553,14 +553,14 @@ func InitTestAPIServer(t *testing.T, nsPrefix string, admission admission.Interf
553553
}
554554

555555
// WaitForSchedulerCacheCleanup waits for cleanup of scheduler's cache to complete
556-
func WaitForSchedulerCacheCleanup(sched *scheduler.Scheduler, t *testing.T) {
557-
schedulerCacheIsEmpty := func() (bool, error) {
556+
func WaitForSchedulerCacheCleanup(ctx context.Context, sched *scheduler.Scheduler, t *testing.T) {
557+
schedulerCacheIsEmpty := func(context.Context) (bool, error) {
558558
dump := sched.Cache.Dump()
559559

560560
return len(dump.Nodes) == 0 && len(dump.AssumedPods) == 0, nil
561561
}
562562

563-
if err := wait.Poll(time.Second, wait.ForeverTestTimeout, schedulerCacheIsEmpty); err != nil {
563+
if err := wait.PollUntilContextTimeout(ctx, time.Second, wait.ForeverTestTimeout, false, schedulerCacheIsEmpty); err != nil {
564564
t.Errorf("Failed to wait for scheduler cache cleanup: %v", err)
565565
}
566566
}
@@ -726,10 +726,10 @@ func InitTestDisablePreemption(t *testing.T, nsPrefix string) *TestContext {
726726

727727
// WaitForReflection waits till the passFunc confirms that the object it expects
728728
// to see is in the store. Used to observe reflected events.
729-
func WaitForReflection(t *testing.T, nodeLister corelisters.NodeLister, key string,
729+
func WaitForReflection(ctx context.Context, t *testing.T, nodeLister corelisters.NodeLister, key string,
730730
passFunc func(n interface{}) bool) error {
731731
var nodes []*v1.Node
732-
err := wait.Poll(time.Millisecond*100, wait.ForeverTestTimeout, func() (bool, error) {
732+
err := wait.PollUntilContextTimeout(ctx, time.Millisecond*100, wait.ForeverTestTimeout, false, func(context.Context) (bool, error) {
733733
n, err := nodeLister.Get(key)
734734

735735
switch {
@@ -783,13 +783,13 @@ func CreateAndWaitForNodesInCache(testCtx *TestContext, prefix string, wrapper *
783783
if err != nil {
784784
return nodes, fmt.Errorf("cannot create nodes: %v", err)
785785
}
786-
return nodes, WaitForNodesInCache(testCtx.Scheduler, numNodes+existingNodes)
786+
return nodes, WaitForNodesInCache(testCtx.Ctx, testCtx.Scheduler, numNodes+existingNodes)
787787
}
788788

789789
// WaitForNodesInCache ensures at least <nodeCount> nodes are present in scheduler cache
790790
// within 30 seconds; otherwise returns false.
791-
func WaitForNodesInCache(sched *scheduler.Scheduler, nodeCount int) error {
792-
err := wait.Poll(100*time.Millisecond, wait.ForeverTestTimeout, func() (bool, error) {
791+
func WaitForNodesInCache(ctx context.Context, sched *scheduler.Scheduler, nodeCount int) error {
792+
err := wait.PollUntilContextTimeout(ctx, 100*time.Millisecond, wait.ForeverTestTimeout, false, func(context.Context) (bool, error) {
793793
return sched.Cache.NodeCount() >= nodeCount, nil
794794
})
795795
if err != nil {
@@ -1018,9 +1018,9 @@ func PodSchedulingError(c clientset.Interface, podNamespace, podName string) wai
10181018

10191019
// PodSchedulingGated returns a condition function that returns true if the given pod
10201020
// gets unschedulable status of reason 'SchedulingGated'.
1021-
func PodSchedulingGated(c clientset.Interface, podNamespace, podName string) wait.ConditionFunc {
1022-
return func() (bool, error) {
1023-
pod, err := c.CoreV1().Pods(podNamespace).Get(context.TODO(), podName, metav1.GetOptions{})
1021+
func PodSchedulingGated(ctx context.Context, c clientset.Interface, podNamespace, podName string) wait.ConditionWithContextFunc {
1022+
return func(context.Context) (bool, error) {
1023+
pod, err := c.CoreV1().Pods(podNamespace).Get(ctx, podName, metav1.GetOptions{})
10241024
if err != nil {
10251025
// This could be a connection error so we want to retry.
10261026
return false, nil
@@ -1033,27 +1033,27 @@ func PodSchedulingGated(c clientset.Interface, podNamespace, podName string) wai
10331033

10341034
// WaitForPodUnschedulableWithTimeout waits for a pod to fail scheduling and returns
10351035
// an error if it does not become unschedulable within the given timeout.
1036-
func WaitForPodUnschedulableWithTimeout(cs clientset.Interface, pod *v1.Pod, timeout time.Duration) error {
1037-
return wait.PollUntilContextTimeout(context.TODO(), 100*time.Millisecond, timeout, false, PodUnschedulable(cs, pod.Namespace, pod.Name))
1036+
func WaitForPodUnschedulableWithTimeout(ctx context.Context, cs clientset.Interface, pod *v1.Pod, timeout time.Duration) error {
1037+
return wait.PollUntilContextTimeout(ctx, 100*time.Millisecond, timeout, false, PodUnschedulable(cs, pod.Namespace, pod.Name))
10381038
}
10391039

10401040
// WaitForPodUnschedulable waits for a pod to fail scheduling and returns
10411041
// an error if it does not become unschedulable within the timeout duration (30 seconds).
1042-
func WaitForPodUnschedulable(cs clientset.Interface, pod *v1.Pod) error {
1043-
return WaitForPodUnschedulableWithTimeout(cs, pod, 30*time.Second)
1042+
func WaitForPodUnschedulable(ctx context.Context, cs clientset.Interface, pod *v1.Pod) error {
1043+
return WaitForPodUnschedulableWithTimeout(ctx, cs, pod, 30*time.Second)
10441044
}
10451045

10461046
// WaitForPodSchedulingGated waits for a pod to be in scheduling gated state
10471047
// and returns an error if it does not fall into this state within the given timeout.
1048-
func WaitForPodSchedulingGated(cs clientset.Interface, pod *v1.Pod, timeout time.Duration) error {
1049-
return wait.Poll(100*time.Millisecond, timeout, PodSchedulingGated(cs, pod.Namespace, pod.Name))
1048+
func WaitForPodSchedulingGated(ctx context.Context, cs clientset.Interface, pod *v1.Pod, timeout time.Duration) error {
1049+
return wait.PollUntilContextTimeout(ctx, 100*time.Millisecond, timeout, false, PodSchedulingGated(ctx, cs, pod.Namespace, pod.Name))
10501050
}
10511051

10521052
// WaitForPDBsStable waits for PDBs to have "CurrentHealthy" status equal to
10531053
// the expected values.
10541054
func WaitForPDBsStable(testCtx *TestContext, pdbs []*policy.PodDisruptionBudget, pdbPodNum []int32) error {
1055-
return wait.Poll(time.Second, 60*time.Second, func() (bool, error) {
1056-
pdbList, err := testCtx.ClientSet.PolicyV1().PodDisruptionBudgets(testCtx.NS.Name).List(context.TODO(), metav1.ListOptions{})
1055+
return wait.PollUntilContextTimeout(testCtx.Ctx, time.Second, 60*time.Second, false, func(context.Context) (bool, error) {
1056+
pdbList, err := testCtx.ClientSet.PolicyV1().PodDisruptionBudgets(testCtx.NS.Name).List(testCtx.Ctx, metav1.ListOptions{})
10571057
if err != nil {
10581058
return false, err
10591059
}
@@ -1080,7 +1080,7 @@ func WaitForPDBsStable(testCtx *TestContext, pdbs []*policy.PodDisruptionBudget,
10801080

10811081
// WaitCachedPodsStable waits until scheduler cache has the given pods.
10821082
func WaitCachedPodsStable(testCtx *TestContext, pods []*v1.Pod) error {
1083-
return wait.Poll(time.Second, 30*time.Second, func() (bool, error) {
1083+
return wait.PollUntilContextTimeout(testCtx.Ctx, time.Second, 30*time.Second, false, func(context.Context) (bool, error) {
10841084
cachedPods, err := testCtx.Scheduler.Cache.PodCount()
10851085
if err != nil {
10861086
return false, err
@@ -1089,7 +1089,7 @@ func WaitCachedPodsStable(testCtx *TestContext, pods []*v1.Pod) error {
10891089
return false, nil
10901090
}
10911091
for _, p := range pods {
1092-
actualPod, err1 := testCtx.ClientSet.CoreV1().Pods(p.Namespace).Get(context.TODO(), p.Name, metav1.GetOptions{})
1092+
actualPod, err1 := testCtx.ClientSet.CoreV1().Pods(p.Namespace).Get(testCtx.Ctx, p.Name, metav1.GetOptions{})
10931093
if err1 != nil {
10941094
return false, err1
10951095
}

0 commit comments

Comments
 (0)