diff --git a/test/e2e/apimachinery/crd_conversion_webhook.go b/test/e2e/apimachinery/crd_conversion_webhook.go index 541b2145220..9e6d8956d84 100644 --- a/test/e2e/apimachinery/crd_conversion_webhook.go +++ b/test/e2e/apimachinery/crd_conversion_webhook.go @@ -483,7 +483,7 @@ func testCRListConversion(ctx context.Context, f *framework.Framework, testCrd * // waitWebhookConversionReady sends stub custom resource creation requests requiring conversion until one succeeds. func waitWebhookConversionReady(ctx context.Context, f *framework.Framework, crd *apiextensionsv1.CustomResourceDefinition, customResourceClients map[string]dynamic.ResourceInterface, version string) { - framework.ExpectNoError(wait.PollImmediateWithContext(ctx, 100*time.Millisecond, 30*time.Second, func(ctx context.Context) (bool, error) { + framework.ExpectNoError(wait.PollUntilContextTimeout(ctx, 100*time.Millisecond, 30*time.Second, true, func(ctx context.Context) (bool, error) { crInstance := &unstructured.Unstructured{ Object: map[string]interface{}{ "kind": crd.Spec.Names.Kind, diff --git a/test/e2e/apimachinery/garbage_collector.go b/test/e2e/apimachinery/garbage_collector.go index 8eb838680b0..bab23e44ef2 100644 --- a/test/e2e/apimachinery/garbage_collector.go +++ b/test/e2e/apimachinery/garbage_collector.go @@ -491,7 +491,7 @@ var _ = SIGDescribe("Garbage collector", func() { } // wait for deployment to create some rs ginkgo.By("Wait for the Deployment to create new ReplicaSet") - err = wait.PollImmediateWithContext(ctx, 500*time.Millisecond, 1*time.Minute, func(ctx context.Context) (bool, error) { + err = wait.PollUntilContextTimeout(ctx, 500*time.Millisecond, 1*time.Minute, true, func(ctx context.Context) (bool, error) { rsList, err := rsClient.List(ctx, metav1.ListOptions{}) if err != nil { return false, fmt.Errorf("failed to list rs: %w", err) @@ -510,7 +510,7 @@ var _ = SIGDescribe("Garbage collector", func() { framework.Failf("failed to delete the deployment: %v", err) } ginkgo.By("wait for all rs to be garbage collected") - err = wait.PollImmediateWithContext(ctx, 500*time.Millisecond, 1*time.Minute+gcInformerResyncRetryTimeout, func(ctx context.Context) (bool, error) { + err = wait.PollUntilContextTimeout(ctx, 500*time.Millisecond, 1*time.Minute+gcInformerResyncRetryTimeout, true, func(ctx context.Context) (bool, error) { objects := map[string]int{"Deployments": 0, "ReplicaSets": 0, "Pods": 0} return verifyRemainingObjects(ctx, f, objects) }) @@ -551,7 +551,7 @@ var _ = SIGDescribe("Garbage collector", func() { // wait for deployment to create some rs ginkgo.By("Wait for the Deployment to create new ReplicaSet") var replicaset appsv1.ReplicaSet - err = wait.PollImmediateWithContext(ctx, 500*time.Millisecond, 1*time.Minute, func(ctx context.Context) (bool, error) { + err = wait.PollUntilContextTimeout(ctx, 500*time.Millisecond, 1*time.Minute, true, func(ctx context.Context) (bool, error) { rsList, err := rsClient.List(ctx, metav1.ListOptions{}) if err != nil { return false, fmt.Errorf("failed to list rs: %w", err) @@ -568,7 +568,7 @@ var _ = SIGDescribe("Garbage collector", func() { } desiredGeneration := replicaset.Generation - if err := wait.PollImmediateWithContext(ctx, 100*time.Millisecond, 60*time.Second, func(ctx context.Context) (bool, error) { + if err := wait.PollUntilContextTimeout(ctx, 100*time.Millisecond, 60*time.Second, true, func(ctx context.Context) (bool, error) { newRS, err := clientSet.AppsV1().ReplicaSets(replicaset.Namespace).Get(ctx, replicaset.Name, metav1.GetOptions{}) if err != nil { return false, err @@ -585,7 +585,7 @@ var _ = SIGDescribe("Garbage collector", func() { framework.Failf("failed to delete the deployment: %v", err) } ginkgo.By("wait for deployment deletion to see if the garbage collector mistakenly deletes the rs") - err = wait.PollImmediateWithContext(ctx, 500*time.Millisecond, 1*time.Minute+gcInformerResyncRetryTimeout, func(ctx context.Context) (bool, error) { + err = wait.PollUntilContextTimeout(ctx, 500*time.Millisecond, 1*time.Minute+gcInformerResyncRetryTimeout, true, func(ctx context.Context) (bool, error) { dList, err := deployClient.List(ctx, metav1.ListOptions{}) if err != nil { return false, fmt.Errorf("failed to list deployments: %w", err) @@ -974,7 +974,7 @@ var _ = SIGDescribe("Garbage collector", func() { } // Wait for the canary foreground finalization to complete, which means GC is aware of our new custom resource type var lastCanary *unstructured.Unstructured - if err := wait.PollImmediateWithContext(ctx, 5*time.Second, 3*time.Minute, func(ctx context.Context) (bool, error) { + if err := wait.PollUntilContextTimeout(ctx, 5*time.Second, 3*time.Minute, true, func(ctx context.Context) (bool, error) { lastCanary, err = resourceClient.Get(ctx, dependentName, metav1.GetOptions{}) return apierrors.IsNotFound(err), nil }); err != nil { @@ -1119,7 +1119,7 @@ var _ = SIGDescribe("Garbage collector", func() { framework.ExpectNoError(err, "failed to create cronjob: %+v, in namespace: %s", cronJob, f.Namespace.Name) ginkgo.By("Wait for the CronJob to create new Job") - err = wait.PollImmediateWithContext(ctx, 500*time.Millisecond, 2*time.Minute, func(ctx context.Context) (bool, error) { + err = wait.PollUntilContextTimeout(ctx, 500*time.Millisecond, 2*time.Minute, true, func(ctx context.Context) (bool, error) { jobs, err := f.ClientSet.BatchV1().Jobs(f.Namespace.Name).List(ctx, metav1.ListOptions{}) if err != nil { return false, fmt.Errorf("failed to list jobs: %w", err) @@ -1135,7 +1135,7 @@ var _ = SIGDescribe("Garbage collector", func() { framework.Failf("Failed to delete the CronJob: %v", err) } ginkgo.By("Verify if cronjob does not leave jobs nor pods behind") - err = wait.PollImmediateWithContext(ctx, 500*time.Millisecond, 1*time.Minute, func(ctx context.Context) (bool, error) { + err = wait.PollUntilContextTimeout(ctx, 500*time.Millisecond, 1*time.Minute, true, func(ctx context.Context) (bool, error) { objects := map[string]int{"CronJobs": 0, "Jobs": 0, "Pods": 0} return verifyRemainingObjects(ctx, f, objects) }) diff --git a/test/e2e/apimachinery/resource_quota.go b/test/e2e/apimachinery/resource_quota.go index fcfb1ff1890..0293117d8cc 100644 --- a/test/e2e/apimachinery/resource_quota.go +++ b/test/e2e/apimachinery/resource_quota.go @@ -1185,7 +1185,7 @@ var _ = SIGDescribe("ResourceQuota", func() { }) framework.ExpectNoError(err, "failed to locate ResourceQuota %q in namespace %q", patchedResourceQuota.Name, ns) - err = wait.PollImmediateWithContext(ctx, 5*time.Second, 5*time.Minute, func(ctx context.Context) (bool, error) { + err = wait.PollUntilContextTimeout(ctx, 5*time.Second, 5*time.Minute, true, func(ctx context.Context) (bool, error) { resourceQuotaResult, err := rqClient.Get(ctx, rqName, metav1.GetOptions{}) framework.ExpectNoError(err) diff --git a/test/e2e/apps/controller_revision.go b/test/e2e/apps/controller_revision.go index c873b0ec187..5630b9d5798 100644 --- a/test/e2e/apps/controller_revision.go +++ b/test/e2e/apps/controller_revision.go @@ -65,7 +65,7 @@ var _ = SIGDescribe("ControllerRevision [Serial]", func() { for _, ds := range daemonsets.Items { ginkgo.By(fmt.Sprintf("Deleting DaemonSet %q", ds.Name)) framework.ExpectNoError(e2eresource.DeleteResourceAndWaitForGC(ctx, f.ClientSet, extensionsinternal.Kind("DaemonSet"), f.Namespace.Name, ds.Name)) - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkRunningOnNoNodes(f, &ds)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkRunningOnNoNodes(f, &ds)) framework.ExpectNoError(err, "error waiting for daemon pod to be reaped") } } @@ -134,7 +134,7 @@ var _ = SIGDescribe("ControllerRevision [Serial]", func() { framework.ExpectNoError(err) ginkgo.By("Check that daemon pods launch on every node of the cluster.") - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkRunningOnAllNodes(f, testDaemonset)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkRunningOnAllNodes(f, testDaemonset)) framework.ExpectNoError(err, "error waiting for daemon pod to start") err = e2edaemonset.CheckDaemonStatus(ctx, f, dsName) framework.ExpectNoError(err) @@ -191,7 +191,7 @@ var _ = SIGDescribe("ControllerRevision [Serial]", func() { framework.Logf("Created ControllerRevision: %s", newControllerRevision.Name) ginkgo.By("Confirm that there are two ControllerRevisions") - err = wait.PollImmediateWithContext(ctx, controllerRevisionRetryPeriod, controllerRevisionRetryTimeout, checkControllerRevisionListQuantity(f, dsLabelSelector, 2)) + err = wait.PollUntilContextTimeout(ctx, controllerRevisionRetryPeriod, controllerRevisionRetryTimeout, true, checkControllerRevisionListQuantity(f, dsLabelSelector, 2)) framework.ExpectNoError(err, "failed to count required ControllerRevisions") ginkgo.By(fmt.Sprintf("Deleting ControllerRevision %q", initialRevision.Name)) @@ -199,7 +199,7 @@ var _ = SIGDescribe("ControllerRevision [Serial]", func() { framework.ExpectNoError(err, "Failed to delete ControllerRevision: %v", err) ginkgo.By("Confirm that there is only one ControllerRevision") - err = wait.PollImmediateWithContext(ctx, controllerRevisionRetryPeriod, controllerRevisionRetryTimeout, checkControllerRevisionListQuantity(f, dsLabelSelector, 1)) + err = wait.PollUntilContextTimeout(ctx, controllerRevisionRetryPeriod, controllerRevisionRetryTimeout, true, checkControllerRevisionListQuantity(f, dsLabelSelector, 1)) framework.ExpectNoError(err, "failed to count required ControllerRevisions") listControllerRevisions, err := csAppsV1.ControllerRevisions(ns).List(ctx, metav1.ListOptions{}) @@ -226,7 +226,7 @@ var _ = SIGDescribe("ControllerRevision [Serial]", func() { framework.ExpectNoError(err, "error patching daemon set") ginkgo.By("Confirm that there are two ControllerRevisions") - err = wait.PollImmediateWithContext(ctx, controllerRevisionRetryPeriod, controllerRevisionRetryTimeout, checkControllerRevisionListQuantity(f, dsLabelSelector, 2)) + err = wait.PollUntilContextTimeout(ctx, controllerRevisionRetryPeriod, controllerRevisionRetryTimeout, true, checkControllerRevisionListQuantity(f, dsLabelSelector, 2)) framework.ExpectNoError(err, "failed to count required ControllerRevisions") updatedLabel := map[string]string{updatedControllerRevision.Name: "updated"} @@ -237,7 +237,7 @@ var _ = SIGDescribe("ControllerRevision [Serial]", func() { framework.ExpectNoError(err, "Failed to delete ControllerRevision: %v", err) ginkgo.By("Confirm that there is only one ControllerRevision") - err = wait.PollImmediateWithContext(ctx, controllerRevisionRetryPeriod, controllerRevisionRetryTimeout, checkControllerRevisionListQuantity(f, dsLabelSelector, 1)) + err = wait.PollUntilContextTimeout(ctx, controllerRevisionRetryPeriod, controllerRevisionRetryTimeout, true, checkControllerRevisionListQuantity(f, dsLabelSelector, 1)) framework.ExpectNoError(err, "failed to count required ControllerRevisions") list, err := csAppsV1.ControllerRevisions(ns).List(ctx, metav1.ListOptions{}) diff --git a/test/e2e/apps/daemon_set.go b/test/e2e/apps/daemon_set.go index 8b2bac38837..fc8079d72f1 100644 --- a/test/e2e/apps/daemon_set.go +++ b/test/e2e/apps/daemon_set.go @@ -92,7 +92,7 @@ type updateDSFunc func(*appsv1.DaemonSet) func updateDaemonSetWithRetries(ctx context.Context, c clientset.Interface, namespace, name string, applyUpdate updateDSFunc) (ds *appsv1.DaemonSet, err error) { daemonsets := c.AppsV1().DaemonSets(namespace) var updateErr error - pollErr := wait.PollImmediateWithContext(ctx, 10*time.Millisecond, 1*time.Minute, func(ctx context.Context) (bool, error) { + pollErr := wait.PollUntilContextTimeout(ctx, 10*time.Millisecond, 1*time.Minute, true, func(ctx context.Context) (bool, error) { if ds, err = daemonsets.Get(ctx, name, metav1.GetOptions{}); err != nil { return false, err } @@ -127,7 +127,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { for _, ds := range daemonsets.Items { ginkgo.By(fmt.Sprintf("Deleting DaemonSet %q", ds.Name)) framework.ExpectNoError(e2eresource.DeleteResourceAndWaitForGC(ctx, f.ClientSet, extensionsinternal.Kind("DaemonSet"), f.Namespace.Name, ds.Name)) - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkRunningOnNoNodes(f, &ds)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkRunningOnNoNodes(f, &ds)) framework.ExpectNoError(err, "error waiting for daemon pod to be reaped") } } @@ -182,7 +182,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { framework.ExpectNoError(err) ginkgo.By("Check that daemon pods launch on every node of the cluster.") - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkRunningOnAllNodes(f, ds)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkRunningOnAllNodes(f, ds)) framework.ExpectNoError(err, "error waiting for daemon pod to start") err = e2edaemonset.CheckDaemonStatus(ctx, f, dsName) framework.ExpectNoError(err) @@ -192,7 +192,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { pod := podList.Items[0] err = c.CoreV1().Pods(ns).Delete(ctx, pod.Name, metav1.DeleteOptions{}) framework.ExpectNoError(err) - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkRunningOnAllNodes(f, ds)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkRunningOnAllNodes(f, ds)) framework.ExpectNoError(err, "error waiting for daemon pod to revive") }) @@ -212,7 +212,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { framework.ExpectNoError(err) ginkgo.By("Initially, daemon pods should not be running on any nodes.") - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkRunningOnNoNodes(f, ds)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkRunningOnNoNodes(f, ds)) framework.ExpectNoError(err, "error waiting for daemon pods to be running on no nodes") ginkgo.By("Change node label to blue, check that daemon pod is launched.") @@ -222,7 +222,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { framework.ExpectNoError(err, "error setting labels on node") daemonSetLabels, _ := separateDaemonSetNodeLabels(newNode.Labels) gomega.Expect(daemonSetLabels).To(gomega.HaveLen(1)) - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, e2edaemonset.CheckDaemonPodOnNodes(f, ds, []string{newNode.Name})) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, e2edaemonset.CheckDaemonPodOnNodes(f, ds, []string{newNode.Name})) framework.ExpectNoError(err, "error waiting for daemon pods to be running on new nodes") err = e2edaemonset.CheckDaemonStatus(ctx, f, dsName) framework.ExpectNoError(err) @@ -231,7 +231,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { nodeSelector[daemonsetColorLabel] = "green" greenNode, err := setDaemonSetNodeLabels(ctx, c, node.Name, nodeSelector) framework.ExpectNoError(err, "error removing labels on node") - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkRunningOnNoNodes(f, ds)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkRunningOnNoNodes(f, ds)) framework.ExpectNoError(err, "error waiting for daemon pod to not be running on nodes") ginkgo.By("Update DaemonSet node selector to green, and change its update strategy to RollingUpdate") @@ -241,7 +241,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { framework.ExpectNoError(err, "error patching daemon set") daemonSetLabels, _ = separateDaemonSetNodeLabels(greenNode.Labels) gomega.Expect(daemonSetLabels).To(gomega.HaveLen(1)) - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, e2edaemonset.CheckDaemonPodOnNodes(f, ds, []string{greenNode.Name})) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, e2edaemonset.CheckDaemonPodOnNodes(f, ds, []string{greenNode.Name})) framework.ExpectNoError(err, "error waiting for daemon pods to be running on new nodes") err = e2edaemonset.CheckDaemonStatus(ctx, f, dsName) framework.ExpectNoError(err) @@ -275,7 +275,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { framework.ExpectNoError(err) ginkgo.By("Initially, daemon pods should not be running on any nodes.") - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkRunningOnNoNodes(f, ds)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkRunningOnNoNodes(f, ds)) framework.ExpectNoError(err, "error waiting for daemon pods to be running on no nodes") ginkgo.By("Change node label to blue, check that daemon pod is launched.") @@ -285,7 +285,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { framework.ExpectNoError(err, "error setting labels on node") daemonSetLabels, _ := separateDaemonSetNodeLabels(newNode.Labels) gomega.Expect(daemonSetLabels).To(gomega.HaveLen(1)) - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, e2edaemonset.CheckDaemonPodOnNodes(f, ds, []string{newNode.Name})) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, e2edaemonset.CheckDaemonPodOnNodes(f, ds, []string{newNode.Name})) framework.ExpectNoError(err, "error waiting for daemon pods to be running on new nodes") err = e2edaemonset.CheckDaemonStatus(ctx, f, dsName) framework.ExpectNoError(err) @@ -293,7 +293,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { ginkgo.By("Remove the node label and wait for daemons to be unscheduled") _, err = setDaemonSetNodeLabels(ctx, c, node.Name, map[string]string{}) framework.ExpectNoError(err, "error removing labels on node") - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkRunningOnNoNodes(f, ds)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkRunningOnNoNodes(f, ds)) framework.ExpectNoError(err, "error waiting for daemon pod to not be running on nodes") }) @@ -310,7 +310,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { framework.ExpectNoError(err) ginkgo.By("Check that daemon pods launch on every node of the cluster.") - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkRunningOnAllNodes(f, ds)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkRunningOnAllNodes(f, ds)) framework.ExpectNoError(err, "error waiting for daemon pod to start") err = e2edaemonset.CheckDaemonStatus(ctx, f, dsName) framework.ExpectNoError(err) @@ -322,11 +322,11 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { pod.Status.Phase = v1.PodFailed _, err = c.CoreV1().Pods(ns).UpdateStatus(ctx, &pod, metav1.UpdateOptions{}) framework.ExpectNoError(err, "error failing a daemon pod") - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkRunningOnAllNodes(f, ds)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkRunningOnAllNodes(f, ds)) framework.ExpectNoError(err, "error waiting for daemon pod to revive") ginkgo.By("Wait for the failed daemon pod to be completely deleted.") - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, waitFailedDaemonPodDeleted(c, &pod)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, waitFailedDaemonPodDeleted(c, &pod)) framework.ExpectNoError(err, "error waiting for the failed daemon pod to be completely deleted") }) @@ -342,7 +342,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { framework.ExpectNoError(err) ginkgo.By("Check that daemon pods launch on every node of the cluster.") - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkRunningOnAllNodes(f, ds)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkRunningOnAllNodes(f, ds)) framework.ExpectNoError(err, "error waiting for daemon pod to start") // Check history and labels @@ -360,11 +360,11 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { framework.ExpectNoError(err) ginkgo.By("Check that daemon pods images aren't updated.") - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkDaemonPodsImageAndAvailability(c, ds, image, 0)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkDaemonPodsImageAndAvailability(c, ds, image, 0)) framework.ExpectNoError(err) ginkgo.By("Check that daemon pods are still running on every node of the cluster.") - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkRunningOnAllNodes(f, ds)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkRunningOnAllNodes(f, ds)) framework.ExpectNoError(err, "error waiting for daemon pod to start") // Check history and labels @@ -392,7 +392,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { framework.ExpectNoError(err) ginkgo.By("Check that daemon pods launch on every node of the cluster.") - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkRunningOnAllNodes(f, ds)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkRunningOnAllNodes(f, ds)) framework.ExpectNoError(err, "error waiting for daemon pod to start") // Check history and labels @@ -417,11 +417,11 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { retryTimeout := dsRetryTimeout + time.Duration(nodeCount*30)*time.Second ginkgo.By("Check that daemon pods images are updated.") - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, retryTimeout, checkDaemonPodsImageAndAvailability(c, ds, AgnhostImage, 1)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, retryTimeout, true, checkDaemonPodsImageAndAvailability(c, ds, AgnhostImage, 1)) framework.ExpectNoError(err) ginkgo.By("Check that daemon pods are still running on every node of the cluster.") - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkRunningOnAllNodes(f, ds)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkRunningOnAllNodes(f, ds)) framework.ExpectNoError(err, "error waiting for daemon pod to start") // Check history and labels @@ -452,7 +452,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { framework.ExpectNoError(err) framework.Logf("Check that daemon pods launch on every node of the cluster") - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkRunningOnAllNodes(f, ds)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkRunningOnAllNodes(f, ds)) framework.ExpectNoError(err, "error waiting for daemon pod to start") framework.Logf("Update the DaemonSet to trigger a rollout") @@ -464,7 +464,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { framework.ExpectNoError(err) // Make sure we're in the middle of a rollout - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkAtLeastOneNewPod(c, ns, label, newImage)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkAtLeastOneNewPod(c, ns, label, newImage)) framework.ExpectNoError(err) pods := listDaemonPods(ctx, c, ns, label) @@ -497,7 +497,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { framework.ExpectNoError(err) framework.Logf("Make sure DaemonSet rollback is complete") - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkDaemonPodsImageAndAvailability(c, rollbackDS, image, 1)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkDaemonPodsImageAndAvailability(c, rollbackDS, image, 1)) framework.ExpectNoError(err) // After rollback is done, compare current pods with previous old pods during rollout, to make sure they're not restarted @@ -562,7 +562,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { framework.ExpectNoError(err) ginkgo.By("Check that daemon pods launch on every node of the cluster.") - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkRunningOnAllNodes(f, ds)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkRunningOnAllNodes(f, ds)) framework.ExpectNoError(err, "error waiting for daemon pod to start") // Check history and labels @@ -590,7 +590,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { ginkgo.By("Check that daemon pods surge and invariants are preserved during that rollout") ageOfOldPod := make(map[string]time.Time) deliberatelyDeletedPods := sets.NewString() - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, retryTimeout, func(ctx context.Context) (bool, error) { + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, retryTimeout, true, func(ctx context.Context) (bool, error) { podList, err := c.CoreV1().Pods(ds.Namespace).List(ctx, metav1.ListOptions{}) if err != nil { return false, err @@ -813,7 +813,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { framework.ExpectNoError(err) ginkgo.By("Check that daemon pods are still running on every node of the cluster.") - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkRunningOnAllNodes(f, ds)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkRunningOnAllNodes(f, ds)) framework.ExpectNoError(err, "error waiting for daemon pod to start") // Check history and labels @@ -846,7 +846,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { framework.ExpectNoError(err) ginkgo.By("Check that daemon pods launch on every node of the cluster.") - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkRunningOnAllNodes(f, testDaemonset)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkRunningOnAllNodes(f, testDaemonset)) framework.ExpectNoError(err, "error waiting for daemon pod to start") err = e2edaemonset.CheckDaemonStatus(ctx, f, dsName) framework.ExpectNoError(err) @@ -894,7 +894,7 @@ var _ = SIGDescribe("Daemon set [Serial]", func() { framework.ExpectNoError(err) ginkgo.By("Check that daemon pods launch on every node of the cluster.") - err = wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkRunningOnAllNodes(f, testDaemonset)) + err = wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkRunningOnAllNodes(f, testDaemonset)) framework.ExpectNoError(err, "error waiting for daemon pod to start") err = e2edaemonset.CheckDaemonStatus(ctx, f, dsName) framework.ExpectNoError(err) @@ -1097,7 +1097,7 @@ func setDaemonSetNodeLabels(ctx context.Context, c clientset.Interface, nodeName nodeClient := c.CoreV1().Nodes() var newNode *v1.Node var newLabels map[string]string - err := wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, func(ctx context.Context) (bool, error) { node, err := nodeClient.Get(ctx, nodeName, metav1.GetOptions{}) if err != nil { return false, err @@ -1226,7 +1226,7 @@ func waitForHistoryCreated(ctx context.Context, c clientset.Interface, ns string framework.Logf("%d/%d controllerrevisions created.", len(historyList.Items), numHistory) return false, nil } - err := wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, listHistoryFn) + err := wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, listHistoryFn) framework.ExpectNoError(err, "error waiting for controllerrevisions to be created") } diff --git a/test/e2e/apps/deployment.go b/test/e2e/apps/deployment.go index 51562e1764c..616d2b43c7c 100644 --- a/test/e2e/apps/deployment.go +++ b/test/e2e/apps/deployment.go @@ -1584,7 +1584,7 @@ func waitForDeploymentOldRSsNum(ctx context.Context, c clientset.Interface, ns, // waitForReplicaSetDesiredReplicas waits until the replicaset has desired number of replicas. func waitForReplicaSetDesiredReplicas(ctx context.Context, rsClient appsclient.ReplicaSetsGetter, replicaSet *appsv1.ReplicaSet) error { desiredGeneration := replicaSet.Generation - err := wait.PollImmediateWithContext(ctx, framework.Poll, framework.PollShortTimeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, framework.Poll, framework.PollShortTimeout, true, func(ctx context.Context) (bool, error) { rs, err := rsClient.ReplicaSets(replicaSet.Namespace).Get(ctx, replicaSet.Name, metav1.GetOptions{}) if err != nil { return false, err @@ -1600,7 +1600,7 @@ func waitForReplicaSetDesiredReplicas(ctx context.Context, rsClient appsclient.R // waitForReplicaSetTargetSpecReplicas waits for .spec.replicas of a RS to equal targetReplicaNum func waitForReplicaSetTargetSpecReplicas(ctx context.Context, c clientset.Interface, replicaSet *appsv1.ReplicaSet, targetReplicaNum int32) error { desiredGeneration := replicaSet.Generation - err := wait.PollImmediateWithContext(ctx, framework.Poll, framework.PollShortTimeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, framework.Poll, framework.PollShortTimeout, true, func(ctx context.Context) (bool, error) { rs, err := c.AppsV1().ReplicaSets(replicaSet.Namespace).Get(ctx, replicaSet.Name, metav1.GetOptions{}) if err != nil { return false, err diff --git a/test/e2e/apps/disruption.go b/test/e2e/apps/disruption.go index 77a211c93c1..a23f0d2f574 100644 --- a/test/e2e/apps/disruption.go +++ b/test/e2e/apps/disruption.go @@ -146,7 +146,7 @@ var _ = SIGDescribe("DisruptionController", func() { // Since disruptionAllowed starts out 0, if we see it ever become positive, // that means the controller is working. - err := wait.PollImmediateWithContext(ctx, framework.Poll, timeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, framework.Poll, timeout, true, func(ctx context.Context) (bool, error) { pdb, err := cs.PolicyV1().PodDisruptionBudgets(ns).Get(ctx, defaultName, metav1.GetOptions{}) if err != nil { return false, err @@ -329,7 +329,7 @@ var _ = SIGDescribe("DisruptionController", func() { // Since disruptionAllowed starts out false, if an eviction is ever allowed, // that means the controller is working. - err = wait.PollImmediateWithContext(ctx, framework.Poll, timeout, func(ctx context.Context) (bool, error) { + err = wait.PollUntilContextTimeout(ctx, framework.Poll, timeout, true, func(ctx context.Context) (bool, error) { err = cs.CoreV1().Pods(ns).EvictV1(ctx, e) if err != nil { return false, nil @@ -519,7 +519,7 @@ func deletePDBCollection(ctx context.Context, cs kubernetes.Interface, ns string func waitForPDBCollectionToBeDeleted(ctx context.Context, cs kubernetes.Interface, ns string) { ginkgo.By("Waiting for the PDB collection to be deleted") - err := wait.PollImmediateWithContext(ctx, framework.Poll, schedulingTimeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, framework.Poll, schedulingTimeout, true, func(ctx context.Context) (bool, error) { pdbList, err := cs.PolicyV1().PodDisruptionBudgets(ns).List(ctx, metav1.ListOptions{}) if err != nil { return false, err @@ -558,7 +558,7 @@ func createPodsOrDie(ctx context.Context, cs kubernetes.Interface, ns string, n func waitForPodsOrDie(ctx context.Context, cs kubernetes.Interface, ns string, n int) { ginkgo.By("Waiting for all pods to be running") - err := wait.PollImmediateWithContext(ctx, framework.Poll, schedulingTimeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, framework.Poll, schedulingTimeout, true, func(ctx context.Context) (bool, error) { pods, err := cs.CoreV1().Pods(ns).List(ctx, metav1.ListOptions{LabelSelector: "foo=bar"}) if err != nil { return false, err @@ -624,7 +624,7 @@ func createReplicaSetOrDie(ctx context.Context, cs kubernetes.Interface, ns stri func locateRunningPod(ctx context.Context, cs kubernetes.Interface, ns string) (pod *v1.Pod, err error) { ginkgo.By("locating a running pod") - err = wait.PollImmediateWithContext(ctx, framework.Poll, schedulingTimeout, func(ctx context.Context) (bool, error) { + err = wait.PollUntilContextTimeout(ctx, framework.Poll, schedulingTimeout, true, func(ctx context.Context) (bool, error) { podList, err := cs.CoreV1().Pods(ns).List(ctx, metav1.ListOptions{}) if err != nil { return false, err @@ -645,7 +645,7 @@ func locateRunningPod(ctx context.Context, cs kubernetes.Interface, ns string) ( func waitForPdbToBeProcessed(ctx context.Context, cs kubernetes.Interface, ns string, name string) { ginkgo.By("Waiting for the pdb to be processed") - err := wait.PollImmediateWithContext(ctx, framework.Poll, schedulingTimeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, framework.Poll, schedulingTimeout, true, func(ctx context.Context) (bool, error) { pdb, err := cs.PolicyV1().PodDisruptionBudgets(ns).Get(ctx, name, metav1.GetOptions{}) if err != nil { return false, err @@ -660,7 +660,7 @@ func waitForPdbToBeProcessed(ctx context.Context, cs kubernetes.Interface, ns st func waitForPdbToBeDeleted(ctx context.Context, cs kubernetes.Interface, ns string, name string) { ginkgo.By("Waiting for the pdb to be deleted") - err := wait.PollImmediateWithContext(ctx, framework.Poll, schedulingTimeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, framework.Poll, schedulingTimeout, true, func(ctx context.Context) (bool, error) { _, err := cs.PolicyV1().PodDisruptionBudgets(ns).Get(ctx, name, metav1.GetOptions{}) if apierrors.IsNotFound(err) { return true, nil // done @@ -675,7 +675,7 @@ func waitForPdbToBeDeleted(ctx context.Context, cs kubernetes.Interface, ns stri func waitForPdbToObserveHealthyPods(ctx context.Context, cs kubernetes.Interface, ns string, healthyCount int32) { ginkgo.By("Waiting for the pdb to observed all healthy pods") - err := wait.PollImmediateWithContext(ctx, framework.Poll, wait.ForeverTestTimeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, framework.Poll, wait.ForeverTestTimeout, true, func(ctx context.Context) (bool, error) { pdb, err := cs.PolicyV1().PodDisruptionBudgets(ns).Get(ctx, "foo", metav1.GetOptions{}) if err != nil { return false, err diff --git a/test/e2e/apps/rc.go b/test/e2e/apps/rc.go index 144478c6069..ac7af7a6c41 100644 --- a/test/e2e/apps/rc.go +++ b/test/e2e/apps/rc.go @@ -433,7 +433,7 @@ var _ = SIGDescribe("ReplicationController", func() { _, err := rcClient.Create(ctx, rc, metav1.CreateOptions{}) framework.ExpectNoError(err, "Failed to create ReplicationController: %v", err) - err = wait.PollImmediateWithContext(ctx, 1*time.Second, 1*time.Minute, checkReplicationControllerStatusReplicaCount(f, rcName, initialRCReplicaCount)) + err = wait.PollUntilContextTimeout(ctx, 1*time.Second, 1*time.Minute, true, checkReplicationControllerStatusReplicaCount(f, rcName, initialRCReplicaCount)) framework.ExpectNoError(err, "failed to confirm the quantity of ReplicationController replicas") ginkgo.By(fmt.Sprintf("Getting scale subresource for ReplicationController %q", rcName)) @@ -448,7 +448,7 @@ var _ = SIGDescribe("ReplicationController", func() { framework.ExpectNoError(err, "Failed to update scale subresource: %v", err) ginkgo.By(fmt.Sprintf("Verifying replicas where modified for replication controller %q", rcName)) - err = wait.PollImmediateWithContext(ctx, 1*time.Second, 1*time.Minute, checkReplicationControllerStatusReplicaCount(f, rcName, expectedRCReplicaCount)) + err = wait.PollUntilContextTimeout(ctx, 1*time.Second, 1*time.Minute, true, checkReplicationControllerStatusReplicaCount(f, rcName, expectedRCReplicaCount)) framework.ExpectNoError(err, "failed to confirm the quantity of ReplicationController replicas") }) }) diff --git a/test/e2e/apps/statefulset.go b/test/e2e/apps/statefulset.go index 79807414f36..0f6b1aba2ca 100644 --- a/test/e2e/apps/statefulset.go +++ b/test/e2e/apps/statefulset.go @@ -1826,7 +1826,7 @@ func lastLine(out string) string { } func pollReadWithTimeout(ctx context.Context, statefulPod statefulPodTester, statefulPodNumber int, key, expectedVal string) error { - err := wait.PollImmediateWithContext(ctx, time.Second, readTimeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, time.Second, readTimeout, true, func(ctx context.Context) (bool, error) { val := statefulPod.read(statefulPodNumber, key) if val == "" { return false, nil diff --git a/test/e2e/apps/ttl_after_finished.go b/test/e2e/apps/ttl_after_finished.go index 0c73cceb4d1..7c8a06963bd 100644 --- a/test/e2e/apps/ttl_after_finished.go +++ b/test/e2e/apps/ttl_after_finished.go @@ -126,7 +126,7 @@ func finishTime(finishedJob *batchv1.Job) metav1.Time { func updateJobWithRetries(ctx context.Context, c clientset.Interface, namespace, name string, applyUpdate func(*batchv1.Job)) (job *batchv1.Job, err error) { jobs := c.BatchV1().Jobs(namespace) var updateErr error - pollErr := wait.PollImmediateWithContext(ctx, framework.Poll, JobTimeout, func(ctx context.Context) (bool, error) { + pollErr := wait.PollUntilContextTimeout(ctx, framework.Poll, JobTimeout, true, func(ctx context.Context) (bool, error) { if job, err = jobs.Get(ctx, name, metav1.GetOptions{}); err != nil { return false, err } @@ -148,7 +148,7 @@ func updateJobWithRetries(ctx context.Context, c clientset.Interface, namespace, // waitForJobDeleting uses c to wait for the Job jobName in namespace ns to have // a non-nil deletionTimestamp (i.e. being deleted). func waitForJobDeleting(ctx context.Context, c clientset.Interface, ns, jobName string) error { - return wait.PollImmediateWithContext(ctx, framework.Poll, JobTimeout, func(ctx context.Context) (bool, error) { + return wait.PollUntilContextTimeout(ctx, framework.Poll, JobTimeout, true, func(ctx context.Context) (bool, error) { curr, err := c.BatchV1().Jobs(ns).Get(ctx, jobName, metav1.GetOptions{}) if err != nil { return false, err diff --git a/test/e2e/autoscaling/cluster_size_autoscaling.go b/test/e2e/autoscaling/cluster_size_autoscaling.go index 40941877689..f8a830bfd95 100644 --- a/test/e2e/autoscaling/cluster_size_autoscaling.go +++ b/test/e2e/autoscaling/cluster_size_autoscaling.go @@ -1859,7 +1859,7 @@ func getScaleUpStatus(ctx context.Context, c clientset.Interface) (*scaleUpStatu func waitForScaleUpStatus(ctx context.Context, c clientset.Interface, cond func(s *scaleUpStatus) bool, timeout time.Duration) (*scaleUpStatus, error) { var finalErr error var status *scaleUpStatus - err := wait.PollImmediateWithContext(ctx, 5*time.Second, timeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, 5*time.Second, timeout, true, func(ctx context.Context) (bool, error) { status, finalErr = getScaleUpStatus(ctx, c) if finalErr != nil { return false, nil diff --git a/test/e2e/autoscaling/custom_metrics_stackdriver_autoscaling.go b/test/e2e/autoscaling/custom_metrics_stackdriver_autoscaling.go index d0b3fbfe1c1..4840a4fad7b 100644 --- a/test/e2e/autoscaling/custom_metrics_stackdriver_autoscaling.go +++ b/test/e2e/autoscaling/custom_metrics_stackdriver_autoscaling.go @@ -594,7 +594,7 @@ func hpa(name, namespace, deploymentName string, minReplicas, maxReplicas int32, func waitForReplicas(ctx context.Context, deploymentName, namespace string, cs clientset.Interface, timeout time.Duration, desiredReplicas int) { interval := 20 * time.Second - err := wait.PollImmediateWithContext(ctx, interval, timeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, interval, timeout, true, func(ctx context.Context) (bool, error) { deployment, err := cs.AppsV1().Deployments(namespace).Get(ctx, deploymentName, metav1.GetOptions{}) if err != nil { framework.Failf("Failed to get replication controller %s: %v", deployment, err) @@ -610,7 +610,7 @@ func waitForReplicas(ctx context.Context, deploymentName, namespace string, cs c func ensureDesiredReplicasInRange(ctx context.Context, deploymentName, namespace string, cs clientset.Interface, minDesiredReplicas, maxDesiredReplicas int, timeout time.Duration) { interval := 60 * time.Second - err := wait.PollImmediateWithContext(ctx, interval, timeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, interval, timeout, true, func(ctx context.Context) (bool, error) { deployment, err := cs.AppsV1().Deployments(namespace).Get(ctx, deploymentName, metav1.GetOptions{}) if err != nil { framework.Failf("Failed to get replication controller %s: %v", deployment, err) diff --git a/test/e2e/cloud/gcp/common/upgrade_mechanics.go b/test/e2e/cloud/gcp/common/upgrade_mechanics.go index cc4a3db3f11..75ff89ec09a 100644 --- a/test/e2e/cloud/gcp/common/upgrade_mechanics.go +++ b/test/e2e/cloud/gcp/common/upgrade_mechanics.go @@ -122,7 +122,7 @@ func checkControlPlaneVersion(ctx context.Context, c clientset.Interface, want s framework.Logf("Checking control plane version") var err error var v *version.Info - waitErr := wait.PollImmediateWithContext(ctx, 5*time.Second, 2*time.Minute, func(ctx context.Context) (bool, error) { + waitErr := wait.PollUntilContextTimeout(ctx, 5*time.Second, 2*time.Minute, true, func(ctx context.Context) (bool, error) { v, err = c.Discovery().ServerVersion() if err != nil { traceRouteToControlPlane() diff --git a/test/e2e/common/node/pods.go b/test/e2e/common/node/pods.go index f0620832a22..da6289061a9 100644 --- a/test/e2e/common/node/pods.go +++ b/test/e2e/common/node/pods.go @@ -883,7 +883,7 @@ var _ = SIGDescribe("Pods", func() { // wait for all pods to be deleted ginkgo.By("waiting for all pods to be deleted") - err = wait.PollImmediateWithContext(ctx, podRetryPeriod, f.Timeouts.PodDelete, checkPodListQuantity(f, "type=Testing", 0)) + err = wait.PollUntilContextTimeout(ctx, podRetryPeriod, f.Timeouts.PodDelete, true, checkPodListQuantity(f, "type=Testing", 0)) framework.ExpectNoError(err, "found a pod(s)") }) diff --git a/test/e2e/e2e.go b/test/e2e/e2e.go index 8ef5b337454..c069aac9a50 100644 --- a/test/e2e/e2e.go +++ b/test/e2e/e2e.go @@ -150,7 +150,7 @@ func waitForDaemonSets(ctx context.Context, c clientset.Interface, ns string, al framework.Logf("Waiting up to %v for all daemonsets in namespace '%s' to start", timeout, ns) - return wait.PollImmediateWithContext(ctx, framework.Poll, timeout, func(ctx context.Context) (bool, error) { + return wait.PollUntilContextTimeout(ctx, framework.Poll, timeout, true, func(ctx context.Context) (bool, error) { dsList, err := c.AppsV1().DaemonSets(ns).List(ctx, metav1.ListOptions{}) if err != nil { framework.Logf("Error getting daemonsets in namespace: '%s': %v", ns, err) @@ -429,7 +429,7 @@ func prepullImages(ctx context.Context, c clientset.Interface) { return daemonset.CheckPresentOnNodes(ctx, c, imgPuller, ns, framework.TestContext.CloudConfig.NumNodes) } framework.Logf("Waiting for %s", imgPuller.Name) - err := wait.PollImmediateWithContext(ctx, dsRetryPeriod, dsRetryTimeout, checkDaemonset) + err := wait.PollUntilContextTimeout(ctx, dsRetryPeriod, dsRetryTimeout, true, checkDaemonset) framework.ExpectNoError(err, "error waiting for image to be pulled") } } diff --git a/test/e2e/framework/autoscaling/autoscaling_utils.go b/test/e2e/framework/autoscaling/autoscaling_utils.go index 886acb25c92..30b06e88e29 100644 --- a/test/e2e/framework/autoscaling/autoscaling_utils.go +++ b/test/e2e/framework/autoscaling/autoscaling_utils.go @@ -495,7 +495,7 @@ func (rc *ResourceConsumer) GetHpa(ctx context.Context, name string) (*autoscali // WaitForReplicas wait for the desired replicas func (rc *ResourceConsumer) WaitForReplicas(ctx context.Context, desiredReplicas int, duration time.Duration) { interval := 20 * time.Second - err := wait.PollImmediateWithContext(ctx, interval, duration, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, interval, duration, true, func(ctx context.Context) (bool, error) { replicas := rc.GetReplicas(ctx) framework.Logf("waiting for %d replicas (current: %d)", desiredReplicas, replicas) return replicas == desiredReplicas, nil // Expected number of replicas found. Exit. @@ -506,7 +506,7 @@ func (rc *ResourceConsumer) WaitForReplicas(ctx context.Context, desiredReplicas // EnsureDesiredReplicasInRange ensure the replicas is in a desired range func (rc *ResourceConsumer) EnsureDesiredReplicasInRange(ctx context.Context, minDesiredReplicas, maxDesiredReplicas int, duration time.Duration, hpaName string) { interval := 10 * time.Second - err := wait.PollImmediateWithContext(ctx, interval, duration, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, interval, duration, true, func(ctx context.Context) (bool, error) { replicas := rc.GetReplicas(ctx) framework.Logf("expecting there to be in [%d, %d] replicas (are: %d)", minDesiredReplicas, maxDesiredReplicas, replicas) as, err := rc.GetHpa(ctx, hpaName) @@ -964,7 +964,7 @@ func CreateCustomResourceDefinition(ctx context.Context, c crdclientset.Interfac crd, err = c.ApiextensionsV1().CustomResourceDefinitions().Create(ctx, crdSchema, metav1.CreateOptions{}) framework.ExpectNoError(err) // Wait until just created CRD appears in discovery. - err = wait.PollImmediateWithContext(ctx, 500*time.Millisecond, 30*time.Second, func(ctx context.Context) (bool, error) { + err = wait.PollUntilContextTimeout(ctx, 500*time.Millisecond, 30*time.Second, true, func(ctx context.Context) (bool, error) { return ExistsInDiscovery(crd, c, "v1") }) framework.ExpectNoError(err) diff --git a/test/e2e/framework/events/events.go b/test/e2e/framework/events/events.go index b38c4a1eea8..1ad19b455a8 100644 --- a/test/e2e/framework/events/events.go +++ b/test/e2e/framework/events/events.go @@ -34,7 +34,7 @@ type Action func() error // Please note delivery of events is not guaranteed. Asserting on events can lead to flaky tests. func WaitTimeoutForEvent(ctx context.Context, c clientset.Interface, namespace, eventSelector, msg string, timeout time.Duration) error { interval := 2 * time.Second - return wait.PollImmediateWithContext(ctx, interval, timeout, eventOccurred(c, namespace, eventSelector, msg)) + return wait.PollUntilContextTimeout(ctx, interval, timeout, true, eventOccurred(c, namespace, eventSelector, msg)) } func eventOccurred(c clientset.Interface, namespace, eventSelector, msg string) wait.ConditionWithContextFunc { diff --git a/test/e2e/framework/ingress/ingress_utils.go b/test/e2e/framework/ingress/ingress_utils.go index 908f4cbbabf..0275848cacc 100644 --- a/test/e2e/framework/ingress/ingress_utils.go +++ b/test/e2e/framework/ingress/ingress_utils.go @@ -196,7 +196,7 @@ func SimpleGET(ctx context.Context, c *http.Client, url, host string) (string, e // expectUnreachable is true, it breaks on first non-healthy http code instead. func PollURL(ctx context.Context, route, host string, timeout time.Duration, interval time.Duration, httpClient *http.Client, expectUnreachable bool) error { var lastBody string - pollErr := wait.PollImmediateWithContext(ctx, interval, timeout, func(ctx context.Context) (bool, error) { + pollErr := wait.PollUntilContextTimeout(ctx, interval, timeout, true, func(ctx context.Context) (bool, error) { var err error lastBody, err = SimpleGET(ctx, httpClient, route, host) if err != nil { @@ -733,7 +733,7 @@ func getIngressAddress(ctx context.Context, client clientset.Interface, ns, name // WaitForIngressAddress waits for the Ingress to acquire an address. func (j *TestJig) WaitForIngressAddress(ctx context.Context, c clientset.Interface, ns, ingName string, timeout time.Duration) (string, error) { var address string - err := wait.PollImmediateWithContext(ctx, 10*time.Second, timeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, 10*time.Second, timeout, true, func(ctx context.Context) (bool, error) { ipOrNameList, err := getIngressAddress(ctx, c, ns, ingName, j.Class) if err != nil || len(ipOrNameList) == 0 { j.Logger.Errorf("Waiting for Ingress %s/%s to acquire IP, error: %v, ipOrNameList: %v", ns, ingName, err, ipOrNameList) @@ -889,7 +889,7 @@ func getPortURL(ctx context.Context, client clientset.Interface, ns, name string // unschedulable, since control plane nodes don't run kube-proxy. Without // kube-proxy NodePorts won't work. var nodes *v1.NodeList - if wait.PollImmediateWithContext(ctx, poll, framework.SingleCallTimeout, func(ctx context.Context) (bool, error) { + if wait.PollUntilContextTimeout(ctx, poll, framework.SingleCallTimeout, true, func(ctx context.Context) (bool, error) { nodes, err = client.CoreV1().Nodes().List(ctx, metav1.ListOptions{FieldSelector: fields.Set{ "spec.unschedulable": "false", }.AsSelector().String()}) diff --git a/test/e2e/framework/job/wait.go b/test/e2e/framework/job/wait.go index 3f94dc03182..31daead98fc 100644 --- a/test/e2e/framework/job/wait.go +++ b/test/e2e/framework/job/wait.go @@ -91,7 +91,7 @@ func isJobFailed(j *batchv1.Job) bool { // WaitForJobFinish uses c to wait for the Job jobName in namespace ns to finish (either Failed or Complete). func WaitForJobFinish(ctx context.Context, c clientset.Interface, ns, jobName string) error { - return wait.PollImmediateWithContext(ctx, framework.Poll, JobTimeout, func(ctx context.Context) (bool, error) { + return wait.PollUntilContextTimeout(ctx, framework.Poll, JobTimeout, true, func(ctx context.Context) (bool, error) { curr, err := c.BatchV1().Jobs(ns).Get(ctx, jobName, metav1.GetOptions{}) if err != nil { return false, err @@ -125,7 +125,7 @@ func WaitForJobGone(ctx context.Context, c clientset.Interface, ns, jobName stri // WaitForAllJobPodsGone waits for all pods for the Job named jobName in namespace ns // to be deleted. func WaitForAllJobPodsGone(ctx context.Context, c clientset.Interface, ns, jobName string) error { - return wait.PollImmediateWithContext(ctx, framework.Poll, JobTimeout, func(ctx context.Context) (bool, error) { + return wait.PollUntilContextTimeout(ctx, framework.Poll, JobTimeout, true, func(ctx context.Context) (bool, error) { pods, err := GetJobPods(ctx, c, ns, jobName) if err != nil { return false, err diff --git a/test/e2e/framework/metrics/metrics_grabber.go b/test/e2e/framework/metrics/metrics_grabber.go index 227b6ff1eb3..76864526887 100644 --- a/test/e2e/framework/metrics/metrics_grabber.go +++ b/test/e2e/framework/metrics/metrics_grabber.go @@ -252,7 +252,7 @@ func (g *Grabber) GrabFromScheduler(ctx context.Context) (SchedulerMetrics, erro var lastMetricsFetchErr error var output string - if metricsWaitErr := wait.PollImmediateWithContext(ctx, time.Second, time.Minute, func(ctx context.Context) (bool, error) { + if metricsWaitErr := wait.PollUntilContextTimeout(ctx, time.Second, time.Minute, true, func(ctx context.Context) (bool, error) { output, lastMetricsFetchErr = g.getSecureMetricsFromPod(ctx, g.kubeScheduler, metav1.NamespaceSystem, kubeSchedulerPort) return lastMetricsFetchErr == nil, nil }); metricsWaitErr != nil { @@ -303,7 +303,7 @@ func (g *Grabber) GrabFromControllerManager(ctx context.Context) (ControllerMana var output string var lastMetricsFetchErr error - if metricsWaitErr := wait.PollImmediateWithContext(ctx, time.Second, time.Minute, func(ctx context.Context) (bool, error) { + if metricsWaitErr := wait.PollUntilContextTimeout(ctx, time.Second, time.Minute, true, func(ctx context.Context) (bool, error) { output, lastMetricsFetchErr = g.getSecureMetricsFromPod(ctx, g.kubeControllerManager, metav1.NamespaceSystem, kubeControllerManagerPort) return lastMetricsFetchErr == nil, nil }); metricsWaitErr != nil { @@ -342,7 +342,7 @@ func (g *Grabber) GrabFromSnapshotController(ctx context.Context, podName string var output string var lastMetricsFetchErr error - if metricsWaitErr := wait.PollImmediateWithContext(ctx, time.Second, time.Minute, func(ctx context.Context) (bool, error) { + if metricsWaitErr := wait.PollUntilContextTimeout(ctx, time.Second, time.Minute, true, func(ctx context.Context) (bool, error) { output, lastMetricsFetchErr = g.getMetricsFromPod(ctx, g.client, podName, metav1.NamespaceSystem, port) return lastMetricsFetchErr == nil, nil }); metricsWaitErr != nil { diff --git a/test/e2e/framework/network/utils.go b/test/e2e/framework/network/utils.go index 914218f9ef2..99f53d53a14 100644 --- a/test/e2e/framework/network/utils.go +++ b/test/e2e/framework/network/utils.go @@ -526,7 +526,7 @@ func (config *NetworkingTestConfig) executeCurlCmd(ctx context.Context, cmd stri const retryTimeout = 30 * time.Second podName := config.HostTestContainerPod.Name var msg string - if pollErr := wait.PollImmediateWithContext(ctx, retryInterval, retryTimeout, func(ctx context.Context) (bool, error) { + if pollErr := wait.PollUntilContextTimeout(ctx, retryInterval, retryTimeout, true, func(ctx context.Context) (bool, error) { stdout, err := e2epodoutput.RunHostCmd(config.Namespace, podName, cmd) if err != nil { msg = fmt.Sprintf("failed executing cmd %v in %v/%v: %v", cmd, config.Namespace, podName, err) @@ -1172,7 +1172,7 @@ func UnblockNetwork(ctx context.Context, from string, to string) { // WaitForService waits until the service appears (exist == true), or disappears (exist == false) func WaitForService(ctx context.Context, c clientset.Interface, namespace, name string, exist bool, interval, timeout time.Duration) error { - err := wait.PollImmediateWithContext(ctx, interval, timeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, interval, timeout, true, func(ctx context.Context) (bool, error) { _, err := c.CoreV1().Services(namespace).Get(ctx, name, metav1.GetOptions{}) switch { case err == nil: diff --git a/test/e2e/framework/node/helper.go b/test/e2e/framework/node/helper.go index 82dd73a6572..f473d4ffa76 100644 --- a/test/e2e/framework/node/helper.go +++ b/test/e2e/framework/node/helper.go @@ -121,7 +121,7 @@ func allNodesReady(ctx context.Context, c clientset.Interface, timeout time.Dura framework.Logf("Waiting up to %v for all (but %d) nodes to be ready", timeout, framework.TestContext.AllowedNotReadyNodes) var notReady []*v1.Node - err := wait.PollImmediateWithContext(ctx, framework.Poll, timeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, framework.Poll, timeout, true, func(ctx context.Context) (bool, error) { notReady = nil // It should be OK to list unschedulable Nodes here. nodes, err := c.CoreV1().Nodes().List(ctx, metav1.ListOptions{}) diff --git a/test/e2e/framework/node/ssh.go b/test/e2e/framework/node/ssh.go index 2e0b02c0fe3..cb7dc573d20 100644 --- a/test/e2e/framework/node/ssh.go +++ b/test/e2e/framework/node/ssh.go @@ -36,7 +36,7 @@ func WaitForSSHTunnels(ctx context.Context, namespace string) { defer e2ekubectl.RunKubectl(namespace, "delete", "pod", "ssh-tunnel-test") // allow up to a minute for new ssh tunnels to establish - wait.PollImmediateWithContext(ctx, 5*time.Second, time.Minute, func(ctx context.Context) (bool, error) { + wait.PollUntilContextTimeout(ctx, 5*time.Second, time.Minute, true, func(ctx context.Context) (bool, error) { _, err := e2ekubectl.RunKubectl(namespace, "logs", "ssh-tunnel-test") return err == nil, nil }) diff --git a/test/e2e/framework/node/wait.go b/test/e2e/framework/node/wait.go index 91aaec4efe4..d87e59b3db5 100644 --- a/test/e2e/framework/node/wait.go +++ b/test/e2e/framework/node/wait.go @@ -51,7 +51,7 @@ func WaitForTotalHealthy(ctx context.Context, c clientset.Interface, timeout tim var notReady []v1.Node var missingPodsPerNode map[string][]string - err := wait.PollImmediateWithContext(ctx, poll, timeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, poll, timeout, true, func(ctx context.Context) (bool, error) { notReady = nil // It should be OK to list unschedulable Nodes here. nodes, err := c.CoreV1().Nodes().List(ctx, metav1.ListOptions{ResourceVersion: "0"}) @@ -192,7 +192,7 @@ func CheckReady(ctx context.Context, c clientset.Interface, size int, timeout ti func waitListSchedulableNodes(ctx context.Context, c clientset.Interface) (*v1.NodeList, error) { var nodes *v1.NodeList var err error - if wait.PollImmediateWithContext(ctx, poll, singleCallTimeout, func(ctx context.Context) (bool, error) { + if wait.PollUntilContextTimeout(ctx, poll, singleCallTimeout, true, func(ctx context.Context) (bool, error) { nodes, err = c.CoreV1().Nodes().List(ctx, metav1.ListOptions{FieldSelector: fields.Set{ "spec.unschedulable": "false", }.AsSelector().String()}) diff --git a/test/e2e/framework/providers/gce/firewall.go b/test/e2e/framework/providers/gce/firewall.go index 8beb1c8518b..411308946e4 100644 --- a/test/e2e/framework/providers/gce/firewall.go +++ b/test/e2e/framework/providers/gce/firewall.go @@ -251,7 +251,7 @@ func WaitForFirewallRule(ctx context.Context, gceCloud *gcecloud.Cloud, fwName s return true, nil } - if err := wait.PollImmediateWithContext(ctx, 5*time.Second, timeout, condition); err != nil { + if err := wait.PollUntilContextTimeout(ctx, 5*time.Second, timeout, true, condition); err != nil { return nil, fmt.Errorf("error waiting for firewall %v exist=%v", fwName, exist) } return fw, nil diff --git a/test/e2e/framework/pv/pv.go b/test/e2e/framework/pv/pv.go index 469688d3496..3c43c20e07d 100644 --- a/test/e2e/framework/pv/pv.go +++ b/test/e2e/framework/pv/pv.go @@ -297,7 +297,7 @@ func DeletePVCandValidatePVGroup(ctx context.Context, c clientset.Interface, tim func createPV(ctx context.Context, c clientset.Interface, timeouts *framework.TimeoutContext, pv *v1.PersistentVolume) (*v1.PersistentVolume, error) { var resultPV *v1.PersistentVolume var lastCreateErr error - err := wait.PollImmediateWithContext(ctx, 29*time.Second, timeouts.PVCreate, func(ctx context.Context) (done bool, err error) { + err := wait.PollUntilContextTimeout(ctx, 29*time.Second, timeouts.PVCreate, true, func(ctx context.Context) (done bool, err error) { resultPV, lastCreateErr = c.CoreV1().PersistentVolumes().Create(ctx, pv, metav1.CreateOptions{}) if lastCreateErr != nil { // If we hit a quota problem, we are not done and should retry again. This happens to be the quota failure string for GCP. diff --git a/test/e2e/framework/replicaset/wait.go b/test/e2e/framework/replicaset/wait.go index 49719c27f37..c1d2a4f53ba 100644 --- a/test/e2e/framework/replicaset/wait.go +++ b/test/e2e/framework/replicaset/wait.go @@ -52,7 +52,7 @@ func WaitForReplicaSetTargetAvailableReplicas(ctx context.Context, c clientset.I // with given timeout. func WaitForReplicaSetTargetAvailableReplicasWithTimeout(ctx context.Context, c clientset.Interface, replicaSet *appsv1.ReplicaSet, targetReplicaNum int32, timeout time.Duration) error { desiredGeneration := replicaSet.Generation - err := wait.PollImmediateWithContext(ctx, framework.Poll, timeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, framework.Poll, timeout, true, func(ctx context.Context) (bool, error) { rs, err := c.AppsV1().ReplicaSets(replicaSet.Namespace).Get(ctx, replicaSet.Name, metav1.GetOptions{}) if err != nil { return false, err diff --git a/test/e2e/framework/resource/resources.go b/test/e2e/framework/resource/resources.go index 9957aec2785..99462f89a49 100644 --- a/test/e2e/framework/resource/resources.go +++ b/test/e2e/framework/resource/resources.go @@ -175,7 +175,7 @@ func deleteObjectAndWaitForGC(ctx context.Context, c clientset.Interface, rtObje // waitForPodsGone waits until there are no pods left in the PodStore. func waitForPodsGone(ctx context.Context, ps *testutils.PodStore, interval, timeout time.Duration) error { var pods []*v1.Pod - err := wait.PollImmediateWithContext(ctx, interval, timeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, interval, timeout, true, func(ctx context.Context) (bool, error) { if pods = ps.List(); len(pods) == 0 { return true, nil } @@ -197,7 +197,7 @@ func waitForPodsGone(ctx context.Context, ps *testutils.PodStore, interval, time // when the pod is inactvie. func waitForPodsInactive(ctx context.Context, ps *testutils.PodStore, interval, timeout time.Duration) error { var activePods []*v1.Pod - err := wait.PollImmediateWithContext(ctx, interval, timeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, interval, timeout, true, func(ctx context.Context) (bool, error) { pods := ps.List() activePods = e2epod.FilterActivePods(pods) if len(activePods) != 0 { diff --git a/test/e2e/framework/service/jig.go b/test/e2e/framework/service/jig.go index 27c2db54ffa..d6b5d7079dd 100644 --- a/test/e2e/framework/service/jig.go +++ b/test/e2e/framework/service/jig.go @@ -328,7 +328,7 @@ func (j *TestJig) GetEndpointNodeNames(ctx context.Context) (sets.String, error) // WaitForEndpointOnNode waits for a service endpoint on the given node. func (j *TestJig) WaitForEndpointOnNode(ctx context.Context, nodeName string) error { - return wait.PollImmediateWithContext(ctx, framework.Poll, KubeProxyLagTimeout, func(ctx context.Context) (bool, error) { + return wait.PollUntilContextTimeout(ctx, framework.Poll, KubeProxyLagTimeout, true, func(ctx context.Context) (bool, error) { endpoints, err := j.Client.CoreV1().Endpoints(j.Namespace).Get(ctx, j.Name, metav1.GetOptions{}) if err != nil { framework.Logf("Get endpoints for service %s/%s failed (%s)", j.Namespace, j.Name, err) @@ -627,7 +627,7 @@ func (j *TestJig) waitForCondition(ctx context.Context, timeout time.Duration, m } return false, nil } - if err := wait.PollImmediateWithContext(ctx, framework.Poll, timeout, pollFunc); err != nil { + if err := wait.PollUntilContextTimeout(ctx, framework.Poll, timeout, true, pollFunc); err != nil { return nil, fmt.Errorf("timed out waiting for service %q to %s: %w", j.Name, message, err) } return service, nil @@ -910,7 +910,7 @@ func testEndpointReachability(ctx context.Context, endpoint string, port int32, return fmt.Errorf("service reachability check is not supported for %v", protocol) } - err := wait.PollImmediateWithContext(ctx, 1*time.Second, ServiceReachabilityShortPollTimeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, 1*time.Second, ServiceReachabilityShortPollTimeout, true, func(ctx context.Context) (bool, error) { stdout, err := e2epodoutput.RunHostCmd(execPod.Namespace, execPod.Name, cmd) if err != nil { framework.Logf("Service reachability failing with error: %v\nRetrying...", err) @@ -1006,7 +1006,7 @@ func (j *TestJig) checkExternalServiceReachability(ctx context.Context, svc *v1. svcName := fmt.Sprintf("%s.%s.svc.%s", svc.Name, svc.Namespace, framework.TestContext.ClusterDNSDomain) // Service must resolve to IP cmd := fmt.Sprintf("nslookup %s", svcName) - return wait.PollImmediateWithContext(ctx, framework.Poll, ServiceReachabilityShortPollTimeout, func(ctx context.Context) (done bool, err error) { + return wait.PollUntilContextTimeout(ctx, framework.Poll, ServiceReachabilityShortPollTimeout, true, func(ctx context.Context) (done bool, err error) { _, stderr, err := e2epodoutput.RunHostCmdWithFullOutput(pod.Namespace, pod.Name, cmd) // NOTE(claudiub): nslookup may return 0 on Windows, even though the DNS name was not found. In this case, // we can check stderr for the error. diff --git a/test/e2e/framework/service/util.go b/test/e2e/framework/service/util.go index 72007ad5908..bc538e51089 100644 --- a/test/e2e/framework/service/util.go +++ b/test/e2e/framework/service/util.go @@ -44,7 +44,7 @@ func TestReachableHTTPWithRetriableErrorCodes(ctx context.Context, host string, return false, nil // caller can retry } - if err := wait.PollImmediateWithContext(ctx, framework.Poll, timeout, pollfn); err != nil { + if err := wait.PollUntilContextTimeout(ctx, framework.Poll, timeout, true, pollfn); err != nil { if wait.Interrupted(err) { framework.Failf("Could not reach HTTP service through %v:%v after %v", host, port, timeout) } else { diff --git a/test/e2e/framework/service/wait.go b/test/e2e/framework/service/wait.go index 577acf251fa..21e4027143f 100644 --- a/test/e2e/framework/service/wait.go +++ b/test/e2e/framework/service/wait.go @@ -38,7 +38,7 @@ func WaitForServiceDeletedWithFinalizer(ctx context.Context, cs clientset.Interf } ginkgo.By("Wait for service to disappear") - if pollErr := wait.PollImmediateWithContext(ctx, LoadBalancerPollInterval, GetServiceLoadBalancerCreationTimeout(ctx, cs), func(ctx context.Context) (bool, error) { + if pollErr := wait.PollUntilContextTimeout(ctx, LoadBalancerPollInterval, GetServiceLoadBalancerCreationTimeout(ctx, cs), true, func(ctx context.Context) (bool, error) { svc, err := cs.CoreV1().Services(namespace).Get(ctx, name, metav1.GetOptions{}) if err != nil { if apierrors.IsNotFound(err) { @@ -58,7 +58,7 @@ func WaitForServiceDeletedWithFinalizer(ctx context.Context, cs clientset.Interf // don't have a finalizer. func WaitForServiceUpdatedWithFinalizer(ctx context.Context, cs clientset.Interface, namespace, name string, hasFinalizer bool) { ginkgo.By(fmt.Sprintf("Wait for service to hasFinalizer=%t", hasFinalizer)) - if pollErr := wait.PollImmediateWithContext(ctx, LoadBalancerPollInterval, GetServiceLoadBalancerCreationTimeout(ctx, cs), func(ctx context.Context) (bool, error) { + if pollErr := wait.PollUntilContextTimeout(ctx, LoadBalancerPollInterval, GetServiceLoadBalancerCreationTimeout(ctx, cs), true, func(ctx context.Context) (bool, error) { svc, err := cs.CoreV1().Services(namespace).Get(ctx, name, metav1.GetOptions{}) if err != nil { return false, err diff --git a/test/e2e/framework/ssh/ssh.go b/test/e2e/framework/ssh/ssh.go index 5624b3e4a6b..b10456bf63d 100644 --- a/test/e2e/framework/ssh/ssh.go +++ b/test/e2e/framework/ssh/ssh.go @@ -422,7 +422,7 @@ func nodeAddresses(nodelist *v1.NodeList, addrType v1.NodeAddressType) []string func waitListSchedulableNodes(ctx context.Context, c clientset.Interface) (*v1.NodeList, error) { var nodes *v1.NodeList var err error - if wait.PollImmediateWithContext(ctx, pollNodeInterval, singleCallTimeout, func(ctx context.Context) (bool, error) { + if wait.PollUntilContextTimeout(ctx, pollNodeInterval, singleCallTimeout, true, func(ctx context.Context) (bool, error) { nodes, err = c.CoreV1().Nodes().List(ctx, metav1.ListOptions{FieldSelector: fields.Set{ "spec.unschedulable": "false", }.AsSelector().String()}) diff --git a/test/e2e/framework/statefulset/rest.go b/test/e2e/framework/statefulset/rest.go index 7c0c08b03f1..5047d86c6a1 100644 --- a/test/e2e/framework/statefulset/rest.go +++ b/test/e2e/framework/statefulset/rest.go @@ -96,7 +96,7 @@ func DeleteAllStatefulSets(ctx context.Context, c clientset.Interface, ns string // pvs are global, so we need to wait for the exact ones bound to the statefulset pvcs. pvNames := sets.NewString() // TODO: Don't assume all pvcs in the ns belong to a statefulset - pvcPollErr := wait.PollImmediateWithContext(ctx, StatefulSetPoll, StatefulSetTimeout, func(ctx context.Context) (bool, error) { + pvcPollErr := wait.PollUntilContextTimeout(ctx, StatefulSetPoll, StatefulSetTimeout, true, func(ctx context.Context) (bool, error) { pvcList, err := c.CoreV1().PersistentVolumeClaims(ns).List(ctx, metav1.ListOptions{LabelSelector: labels.Everything().String()}) if err != nil { framework.Logf("WARNING: Failed to list pvcs, retrying %v", err) @@ -116,7 +116,7 @@ func DeleteAllStatefulSets(ctx context.Context, c clientset.Interface, ns string errList = append(errList, fmt.Sprintf("Timeout waiting for pvc deletion.")) } - pollErr := wait.PollImmediateWithContext(ctx, StatefulSetPoll, StatefulSetTimeout, func(ctx context.Context) (bool, error) { + pollErr := wait.PollUntilContextTimeout(ctx, StatefulSetPoll, StatefulSetTimeout, true, func(ctx context.Context) (bool, error) { pvList, err := c.CoreV1().PersistentVolumes().List(ctx, metav1.ListOptions{LabelSelector: labels.Everything().String()}) if err != nil { framework.Logf("WARNING: Failed to list pvs, retrying %v", err) @@ -151,7 +151,7 @@ func Scale(ctx context.Context, c clientset.Interface, ss *appsv1.StatefulSet, c ss = update(ctx, c, ns, name, count) var statefulPodList *v1.PodList - pollErr := wait.PollImmediateWithContext(ctx, StatefulSetPoll, StatefulSetTimeout, func(ctx context.Context) (bool, error) { + pollErr := wait.PollUntilContextTimeout(ctx, StatefulSetPoll, StatefulSetTimeout, true, func(ctx context.Context) (bool, error) { statefulPodList = GetPodList(ctx, c, ss) if int32(len(statefulPodList.Items)) == count { return true, nil diff --git a/test/e2e/framework/statefulset/wait.go b/test/e2e/framework/statefulset/wait.go index 554aa11407b..8eae83998ad 100644 --- a/test/e2e/framework/statefulset/wait.go +++ b/test/e2e/framework/statefulset/wait.go @@ -32,7 +32,7 @@ import ( // WaitForRunning waits for numPodsRunning in ss to be Running and for the first // numPodsReady ordinals to be Ready. func WaitForRunning(ctx context.Context, c clientset.Interface, numPodsRunning, numPodsReady int32, ss *appsv1.StatefulSet) { - pollErr := wait.PollImmediateWithContext(ctx, StatefulSetPoll, StatefulSetTimeout, + pollErr := wait.PollUntilContextTimeout(ctx, StatefulSetPoll, StatefulSetTimeout, true, func(ctx context.Context) (bool, error) { podList := GetPodList(ctx, c, ss) SortStatefulPods(podList) @@ -61,7 +61,7 @@ func WaitForRunning(ctx context.Context, c clientset.Interface, numPodsRunning, // WaitForState periodically polls for the ss and its pods until the until function returns either true or an error func WaitForState(ctx context.Context, c clientset.Interface, ss *appsv1.StatefulSet, until func(*appsv1.StatefulSet, *v1.PodList) (bool, error)) { - pollErr := wait.PollImmediateWithContext(ctx, StatefulSetPoll, StatefulSetTimeout, + pollErr := wait.PollUntilContextTimeout(ctx, StatefulSetPoll, StatefulSetTimeout, true, func(ctx context.Context) (bool, error) { ssGet, err := c.AppsV1().StatefulSets(ss.Namespace).Get(ctx, ss.Name, metav1.GetOptions{}) if err != nil { @@ -101,7 +101,7 @@ func WaitForStatusReadyReplicas(ctx context.Context, c clientset.Interface, ss * framework.Logf("Waiting for statefulset status.readyReplicas updated to %d", expectedReplicas) ns, name := ss.Namespace, ss.Name - pollErr := wait.PollImmediateWithContext(ctx, StatefulSetPoll, StatefulSetTimeout, + pollErr := wait.PollUntilContextTimeout(ctx, StatefulSetPoll, StatefulSetTimeout, true, func(ctx context.Context) (bool, error) { ssGet, err := c.AppsV1().StatefulSets(ns).Get(ctx, name, metav1.GetOptions{}) if err != nil { @@ -126,7 +126,7 @@ func WaitForStatusAvailableReplicas(ctx context.Context, c clientset.Interface, framework.Logf("Waiting for statefulset status.AvailableReplicas updated to %d", expectedReplicas) ns, name := ss.Namespace, ss.Name - pollErr := wait.PollImmediateWithContext(ctx, StatefulSetPoll, StatefulSetTimeout, + pollErr := wait.PollUntilContextTimeout(ctx, StatefulSetPoll, StatefulSetTimeout, true, func(ctx context.Context) (bool, error) { ssGet, err := c.AppsV1().StatefulSets(ns).Get(ctx, name, metav1.GetOptions{}) if err != nil { @@ -151,7 +151,7 @@ func WaitForStatusReplicas(ctx context.Context, c clientset.Interface, ss *appsv framework.Logf("Waiting for statefulset status.replicas updated to %d", expectedReplicas) ns, name := ss.Namespace, ss.Name - pollErr := wait.PollImmediateWithContext(ctx, StatefulSetPoll, StatefulSetTimeout, + pollErr := wait.PollUntilContextTimeout(ctx, StatefulSetPoll, StatefulSetTimeout, true, func(ctx context.Context) (bool, error) { ssGet, err := c.AppsV1().StatefulSets(ns).Get(ctx, name, metav1.GetOptions{}) if err != nil { diff --git a/test/e2e/framework/util.go b/test/e2e/framework/util.go index f6e200fc730..9e88a91a8a7 100644 --- a/test/e2e/framework/util.go +++ b/test/e2e/framework/util.go @@ -352,7 +352,7 @@ func CreateTestingNS(ctx context.Context, baseName string, c clientset.Interface } // Be robust about making the namespace creation call. var got *v1.Namespace - if err := wait.PollImmediateWithContext(ctx, Poll, 30*time.Second, func(ctx context.Context) (bool, error) { + if err := wait.PollUntilContextTimeout(ctx, Poll, 30*time.Second, true, func(ctx context.Context) (bool, error) { var err error got, err = c.CoreV1().Namespaces().Create(ctx, namespaceObj, metav1.CreateOptions{}) if err != nil { diff --git a/test/e2e/framework/volume/fixtures.go b/test/e2e/framework/volume/fixtures.go index 55bcdc15589..e64d7ad7fd1 100644 --- a/test/e2e/framework/volume/fixtures.go +++ b/test/e2e/framework/volume/fixtures.go @@ -238,7 +238,7 @@ func getVolumeHandle(ctx context.Context, cs clientset.Interface, claimName stri // WaitForVolumeAttachmentTerminated waits for the VolumeAttachment with the passed in attachmentName to be terminated. func WaitForVolumeAttachmentTerminated(ctx context.Context, attachmentName string, cs clientset.Interface, timeout time.Duration) error { - waitErr := wait.PollImmediateWithContext(ctx, 10*time.Second, timeout, func(ctx context.Context) (bool, error) { + waitErr := wait.PollUntilContextTimeout(ctx, 10*time.Second, timeout, true, func(ctx context.Context) (bool, error) { _, err := cs.StorageV1().VolumeAttachments().Get(ctx, attachmentName, metav1.GetOptions{}) if err != nil { // if the volumeattachment object is not found, it means it has been terminated. diff --git a/test/e2e/instrumentation/core_events.go b/test/e2e/instrumentation/core_events.go index cc07c588411..432c931d267 100644 --- a/test/e2e/instrumentation/core_events.go +++ b/test/e2e/instrumentation/core_events.go @@ -217,7 +217,7 @@ var _ = common.SIGDescribe("Events", func() { ginkgo.By("check that the list of events matches the requested quantity") - err = wait.PollImmediateWithContext(ctx, eventRetryPeriod, eventRetryTimeout, checkEventListQuantity(f, "testevent-set=true", 0)) + err = wait.PollUntilContextTimeout(ctx, eventRetryPeriod, eventRetryTimeout, true, checkEventListQuantity(f, "testevent-set=true", 0)) framework.ExpectNoError(err, "failed to count required events") }) diff --git a/test/e2e/network/conntrack.go b/test/e2e/network/conntrack.go index d558acc8d80..9764f3312cd 100644 --- a/test/e2e/network/conntrack.go +++ b/test/e2e/network/conntrack.go @@ -175,7 +175,7 @@ var _ = common.SIGDescribe("Conntrack", func() { // 30 seconds by default. // Based on the above check if the pod receives the traffic. ginkgo.By("checking client pod connected to the backend 1 on Node IP " + serverNodeInfo.nodeIP) - if err := wait.PollImmediateWithContext(ctx, 5*time.Second, time.Minute, logContainsFn(podBackend1, podClient)); err != nil { + if err := wait.PollUntilContextTimeout(ctx, 5*time.Second, time.Minute, true, logContainsFn(podBackend1, podClient)); err != nil { logs, err = e2epod.GetPodLogs(ctx, cs, ns, podClient, podClient) framework.ExpectNoError(err) framework.Logf("Pod client logs: %s", logs) @@ -199,7 +199,7 @@ var _ = common.SIGDescribe("Conntrack", func() { // Check that the second pod keeps receiving traffic // UDP conntrack entries timeout is 30 sec by default ginkgo.By("checking client pod connected to the backend 2 on Node IP " + serverNodeInfo.nodeIP) - if err := wait.PollImmediateWithContext(ctx, 5*time.Second, time.Minute, logContainsFn(podBackend2, podClient)); err != nil { + if err := wait.PollUntilContextTimeout(ctx, 5*time.Second, time.Minute, true, logContainsFn(podBackend2, podClient)); err != nil { logs, err = e2epod.GetPodLogs(ctx, cs, ns, podClient, podClient) framework.ExpectNoError(err) framework.Logf("Pod client logs: %s", logs) @@ -251,7 +251,7 @@ var _ = common.SIGDescribe("Conntrack", func() { // 30 seconds by default. // Based on the above check if the pod receives the traffic. ginkgo.By("checking client pod connected to the backend 1 on Node IP " + serverNodeInfo.nodeIP) - if err := wait.PollImmediateWithContext(ctx, 5*time.Second, time.Minute, logContainsFn(podBackend1, podClient)); err != nil { + if err := wait.PollUntilContextTimeout(ctx, 5*time.Second, time.Minute, true, logContainsFn(podBackend1, podClient)); err != nil { logs, err = e2epod.GetPodLogs(ctx, cs, ns, podClient, podClient) framework.ExpectNoError(err) framework.Logf("Pod client logs: %s", logs) @@ -275,7 +275,7 @@ var _ = common.SIGDescribe("Conntrack", func() { // Check that the second pod keeps receiving traffic // UDP conntrack entries timeout is 30 sec by default ginkgo.By("checking client pod connected to the backend 2 on Node IP " + serverNodeInfo.nodeIP) - if err := wait.PollImmediateWithContext(ctx, 5*time.Second, time.Minute, logContainsFn(podBackend2, podClient)); err != nil { + if err := wait.PollUntilContextTimeout(ctx, 5*time.Second, time.Minute, true, logContainsFn(podBackend2, podClient)); err != nil { logs, err = e2epod.GetPodLogs(ctx, cs, ns, podClient, podClient) framework.ExpectNoError(err) framework.Logf("Pod client logs: %s", logs) @@ -328,7 +328,7 @@ var _ = common.SIGDescribe("Conntrack", func() { // 30 seconds by default. // Based on the above check if the pod receives the traffic. ginkgo.By("checking client pod connected to the backend 1 on Node IP " + serverNodeInfo.nodeIP) - if err := wait.PollImmediateWithContext(ctx, 5*time.Second, time.Minute, logContainsFn(podBackend1, podClient)); err != nil { + if err := wait.PollUntilContextTimeout(ctx, 5*time.Second, time.Minute, true, logContainsFn(podBackend1, podClient)); err != nil { logs, err = e2epod.GetPodLogs(ctx, cs, ns, podClient, podClient) framework.ExpectNoError(err) framework.Logf("Pod client logs: %s", logs) @@ -352,7 +352,7 @@ var _ = common.SIGDescribe("Conntrack", func() { // Check that the second pod keeps receiving traffic // UDP conntrack entries timeout is 30 sec by default ginkgo.By("checking client pod connected to the backend 2 on Node IP " + serverNodeInfo.nodeIP) - if err := wait.PollImmediateWithContext(ctx, 5*time.Second, time.Minute, logContainsFn(podBackend2, podClient)); err != nil { + if err := wait.PollUntilContextTimeout(ctx, 5*time.Second, time.Minute, true, logContainsFn(podBackend2, podClient)); err != nil { logs, err = e2epod.GetPodLogs(ctx, cs, ns, podClient, podClient) framework.ExpectNoError(err) framework.Logf("Pod client logs: %s", logs) @@ -424,7 +424,7 @@ var _ = common.SIGDescribe("Conntrack", func() { // 30 seconds by default. // Based on the above check if the pod receives the traffic. ginkgo.By("checking client pod connected to the backend on Node IP " + serverNodeInfo.nodeIP) - if err := wait.PollImmediateWithContext(ctx, 5*time.Second, time.Minute, logContainsFn(podBackend1, podClient)); err != nil { + if err := wait.PollUntilContextTimeout(ctx, 5*time.Second, time.Minute, true, logContainsFn(podBackend1, podClient)); err != nil { logs, err = e2epod.GetPodLogs(ctx, cs, ns, podClient, podClient) framework.ExpectNoError(err) framework.Logf("Pod client logs: %s", logs) @@ -541,7 +541,7 @@ var _ = common.SIGDescribe("Conntrack", func() { // so the client will receive an unexpected TCP connection and RST the connection // the server will log ERROR if that happens ginkgo.By("checking client pod does not RST the TCP connection because it receives an INVALID packet") - if err := wait.PollImmediateWithContext(ctx, 5*time.Second, time.Minute, logContainsFn("ERROR", "boom-server")); err == nil { + if err := wait.PollUntilContextTimeout(ctx, 5*time.Second, time.Minute, true, logContainsFn("ERROR", "boom-server")); err == nil { logs, err := e2epod.GetPodLogs(ctx, cs, ns, "boom-server", "boom-server") framework.ExpectNoError(err) framework.Logf("boom-server pod logs: %s", logs) diff --git a/test/e2e/network/dns_common.go b/test/e2e/network/dns_common.go index 2832ea559a6..9d64c5aae39 100644 --- a/test/e2e/network/dns_common.go +++ b/test/e2e/network/dns_common.go @@ -456,7 +456,7 @@ func assertFilesExist(ctx context.Context, fileNames []string, fileDir string, p func assertFilesContain(ctx context.Context, fileNames []string, fileDir string, pod *v1.Pod, client clientset.Interface, check bool, expected string) { var failed []string - framework.ExpectNoError(wait.PollImmediateWithContext(ctx, time.Second*5, time.Second*600, func(ctx context.Context) (bool, error) { + framework.ExpectNoError(wait.PollUntilContextTimeout(ctx, time.Second*5, time.Second*600, true, func(ctx context.Context) (bool, error) { failed = []string{} ctx, cancel := context.WithTimeout(ctx, framework.SingleCallTimeout) diff --git a/test/e2e/network/endpointslice.go b/test/e2e/network/endpointslice.go index 4578c74ce3e..0ee90a064a0 100644 --- a/test/e2e/network/endpointslice.go +++ b/test/e2e/network/endpointslice.go @@ -740,7 +740,7 @@ var _ = common.SIGDescribe("EndpointSlice", func() { // the only caller of this function. func expectEndpointsAndSlices(ctx context.Context, cs clientset.Interface, ns string, svc *v1.Service, pods []*v1.Pod, numSubsets, numSlices int, namedPort bool) { endpointSlices := []discoveryv1.EndpointSlice{} - if err := wait.PollImmediateWithContext(ctx, 5*time.Second, 2*time.Minute, func(ctx context.Context) (bool, error) { + if err := wait.PollUntilContextTimeout(ctx, 5*time.Second, 2*time.Minute, true, func(ctx context.Context) (bool, error) { endpointSlicesFound, hasMatchingSlices := hasMatchingEndpointSlices(ctx, cs, ns, svc.Name, len(pods), numSlices) if !hasMatchingSlices { return false, nil diff --git a/test/e2e/network/example_cluster_dns.go b/test/e2e/network/example_cluster_dns.go index ac604e606f8..9b3717d5508 100644 --- a/test/e2e/network/example_cluster_dns.go +++ b/test/e2e/network/example_cluster_dns.go @@ -171,7 +171,7 @@ var _ = common.SIGDescribe("ClusterDns [Feature:Example]", func() { func waitForServiceResponding(ctx context.Context, c clientset.Interface, ns, name string) error { ginkgo.By(fmt.Sprintf("trying to dial the service %s.%s via the proxy", ns, name)) - return wait.PollImmediateWithContext(ctx, framework.Poll, RespondingTimeout, func(ctx context.Context) (done bool, err error) { + return wait.PollUntilContextTimeout(ctx, framework.Poll, RespondingTimeout, true, func(ctx context.Context) (done bool, err error) { proxyRequest, errProxy := e2eservice.GetServicesProxyRequest(c, c.CoreV1().RESTClient().Get()) if errProxy != nil { framework.Logf("Failed to get services proxy request: %v:", errProxy) diff --git a/test/e2e/network/loadbalancer.go b/test/e2e/network/loadbalancer.go index 8b50250c721..cac444bc6fe 100644 --- a/test/e2e/network/loadbalancer.go +++ b/test/e2e/network/loadbalancer.go @@ -1674,7 +1674,7 @@ func testRollingUpdateLBConnectivityDisruption(ctx context.Context, f *framework ginkgo.By("Checking that daemon pods launch on every schedulable node of the cluster") creationTimeout := e2eservice.GetServiceLoadBalancerCreationTimeout(ctx, cs) - err = wait.PollImmediateWithContext(ctx, framework.Poll, creationTimeout, e2edaemonset.CheckDaemonPodOnNodes(f, ds, nodeNames)) + err = wait.PollUntilContextTimeout(ctx, framework.Poll, creationTimeout, true, e2edaemonset.CheckDaemonPodOnNodes(f, ds, nodeNames)) framework.ExpectNoError(err, "error waiting for daemon pods to start") err = e2edaemonset.CheckDaemonStatus(ctx, f, name) framework.ExpectNoError(err) diff --git a/test/e2e/network/service.go b/test/e2e/network/service.go index 1775cc2cec6..b4072e3ab0b 100644 --- a/test/e2e/network/service.go +++ b/test/e2e/network/service.go @@ -1822,7 +1822,7 @@ var _ = common.SIGDescribe("Services", func() { execPodName := execPod.Name cmd := fmt.Sprintf("curl -q -s --connect-timeout 2 http://%s:%d/", svcName, port) var stdout string - if pollErr := wait.PollImmediateWithContext(ctx, framework.Poll, e2eservice.KubeProxyLagTimeout, func(ctx context.Context) (bool, error) { + if pollErr := wait.PollUntilContextTimeout(ctx, framework.Poll, e2eservice.KubeProxyLagTimeout, true, func(ctx context.Context) (bool, error) { var err error stdout, err = e2eoutput.RunHostCmd(f.Namespace.Name, execPodName, cmd) if err != nil { diff --git a/test/e2e/network/util.go b/test/e2e/network/util.go index 492169ef93c..2751b102f55 100644 --- a/test/e2e/network/util.go +++ b/test/e2e/network/util.go @@ -233,7 +233,7 @@ func testEndpointReachability(ctx context.Context, endpoint string, port int32, return fmt.Errorf("service reachability check is not supported for %v", protocol) } - err := wait.PollImmediateWithContext(ctx, framework.Poll, timeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, framework.Poll, timeout, true, func(ctx context.Context) (bool, error) { stdout, err := e2eoutput.RunHostCmd(execPod.Namespace, execPod.Name, cmd) if err != nil { framework.Logf("Service reachability failing with error: %v\nRetrying...", err) diff --git a/test/e2e/storage/detach_mounted.go b/test/e2e/storage/detach_mounted.go index a1cb99fa953..d21cb177f27 100644 --- a/test/e2e/storage/detach_mounted.go +++ b/test/e2e/storage/detach_mounted.go @@ -134,7 +134,7 @@ func getUniqueVolumeName(pod *v1.Pod, driverName string) string { } func waitForVolumesNotInUse(ctx context.Context, client clientset.Interface, nodeName, volumeName string) error { - waitErr := wait.PollImmediateWithContext(ctx, 10*time.Second, 60*time.Second, func(ctx context.Context) (bool, error) { + waitErr := wait.PollUntilContextTimeout(ctx, 10*time.Second, 60*time.Second, true, func(ctx context.Context) (bool, error) { node, err := client.CoreV1().Nodes().Get(ctx, nodeName, metav1.GetOptions{}) if err != nil { return false, fmt.Errorf("error fetching node %s with %v", nodeName, err) @@ -154,7 +154,7 @@ func waitForVolumesNotInUse(ctx context.Context, client clientset.Interface, nod } func waitForVolumesAttached(ctx context.Context, client clientset.Interface, nodeName, volumeName string) error { - waitErr := wait.PollImmediateWithContext(ctx, 2*time.Second, 2*time.Minute, func(ctx context.Context) (bool, error) { + waitErr := wait.PollUntilContextTimeout(ctx, 2*time.Second, 2*time.Minute, true, func(ctx context.Context) (bool, error) { node, err := client.CoreV1().Nodes().Get(ctx, nodeName, metav1.GetOptions{}) if err != nil { return false, fmt.Errorf("error fetching node %s with %v", nodeName, err) @@ -174,7 +174,7 @@ func waitForVolumesAttached(ctx context.Context, client clientset.Interface, nod } func waitForVolumesInUse(ctx context.Context, client clientset.Interface, nodeName, volumeName string) error { - waitErr := wait.PollImmediateWithContext(ctx, 10*time.Second, 60*time.Second, func(ctx context.Context) (bool, error) { + waitErr := wait.PollUntilContextTimeout(ctx, 10*time.Second, 60*time.Second, true, func(ctx context.Context) (bool, error) { node, err := client.CoreV1().Nodes().Get(ctx, nodeName, metav1.GetOptions{}) if err != nil { return false, fmt.Errorf("error fetching node %s with %v", nodeName, err) diff --git a/test/e2e/storage/local_volume_resize.go b/test/e2e/storage/local_volume_resize.go index b0c7ec4b3dc..84955203efd 100644 --- a/test/e2e/storage/local_volume_resize.go +++ b/test/e2e/storage/local_volume_resize.go @@ -139,7 +139,7 @@ func UpdatePVSize(ctx context.Context, pv *v1.PersistentVolume, size resource.Qu pvToUpdate := pv.DeepCopy() var lastError error - waitErr := wait.PollImmediateWithContext(ctx, 5*time.Second, csiResizeWaitPeriod, func(ctx context.Context) (bool, error) { + waitErr := wait.PollUntilContextTimeout(ctx, 5*time.Second, csiResizeWaitPeriod, true, func(ctx context.Context) (bool, error) { var err error pvToUpdate, err = c.CoreV1().PersistentVolumes().Get(ctx, pvName, metav1.GetOptions{}) if err != nil { diff --git a/test/e2e/storage/persistent_volumes-local.go b/test/e2e/storage/persistent_volumes-local.go index e582383e622..1583ed5feb1 100644 --- a/test/e2e/storage/persistent_volumes-local.go +++ b/test/e2e/storage/persistent_volumes-local.go @@ -615,7 +615,7 @@ var _ = utils.SIGDescribe("PersistentVolumes-local", func() { ginkgo.By("Waiting for all pods to complete successfully") const completeTimeout = 5 * time.Minute - waitErr := wait.PollImmediateWithContext(ctx, time.Second, completeTimeout, func(ctx context.Context) (done bool, err error) { + waitErr := wait.PollUntilContextTimeout(ctx, time.Second, completeTimeout, true, func(ctx context.Context) (done bool, err error) { podsList, err := config.client.CoreV1().Pods(config.ns).List(ctx, metav1.ListOptions{}) if err != nil { return false, err diff --git a/test/e2e/storage/regional_pd.go b/test/e2e/storage/regional_pd.go index f1108956a3b..787672e9e82 100644 --- a/test/e2e/storage/regional_pd.go +++ b/test/e2e/storage/regional_pd.go @@ -260,7 +260,7 @@ func testZonalFailover(ctx context.Context, c clientset.Interface, ns string) { } else { otherZone = cloudZones[0] } - waitErr := wait.PollImmediateWithContext(ctx, framework.Poll, statefulSetReadyTimeout, func(ctx context.Context) (bool, error) { + waitErr := wait.PollUntilContextTimeout(ctx, framework.Poll, statefulSetReadyTimeout, true, func(ctx context.Context) (bool, error) { framework.Logf("Checking whether new pod is scheduled in zone %q", otherZone) pod := getPod(ctx, c, ns, regionalPDLabels) node, err := c.CoreV1().Nodes().Get(ctx, pod.Spec.NodeName, metav1.GetOptions{}) diff --git a/test/e2e/storage/testsuites/volume_expand.go b/test/e2e/storage/testsuites/volume_expand.go index 70c40d83e03..2e29277418c 100644 --- a/test/e2e/storage/testsuites/volume_expand.go +++ b/test/e2e/storage/testsuites/volume_expand.go @@ -326,7 +326,7 @@ func ExpandPVCSize(ctx context.Context, origPVC *v1.PersistentVolumeClaim, size // WaitForResizingCondition waits for the pvc condition to be PersistentVolumeClaimResizing func WaitForResizingCondition(ctx context.Context, pvc *v1.PersistentVolumeClaim, c clientset.Interface, duration time.Duration) error { - waitErr := wait.PollImmediateWithContext(ctx, resizePollInterval, duration, func(ctx context.Context) (bool, error) { + waitErr := wait.PollUntilContextTimeout(ctx, resizePollInterval, duration, true, func(ctx context.Context) (bool, error) { var err error updatedPVC, err := c.CoreV1().PersistentVolumeClaims(pvc.Namespace).Get(ctx, pvc.Name, metav1.GetOptions{}) @@ -351,7 +351,7 @@ func WaitForResizingCondition(ctx context.Context, pvc *v1.PersistentVolumeClaim // WaitForControllerVolumeResize waits for the controller resize to be finished func WaitForControllerVolumeResize(ctx context.Context, pvc *v1.PersistentVolumeClaim, c clientset.Interface, timeout time.Duration) error { pvName := pvc.Spec.VolumeName - waitErr := wait.PollImmediateWithContext(ctx, resizePollInterval, timeout, func(ctx context.Context) (bool, error) { + waitErr := wait.PollUntilContextTimeout(ctx, resizePollInterval, timeout, true, func(ctx context.Context) (bool, error) { pvcSize := pvc.Spec.Resources.Requests[v1.ResourceStorage] pv, err := c.CoreV1().PersistentVolumes().Get(ctx, pvName, metav1.GetOptions{}) @@ -376,7 +376,7 @@ func WaitForControllerVolumeResize(ctx context.Context, pvc *v1.PersistentVolume // WaitForPendingFSResizeCondition waits for pvc to have resize condition func WaitForPendingFSResizeCondition(ctx context.Context, pvc *v1.PersistentVolumeClaim, c clientset.Interface) (*v1.PersistentVolumeClaim, error) { var updatedPVC *v1.PersistentVolumeClaim - waitErr := wait.PollImmediateWithContext(ctx, resizePollInterval, pvcConditionSyncPeriod, func(ctx context.Context) (bool, error) { + waitErr := wait.PollUntilContextTimeout(ctx, resizePollInterval, pvcConditionSyncPeriod, true, func(ctx context.Context) (bool, error) { var err error updatedPVC, err = c.CoreV1().PersistentVolumeClaims(pvc.Namespace).Get(ctx, pvc.Name, metav1.GetOptions{}) @@ -404,7 +404,7 @@ func WaitForPendingFSResizeCondition(ctx context.Context, pvc *v1.PersistentVolu // WaitForFSResize waits for the filesystem in the pv to be resized func WaitForFSResize(ctx context.Context, pvc *v1.PersistentVolumeClaim, c clientset.Interface) (*v1.PersistentVolumeClaim, error) { var updatedPVC *v1.PersistentVolumeClaim - waitErr := wait.PollImmediateWithContext(ctx, resizePollInterval, totalResizeWaitPeriod, func(ctx context.Context) (bool, error) { + waitErr := wait.PollUntilContextTimeout(ctx, resizePollInterval, totalResizeWaitPeriod, true, func(ctx context.Context) (bool, error) { var err error updatedPVC, err = c.CoreV1().PersistentVolumeClaims(pvc.Namespace).Get(ctx, pvc.Name, metav1.GetOptions{}) diff --git a/test/e2e/upgrades/apps/cassandra.go b/test/e2e/upgrades/apps/cassandra.go index f92879cdfb3..2f5aac92c99 100644 --- a/test/e2e/upgrades/apps/cassandra.go +++ b/test/e2e/upgrades/apps/cassandra.go @@ -93,7 +93,7 @@ func (t *CassandraUpgradeTest) Setup(ctx context.Context, f *framework.Framework cassandraKubectlCreate(ns, "tester.yaml") ginkgo.By("Getting the ingress IPs from the services") - err := wait.PollImmediateWithContext(ctx, statefulsetPoll, statefulsetTimeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, statefulsetPoll, statefulsetTimeout, true, func(ctx context.Context) (bool, error) { if t.ip = t.getServiceIP(ctx, f, ns, "test-server"); t.ip == "" { return false, nil } diff --git a/test/e2e/upgrades/apps/etcd.go b/test/e2e/upgrades/apps/etcd.go index 937c9bfbdfb..774c35bd048 100644 --- a/test/e2e/upgrades/apps/etcd.go +++ b/test/e2e/upgrades/apps/etcd.go @@ -88,7 +88,7 @@ func (t *EtcdUpgradeTest) Setup(ctx context.Context, f *framework.Framework) { kubectlCreate(ns, "tester.yaml") ginkgo.By("Getting the ingress IPs from the services") - err := wait.PollImmediateWithContext(ctx, statefulsetPoll, statefulsetTimeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, statefulsetPoll, statefulsetTimeout, true, func(ctx context.Context) (bool, error) { if t.ip = t.getServiceIP(ctx, f, ns, "test-server"); t.ip == "" { return false, nil } diff --git a/test/e2e/upgrades/apps/mysql.go b/test/e2e/upgrades/apps/mysql.go index 6ce3a41b00a..1a16931bacc 100644 --- a/test/e2e/upgrades/apps/mysql.go +++ b/test/e2e/upgrades/apps/mysql.go @@ -103,7 +103,7 @@ func (t *MySQLUpgradeTest) Setup(ctx context.Context, f *framework.Framework) { mysqlKubectlCreate(ns, "tester.yaml") ginkgo.By("Getting the ingress IPs from the test-service") - err := wait.PollImmediateWithContext(ctx, statefulsetPoll, statefulsetTimeout, func(ctx context.Context) (bool, error) { + err := wait.PollUntilContextTimeout(ctx, statefulsetPoll, statefulsetTimeout, true, func(ctx context.Context) (bool, error) { if t.ip = t.getServiceIP(ctx, f, ns, "test-server"); t.ip == "" { return false, nil } diff --git a/test/e2e_node/density_test.go b/test/e2e_node/density_test.go index 119d1e7b1c6..8f7efffb7b6 100644 --- a/test/e2e_node/density_test.go +++ b/test/e2e_node/density_test.go @@ -552,7 +552,7 @@ func createBatchPodSequential(ctx context.Context, f *framework.Framework, pods create := metav1.Now() createTimes[pod.Name] = create p := e2epod.NewPodClient(f).Create(ctx, pod) - framework.ExpectNoError(wait.PollImmediateWithContext(ctx, 2*time.Second, framework.PodStartTimeout, podWatchedRunning(watchTimes, p.Name))) + framework.ExpectNoError(wait.PollUntilContextTimeout(ctx, 2*time.Second, framework.PodStartTimeout, true, podWatchedRunning(watchTimes, p.Name))) e2eLags = append(e2eLags, e2emetrics.PodLatencyData{Name: pod.Name, Latency: watchTimes[pod.Name].Time.Sub(create.Time)}) } diff --git a/test/e2e_node/kubeletconfig/kubeletconfig.go b/test/e2e_node/kubeletconfig/kubeletconfig.go index 12e3a7f98eb..e6c23934daa 100644 --- a/test/e2e_node/kubeletconfig/kubeletconfig.go +++ b/test/e2e_node/kubeletconfig/kubeletconfig.go @@ -162,7 +162,7 @@ func pollConfigz(ctx context.Context, timeout time.Duration, pollInterval time.D req.Header.Add("Accept", "application/json") var respBody []byte - err = wait.PollImmediateWithContext(ctx, pollInterval, timeout, func(ctx context.Context) (bool, error) { + err = wait.PollUntilContextTimeout(ctx, pollInterval, timeout, true, func(ctx context.Context) (bool, error) { resp, err := client.Do(req) if err != nil { framework.Logf("Failed to get /configz, retrying. Error: %v", err) diff --git a/test/e2e_node/mirror_pod_test.go b/test/e2e_node/mirror_pod_test.go index bba239e6ae5..e4358fe4de3 100644 --- a/test/e2e_node/mirror_pod_test.go +++ b/test/e2e_node/mirror_pod_test.go @@ -435,7 +435,7 @@ func checkMirrorPodRunning(ctx context.Context, cl clientset.Interface, name, na func checkMirrorPodRunningWithRestartCount(ctx context.Context, interval time.Duration, timeout time.Duration, cl clientset.Interface, name, namespace string, count int32) error { var pod *v1.Pod var err error - err = wait.PollImmediateWithContext(ctx, interval, timeout, func(ctx context.Context) (bool, error) { + err = wait.PollUntilContextTimeout(ctx, interval, timeout, true, func(ctx context.Context) (bool, error) { pod, err = cl.CoreV1().Pods(namespace).Get(ctx, name, metav1.GetOptions{}) if err != nil { return false, fmt.Errorf("expected the mirror pod %q to appear: %w", name, err)