Skip to content

Commit 9136303

Browse files
authored
Merge pull request #739 from googs1025/replace
replace deprecated method
2 parents 4f3094e + 1cbd003 commit 9136303

20 files changed

+57
-58
lines changed

pkg/controllers/elasticquota_controller_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,8 +203,7 @@ func TestElasticQuotaController_Run(t *testing.T) {
203203
t.Errorf("reconcile: (%v)", err)
204204
}
205205
}
206-
207-
err := wait.Poll(200*time.Millisecond, 1*time.Second, func() (done bool, err error) {
206+
err := wait.PollUntilContextTimeout(ctx, 200*time.Millisecond, 1*time.Second, false, func(ctx context.Context) (done bool, err error) {
208207
for _, v := range c.want {
209208
eq := &v1alpha1.ElasticQuota{
210209
ObjectMeta: metav1.ObjectMeta{

pkg/networkaware/networkoverhead/networkoverhead_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ func BenchmarkNetworkOverheadPreFilter(b *testing.B) {
549549
state := framework.NewCycleState()
550550

551551
// Wait for the pods to be scheduled.
552-
if err := wait.Poll(1*time.Second, 20*time.Second, func() (bool, error) {
552+
if err := wait.PollUntilContextTimeout(ctx, 1*time.Second, 20*time.Second, false, func(ctx context.Context) (bool, error) {
553553
return true, nil
554554
}); err != nil {
555555
b.Errorf("pods not scheduled yet: %v ", err)
@@ -767,7 +767,7 @@ func TestNetworkOverheadScore(t *testing.T) {
767767
}
768768

769769
// Wait for the pods to be scheduled.
770-
if err := wait.Poll(1*time.Second, 20*time.Second, func() (bool, error) {
770+
if err := wait.PollUntilContextTimeout(ctx, 1*time.Second, 20*time.Second, false, func(ctx context.Context) (bool, error) {
771771
return true, nil
772772
}); err != nil {
773773
t.Errorf("pods not scheduled yet: %v ", err)
@@ -1016,7 +1016,7 @@ func BenchmarkNetworkOverheadScore(b *testing.B) {
10161016
state := framework.NewCycleState()
10171017

10181018
// Wait for the pods to be scheduled.
1019-
if err := wait.Poll(1*time.Second, 20*time.Second, func() (bool, error) {
1019+
if err := wait.PollUntilContextTimeout(ctx, 1*time.Second, 20*time.Second, false, func(ctx context.Context) (bool, error) {
10201020
return true, nil
10211021
}); err != nil {
10221022
b.Errorf("pods not scheduled yet: %v ", err)
@@ -1245,7 +1245,7 @@ func TestNetworkOverheadFilter(t *testing.T) {
12451245
}
12461246

12471247
// Wait for the pods to be scheduled.
1248-
if err := wait.Poll(1*time.Second, 20*time.Second, func() (bool, error) {
1248+
if err := wait.PollUntilContextTimeout(ctx, 1*time.Second, 20*time.Second, false, func(ctx context.Context) (bool, error) {
12491249
return true, nil
12501250
}); err != nil {
12511251
t.Errorf("pods not scheduled yet: %v ", err)
@@ -1471,7 +1471,7 @@ func BenchmarkNetworkOverheadFilter(b *testing.B) {
14711471
}
14721472

14731473
// Wait for the pods to be scheduled.
1474-
if err := wait.Poll(1*time.Second, 20*time.Second, func() (bool, error) {
1474+
if err := wait.PollUntilContextTimeout(ctx, 1*time.Second, 20*time.Second, false, func(ctx context.Context) (bool, error) {
14751475
return true, nil
14761476
}); err != nil {
14771477
b.Errorf("pods not scheduled yet: %v ", err)

test/integration/allocatable_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func TestAllocatablePlugin(t *testing.T) {
134134

135135
for i := range pods {
136136
// Wait for the pod to be scheduled.
137-
err := wait.Poll(1*time.Second, 60*time.Second, func() (bool, error) {
137+
err := wait.PollUntilContextTimeout(testCtx.Ctx, 1*time.Second, 60*time.Second, false, func(ctx context.Context) (bool, error) {
138138
return podScheduled(cs, pods[i].Namespace, pods[i].Name), nil
139139
})
140140
if err != nil {

test/integration/capacity_scheduling_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ func TestCapacityScheduling(t *testing.T) {
4848
testCtx.ClientSet = cs
4949
testCtx.KubeConfig = globalKubeConfig
5050

51-
if err := wait.Poll(100*time.Millisecond, 3*time.Second, func() (done bool, err error) {
51+
if err := wait.PollUntilContextTimeout(testCtx.Ctx, 100*time.Millisecond, 3*time.Second, false, func(ctx context.Context) (done bool, err error) {
5252
groupList, _, err := cs.ServerGroupsAndResources()
5353
if err != nil {
5454
return false, nil
@@ -522,7 +522,7 @@ func TestCapacityScheduling(t *testing.T) {
522522
}
523523
}
524524

525-
if err := wait.Poll(time.Millisecond*200, 10*time.Second, func() (bool, error) {
525+
if err := wait.PollUntilContextTimeout(testCtx.Ctx, time.Millisecond*200, 10*time.Second, false, func(ctx context.Context) (bool, error) {
526526
for _, pod := range tt.existPods {
527527
if !podScheduled(cs, pod.Namespace, pod.Name) {
528528
return false, nil
@@ -541,7 +541,7 @@ func TestCapacityScheduling(t *testing.T) {
541541
}
542542
}
543543

544-
if err := wait.Poll(time.Millisecond*200, 10*time.Second, func() (bool, error) {
544+
if err := wait.PollUntilContextTimeout(testCtx.Ctx, time.Millisecond*200, 10*time.Second, false, func(ctx context.Context) (bool, error) {
545545
for _, v := range tt.expectedPods {
546546
if !podScheduled(cs, v.Namespace, v.Name) {
547547
return false, nil

test/integration/coscheduling_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func TestCoschedulingPlugin(t *testing.T) {
5353
testCtx.ClientSet = cs
5454
testCtx.KubeConfig = globalKubeConfig
5555

56-
if err := wait.Poll(100*time.Millisecond, 3*time.Second, func() (done bool, err error) {
56+
if err := wait.PollUntilContextTimeout(testCtx.Ctx, 100*time.Millisecond, 3*time.Second, false, func(ctx context.Context) (done bool, err error) {
5757
groupList, _, err := cs.ServerGroupsAndResources()
5858
if err != nil {
5959
return false, nil
@@ -361,7 +361,7 @@ func TestCoschedulingPlugin(t *testing.T) {
361361
t.Fatalf("Failed to create Pod %q: %v", tt.pods[i].Name, err)
362362
}
363363
}
364-
err = wait.Poll(1*time.Second, 120*time.Second, func() (bool, error) {
364+
err = wait.PollUntilContextTimeout(testCtx.Ctx, 1*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
365365
for _, v := range tt.expectedPods {
366366
if !podScheduled(cs, ns, v) {
367367
return false, nil
@@ -386,7 +386,7 @@ func TestPodgroupBackoff(t *testing.T) {
386386
testCtx.ClientSet = cs
387387
testCtx.KubeConfig = globalKubeConfig
388388

389-
if err := wait.Poll(100*time.Millisecond, 3*time.Second, func() (done bool, err error) {
389+
if err := wait.PollUntilContextTimeout(testCtx.Ctx, 100*time.Millisecond, 3*time.Second, false, func(ctx context.Context) (done bool, err error) {
390390
groupList, _, err := cs.ServerGroupsAndResources()
391391
if err != nil {
392392
return false, nil
@@ -539,7 +539,7 @@ func TestPodgroupBackoff(t *testing.T) {
539539
t.Fatalf("Failed to create Pod %q: %v", tt.pods[i].Name, err)
540540
}
541541
}
542-
err = wait.Poll(1*time.Second, 120*time.Second, func() (bool, error) {
542+
err = wait.PollUntilContextTimeout(testCtx.Ctx, 1*time.Second, 120*time.Second, false, func(ctx context.Context) (bool, error) {
543543
for _, v := range tt.expectedPods {
544544
if !podScheduled(cs, ns, v) {
545545
return false, nil

test/integration/elasticquota_controller_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestElasticController(t *testing.T) {
7878
}
7979
}()
8080

81-
if err := wait.Poll(100*time.Millisecond, 3*time.Second, func() (done bool, err error) {
81+
if err := wait.PollUntilContextTimeout(testCtx.Ctx, 100*time.Millisecond, 3*time.Second, false, func(ctx context.Context) (done bool, err error) {
8282
groupList, _, err := cs.ServerGroupsAndResources()
8383
if err != nil {
8484
return false, nil
@@ -301,7 +301,7 @@ func TestElasticController(t *testing.T) {
301301
}
302302
}
303303
}
304-
if err := wait.Poll(time.Millisecond*200, 10*time.Second, func() (bool, error) {
304+
if err := wait.PollUntilContextTimeout(testCtx.Ctx, time.Millisecond*200, 10*time.Second, false, func(ctx context.Context) (bool, error) {
305305
for _, pod := range tt.incomingPods {
306306
if !podScheduled(cs, pod.Namespace, pod.Name) {
307307
return false, nil
@@ -312,10 +312,10 @@ func TestElasticController(t *testing.T) {
312312
t.Fatalf("%v Waiting existPods created error: %v", tt.name, err.Error())
313313
}
314314

315-
if err := wait.Poll(time.Millisecond*200, 10*time.Second, func() (bool, error) {
315+
if err := wait.PollUntilContextTimeout(testCtx.Ctx, time.Millisecond*200, 10*time.Second, false, func(ctx context.Context) (bool, error) {
316316
for _, v := range tt.used {
317317
var eq schedv1alpha1.ElasticQuota
318-
if err := extClient.Get(testCtx.Ctx, types.NamespacedName{Namespace: v.Namespace, Name: v.Name}, &eq); err != nil {
318+
if err := extClient.Get(ctx, types.NamespacedName{Namespace: v.Namespace, Name: v.Name}, &eq); err != nil {
319319
// This could be a connection error so we want to retry.
320320
klog.ErrorS(err, "Failed to obtain the elasticQuota clientSet")
321321
return false, err
@@ -335,7 +335,7 @@ func TestElasticController(t *testing.T) {
335335
t.Fatalf("Failed to update Pod status %q: %v", pod.Name, err)
336336
}
337337
}
338-
if err := wait.Poll(time.Millisecond*200, 10*time.Second, func() (bool, error) {
338+
if err := wait.PollUntilContextTimeout(testCtx.Ctx, time.Millisecond*200, 10*time.Second, false, func(ctx context.Context) (bool, error) {
339339
for _, pod := range tt.incomingPods {
340340
if !podScheduled(cs, pod.Namespace, pod.Name) {
341341
return false, nil
@@ -346,10 +346,10 @@ func TestElasticController(t *testing.T) {
346346
t.Fatalf("%v Waiting nextPods update status error: %v", tt.name, err.Error())
347347
}
348348

349-
if err := wait.Poll(time.Millisecond*200, 10*time.Second, func() (bool, error) {
349+
if err := wait.PollUntilContextTimeout(testCtx.Ctx, time.Millisecond*200, 10*time.Second, false, func(ctx context.Context) (bool, error) {
350350
for _, v := range tt.want {
351351
var eq schedv1alpha1.ElasticQuota
352-
if err := extClient.Get(testCtx.Ctx, types.NamespacedName{Namespace: v.Namespace, Name: v.Name}, &eq); err != nil {
352+
if err := extClient.Get(ctx, types.NamespacedName{Namespace: v.Namespace, Name: v.Name}, &eq); err != nil {
353353
// This could be a connection error so we want to retry.
354354
klog.ErrorS(err, "Failed to obtain the elasticQuota clientSet")
355355
return false, err

test/integration/loadVariationRiskBalancing_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ func TestLoadVariationRiskBalancingPlugin(t *testing.T) {
183183

184184
expected := [2]string{"node-1", "node-1"}
185185
for i := range newPods {
186-
err := wait.Poll(1*time.Second, 10*time.Second, func() (bool, error) {
186+
err := wait.PollUntilContextTimeout(testCtx.Ctx, 1*time.Second, 10*time.Second, false, func(ctx context.Context) (bool, error) {
187187
return podScheduled(cs, newPods[i].Namespace, newPods[i].Name), nil
188188
})
189189
assert.Nil(t, err)

test/integration/lowriskovercommitment_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func TestLowRiskOverCommitmentPlugin(t *testing.T) {
197197

198198
expectedNodes := []string{"node-1"}
199199
for i := numExistingPods; i < numPods; i++ {
200-
err = wait.Poll(1*time.Second, 10*time.Second, func() (bool, error) {
200+
err = wait.PollUntilContextTimeout(testCtx.Ctx, 1*time.Second, 10*time.Second, false, func(ctx context.Context) (bool, error) {
201201
return podScheduled(cs, pods[i].Namespace, pods[i].Name), nil
202202
})
203203
assert.Nil(t, err)

test/integration/networkoverhead_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ func TestNetworkOverheadPlugin(t *testing.T) {
6565
testCtx.ClientSet = cs
6666
testCtx.KubeConfig = globalKubeConfig
6767

68-
if err := wait.Poll(100*time.Millisecond, 3*time.Second, func() (done bool, err error) {
68+
if err := wait.PollUntilContextTimeout(testCtx.Ctx, 100*time.Millisecond, 3*time.Second, false, func(ctx context.Context) (done bool, err error) {
6969
groupList, _, err := cs.ServerGroupsAndResources()
7070
if err != nil {
7171
return false, nil
@@ -81,7 +81,7 @@ func TestNetworkOverheadPlugin(t *testing.T) {
8181
t.Fatalf("Timed out waiting for AppGroup CRD to be ready: %v", err)
8282
}
8383

84-
if err := wait.Poll(100*time.Millisecond, 3*time.Second, func() (done bool, err error) {
84+
if err := wait.PollUntilContextTimeout(testCtx.Ctx, 100*time.Millisecond, 3*time.Second, false, func(ctx context.Context) (done bool, err error) {
8585
groupList, _, err := cs.ServerGroupsAndResources()
8686
if err != nil {
8787
return false, nil
@@ -279,7 +279,7 @@ func TestNetworkOverheadPlugin(t *testing.T) {
279279
for _, p := range tt.pods {
280280
if len(tt.expectedNodes) > 0 {
281281
// Wait for the pod to be scheduled.
282-
if err := wait.Poll(1*time.Second, 20*time.Second, func() (bool, error) {
282+
if err := wait.PollUntilContextTimeout(testCtx.Ctx, 1*time.Second, 20*time.Second, false, func(ctx context.Context) (bool, error) {
283283
return podScheduled(cs, ns, p.Name), nil
284284

285285
}); err != nil {

test/integration/noderesourcetopology_cache_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,9 +889,9 @@ func waitForPodList(cs clientset.Interface, podDescs []podDesc, timeout time.Dur
889889
defer wg.Done()
890890

891891
var updatedPod *corev1.Pod
892-
err := wait.Poll(5*time.Second, timeout, func() (bool, error) {
892+
err := wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, timeout, false, func(ctx context.Context) (bool, error) {
893893
var nerr error
894-
updatedPod, nerr = cs.CoreV1().Pods(pod.Namespace).Get(context.TODO(), pod.Name, metav1.GetOptions{})
894+
updatedPod, nerr = cs.CoreV1().Pods(pod.Namespace).Get(ctx, pod.Name, metav1.GetOptions{})
895895
if nerr != nil {
896896
klog.ErrorS(nerr, "Failed to get pod", "pod", klog.KRef(pod.Namespace, pod.Name))
897897
return false, nerr

0 commit comments

Comments
 (0)