Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace all usages of deprecated wait.PollImmediate with wait.PollUntilContextTimeout #957

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1204,7 +1204,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
Loading