Skip to content

Commit 3711bf3

Browse files
cadenmarchesemociarain
authored andcommitted
replace deprecated k8s.io/apimachinery/pkg/util/wait funcs
1 parent 42ccf63 commit 3711bf3

File tree

18 files changed

+49
-48
lines changed

18 files changed

+49
-48
lines changed

pkg/cluster/delete.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,13 +347,13 @@ func (m *manager) deleteGatewayAndWait(ctx context.Context) error {
347347
}
348348

349349
m.log.Info("waiting for gateway record deletion")
350-
return wait.PollImmediateUntil(15*time.Second, func() (bool, error) {
350+
return wait.PollUntilContextCancel(timeoutCtx, 15*time.Second, true, func(ctx context.Context) (bool, error) {
351351
_, err := m.dbGateway.Get(ctx, m.doc.OpenShiftCluster.Properties.NetworkProfile.GatewayPrivateLinkID)
352352
if err != nil && cosmosdb.IsErrorStatusCode(err, http.StatusNotFound) /* already gone */ {
353353
return true, nil
354354
}
355355
return false, nil
356-
}, timeoutCtx.Done())
356+
})
357357
}
358358

359359
func (m *manager) deleteGateway(ctx context.Context) error {

pkg/cluster/deploybaseresources.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ func (m *manager) _attachNSGs(ctx context.Context, timeout time.Duration, pollIn
362362
// NSG since the inner loop is tolerant of that, and since we are attaching
363363
// the same NSG the only allowed failure case is when the NSG cannot be
364364
// attached to begin with, so it shouldn't happen in practice.
365-
_ = wait.PollImmediateUntil(pollInterval, func() (bool, error) {
365+
_ = wait.PollUntilContextCancel(timeoutCtx, pollInterval, true, func(pollCtx context.Context) (bool, error) {
366366
var c bool
367367
c, innerErr = func() (bool, error) {
368368
for _, subnetID := range []string{
@@ -427,7 +427,7 @@ func (m *manager) _attachNSGs(ctx context.Context, timeout time.Duration, pollIn
427427
}()
428428

429429
return c, innerErr
430-
}, timeoutCtx.Done())
430+
})
431431

432432
return innerErr
433433
}

pkg/deploy/predeploy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,9 @@ func (d *deployer) restartOldScaleset(ctx context.Context, vmssName string, lbHe
589589
}
590590

591591
func (d *deployer) waitForReadiness(ctx context.Context, vmssName string, vmInstanceID string) error {
592-
return wait.PollImmediateUntil(10*time.Second, func() (bool, error) {
592+
return wait.PollUntilContextCancel(ctx, 10*time.Second, true, func(pollCtx context.Context) (bool, error) {
593593
return d.isVMInstanceHealthy(ctx, d.config.RPResourceGroupName, vmssName, vmInstanceID), nil
594-
}, ctx.Done())
594+
})
595595
}
596596

597597
func (d *deployer) isVMInstanceHealthy(ctx context.Context, resourceGroupName string, vmssName string, vmInstanceID string) bool {

pkg/deploy/upgrade_gateway.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ func (d *deployer) gatewayWaitForReadiness(ctx context.Context, vmssName string)
4343
}
4444

4545
d.log.Printf("waiting for %s instances to be healthy", vmssName)
46-
return wait.PollImmediateUntil(10*time.Second, func() (bool, error) {
46+
return wait.PollUntilContextCancel(ctx, 10*time.Second, true, func(pollCtx context.Context) (bool, error) {
4747
for _, vm := range scalesetVMs {
4848
if !d.isVMInstanceHealthy(ctx, d.config.GatewayResourceGroupName, vmssName, *vm.InstanceID) {
4949
return false, nil
5050
}
5151
}
5252

5353
return true, nil
54-
}, ctx.Done())
54+
})
5555
}
5656

5757
func (d *deployer) gatewayRemoveOldScalesets(ctx context.Context) error {

pkg/deploy/upgrade_rp.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ func (d *deployer) rpWaitForReadiness(ctx context.Context, vmssName string) erro
4343
}
4444

4545
d.log.Printf("waiting for %s instances to be healthy", vmssName)
46-
return wait.PollImmediateUntil(10*time.Second, func() (bool, error) {
46+
return wait.PollUntilContextCancel(ctx, 10*time.Second, true, func(pollCtx context.Context) (bool, error) {
4747
for _, vm := range scalesetVMs {
4848
if !d.isVMInstanceHealthy(ctx, d.config.RPResourceGroupName, vmssName, *vm.InstanceID) {
4949
return false, nil
5050
}
5151
}
5252

5353
return true, nil
54-
}, ctx.Done())
54+
})
5555
}
5656

5757
func (d *deployer) rpRemoveOldScalesets(ctx context.Context) error {

pkg/operator/controllers/guardrails/guardrails_controller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ func (r *Reconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.
9999
timeoutCtx, cancel := context.WithTimeout(ctx, r.readinessTimeout)
100100
defer cancel()
101101

102-
err := wait.PollImmediateUntil(r.readinessPollTime, func() (bool, error) {
102+
err := wait.PollUntilContextCancel(timeoutCtx, r.readinessPollTime, true, func(pollCtx context.Context) (bool, error) {
103103
return r.gatekeeperDeploymentIsReady(ctx, deployConfig)
104-
}, timeoutCtx.Done())
104+
})
105105
if err != nil {
106106
return reconcile.Result{}, fmt.Errorf("GateKeeper deployment timed out on Ready: %w", err)
107107
}
@@ -114,9 +114,9 @@ func (r *Reconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.
114114
return reconcile.Result{}, err
115115
}
116116

117-
err := wait.PollImmediateUntil(r.readinessPollTime, func() (bool, error) {
117+
err := wait.PollUntilContextCancel(timeoutCtx, r.readinessPollTime, true, func(pollCtx context.Context) (bool, error) {
118118
return r.gkPolicyTemplate.IsConstraintTemplateReady(ctx, policyConfig)
119-
}, timeoutCtx.Done())
119+
})
120120
if err != nil {
121121
return reconcile.Result{}, fmt.Errorf("GateKeeper ConstraintTemplates timed out on creation: %w", err)
122122
}

pkg/operator/controllers/muo/muo_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ func (r *Reconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.
114114
timeoutCtx, cancel := context.WithTimeout(ctx, r.readinessTimeout)
115115
defer cancel()
116116

117-
err = wait.PollImmediateUntil(r.readinessPollTime, func() (bool, error) {
117+
err = wait.PollUntilContextCancel(timeoutCtx, r.readinessPollTime, true, func(pollCtx context.Context) (bool, error) {
118118
return r.deployer.IsReady(ctx, "openshift-managed-upgrade-operator", "managed-upgrade-operator")
119-
}, timeoutCtx.Done())
119+
})
120120
if err != nil {
121121
return reconcile.Result{}, fmt.Errorf("managed Upgrade Operator deployment timed out on Ready: %w", err)
122122
}

pkg/operator/deploy/deploy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ func (o *operator) applyDeployment(ctx context.Context, resources []kruntime.Obj
432432
return err
433433
}
434434

435-
err = wait.PollImmediate(time.Second, time.Minute, func() (bool, error) {
435+
err = wait.PollUntilContextTimeout(ctx, time.Second, time.Minute, true, func(pollCtx context.Context) (bool, error) {
436436
crd, err := o.extensionscli.ApiextensionsV1().CustomResourceDefinitions().Get(ctx, acc.GetName(), metav1.GetOptions{})
437437
if err != nil {
438438
return false, err

pkg/util/arm/deploy_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func TestDeployARMTemplate(t *testing.T) {
7474
Return(activeErr)
7575
dc.EXPECT().
7676
Wait(ctx, resourceGroup, deploymentName).
77-
Return(wait.ErrWaitTimeout)
77+
Return(wait.ErrorInterrupted(context.DeadlineExceeded))
7878
},
7979
wantErr: "timed out waiting for the condition",
8080
},

pkg/util/azureclient/azuresdk/azcertificates/helpers.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ func WaitForCertificateOperation(parent context.Context, log *logrus.Entry, oper
107107
ctx, cancel := context.WithTimeout(parent, 15*time.Minute)
108108
defer cancel()
109109

110-
err := wait.PollImmediateUntil(10*time.Second, func() (bool, error) {
110+
err := wait.PollUntilContextCancel(ctx, 10*time.Second, true, func(pollCtx context.Context) (bool, error) {
111111
op, err := operation(ctx)
112112
if err != nil {
113113
return false, err
114114
}
115115

116116
return checkOperation(op, log)
117-
}, ctx.Done())
117+
})
118118
return err
119119
}
120120

0 commit comments

Comments
 (0)