Skip to content

Commit

Permalink
Replace all usages of deprecated wait.PollImmediate with wait.PollUnt…
Browse files Browse the repository at this point in the history
…ilContextTimeout (#957)

Signed-off-by: Prashant Rewar <[email protected]>
  • Loading branch information
prashantrewar authored Apr 10, 2024
1 parent 1a6e0da commit a3d8b0f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pkg/prober/prober.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ func (m *Manager) doAsync(ctx context.Context, target string, arg interface{}, p
result bool
inErr error
)
err := wait.PollImmediate(period, timeout, func() (bool, error) {
err := wait.PollUntilContextTimeout(ctx, period, timeout, true, func(ctx context.Context) (bool, error) {
result, inErr = Do(ctx, m.transport, target, ops...)
// Do not return error, which is from verifierError, as retry is expected until timeout.
return result, nil
Expand Down
4 changes: 2 additions & 2 deletions pkg/prober/prober_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func TestDoAsyncTimeout(t *testing.T) {
if done {
t.Errorf("done was true")
}
if !errors.Is(err, wait.ErrWaitTimeout) {
if !errors.Is(err, context.DeadlineExceeded) {
t.Error("Unexpected error =", err)
}
wch <- arg
Expand Down Expand Up @@ -258,7 +258,7 @@ func TestAsyncMultiple(t *testing.T) {
wch <- 2009
<-wch

wait.PollImmediate(probeInterval, probeTimeout, func() (bool, error) {
wait.PollUntilContextTimeout(context.Background(), probeInterval, probeTimeout, true, func(ctx context.Context) (bool, error) {
return m.len() == 0, nil
})
if got, want := m.len(), 0; got != want {
Expand Down
4 changes: 2 additions & 2 deletions test/conformance/certificate/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func WaitForCertificateSecret(ctx context.Context, t *testing.T, client *test.Cl
span := logging.GetEmitableSpan(context.Background(), fmt.Sprintf("WaitForCertificateSecret/%s/%s", cert.Spec.SecretName, desc))
defer span.End()

return wait.PollImmediate(test.PollInterval, test.PollTimeout, func() (bool, error) {
return wait.PollUntilContextTimeout(ctx, test.PollInterval, test.PollTimeout, true, func(ctx context.Context) (bool, error) {
secret, err := client.KubeClient.CoreV1().Secrets(test.ServingNamespace).Get(ctx, cert.Spec.SecretName, metav1.GetOptions{})
if apierrs.IsNotFound(err) {
return false, nil
Expand Down Expand Up @@ -119,7 +119,7 @@ func WaitForCertificateState(ctx context.Context, client *test.NetworkingClients
defer span.End()

var lastState *v1alpha1.Certificate
return wait.PollImmediate(test.PollInterval, test.PollTimeout, func() (bool, error) {
return wait.PollUntilContextTimeout(ctx, test.PollInterval, test.PollTimeout, true, func(ctx context.Context) (bool, error) {
var err error
lastState, err = client.Certificates.Get(ctx, name, metav1.GetOptions{})
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions test/conformance/ingress/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ func createPodAndService(ctx context.Context, t *testing.T, clients *test.Client
}

// Wait for the Pod to show up in the Endpoints resource.
waitErr := wait.PollImmediate(test.PollInterval, test.PollTimeout, func() (bool, error) {
waitErr := wait.PollUntilContextTimeout(ctx, test.PollInterval, test.PollTimeout, true, func(ctx context.Context) (bool, error) {
var ep *corev1.Endpoints
err := reconciler.RetryTestErrors(func(attempts int) (err error) {
ep, err = clients.KubeClient.CoreV1().Endpoints(svc.Namespace).Get(ctx, svc.Name, metav1.GetOptions{})
Expand Down Expand Up @@ -1212,7 +1212,7 @@ func WaitForIngressState(ctx context.Context, client *test.NetworkingClients, na
defer span.End()

var lastState *v1alpha1.Ingress
waitErr := wait.PollImmediate(test.PollInterval, test.PollTimeout, func() (bool, error) {
waitErr := wait.PollUntilContextTimeout(ctx, test.PollInterval, test.PollTimeout, true, func(ctx context.Context) (bool, error) {
err := reconciler.RetryTestErrors(func(attempts int) (err error) {
lastState, err = client.Ingresses.Get(ctx, name, metav1.GetOptions{})
return err
Expand Down
2 changes: 1 addition & 1 deletion test/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func WaitForIngressState(ctx context.Context, client *NetworkingClients, name st
defer span.End()

var lastState *v1alpha1.Ingress
waitErr := wait.PollImmediate(PollInterval, PollTimeout, func() (bool, error) {
waitErr := wait.PollUntilContextTimeout(ctx, PollInterval, PollTimeout, true, func(ctx context.Context) (bool, error) {
var err error
lastState, err = client.Ingresses.Get(ctx, name, metav1.GetOptions{})
if err != nil {
Expand Down

0 comments on commit a3d8b0f

Please sign in to comment.