@@ -144,8 +144,7 @@ func (f *Framework) EnsureDeployment(deployment *appsv1.Deployment) *appsv1.Depl
144144
145145// waitForPodsReady waits for a given amount of time until a group of Pods is running in the given namespace.
146146func waitForPodsReady (kubeClientSet kubernetes.Interface , timeout time.Duration , expectedReplicas int , namespace string , opts * metav1.ListOptions ) error {
147- //nolint:staticcheck // TODO: will replace it since wait.PollImmediate is deprecated
148- return wait .PollImmediate (1 * time .Second , timeout , func () (bool , error ) {
147+ return wait .PollUntilContextTimeout (context .Background (), 1 * time .Second , timeout , true , func (_ context.Context ) (bool , error ) {
149148 pl , err := kubeClientSet .CoreV1 ().Pods (namespace ).List (context .TODO (), * opts )
150149 if err != nil {
151150 return false , nil
@@ -172,8 +171,7 @@ func waitForPodsReady(kubeClientSet kubernetes.Interface, timeout time.Duration,
172171
173172// waitForPodsDeleted waits for a given amount of time until a group of Pods are deleted in the given namespace.
174173func waitForPodsDeleted (kubeClientSet kubernetes.Interface , timeout time.Duration , namespace string , opts * metav1.ListOptions ) error {
175- //nolint:staticcheck // TODO: will replace it since wait.Poll is deprecated
176- return wait .Poll (Poll , timeout , func () (bool , error ) {
174+ return wait .PollUntilContextTimeout (context .Background (), Poll , timeout , true , func (_ context.Context ) (bool , error ) {
177175 pl , err := kubeClientSet .CoreV1 ().Pods (namespace ).List (context .TODO (), * opts )
178176 if err != nil {
179177 return false , nil
@@ -192,8 +190,8 @@ func WaitForEndpoints(kubeClientSet kubernetes.Interface, timeout time.Duration,
192190 if expectedEndpoints == 0 {
193191 return nil
194192 }
195- //nolint:staticcheck // TODO: will replace it since wait.PollImmediate is deprecated
196- return wait .PollImmediate ( Poll , timeout , func () (bool , error ) {
193+
194+ err := wait .PollUntilContextTimeout ( context . Background (), Poll , timeout , true , func (_ context. Context ) (bool , error ) {
197195 endpoint , err := kubeClientSet .CoreV1 ().Endpoints (ns ).Get (context .TODO (), name , metav1.GetOptions {})
198196 if k8sErrors .IsNotFound (err ) {
199197 return false , nil
@@ -207,6 +205,8 @@ func WaitForEndpoints(kubeClientSet kubernetes.Interface, timeout time.Duration,
207205
208206 return false , nil
209207 })
208+
209+ return err
210210}
211211
212212func countReadyEndpoints (e * core.Endpoints ) int {
@@ -254,8 +254,9 @@ func isPodReady(p *core.Pod) bool {
254254// getIngressNGINXPod returns the ingress controller running pod
255255func getIngressNGINXPod (ns string , kubeClientSet kubernetes.Interface ) (* core.Pod , error ) {
256256 var pod * core.Pod
257- //nolint:staticcheck // TODO: will replace it since wait.Poll is deprecated
258- err := wait .Poll (1 * time .Second , DefaultTimeout , func () (bool , error ) {
257+ ctx , cancel := context .WithTimeout (context .Background (), DefaultTimeout )
258+ defer cancel ()
259+ err := wait .PollUntilContextTimeout (ctx , 1 * time .Second , DefaultTimeout , true , func (_ context.Context ) (bool , error ) {
259260 l , err := kubeClientSet .CoreV1 ().Pods (ns ).List (context .TODO (), metav1.ListOptions {
260261 LabelSelector : "app.kubernetes.io/name=ingress-nginx" ,
261262 })
@@ -281,8 +282,7 @@ func getIngressNGINXPod(ns string, kubeClientSet kubernetes.Interface) (*core.Po
281282 return false , nil
282283 })
283284 if err != nil {
284- //nolint:staticcheck // TODO: will replace it since wait.ErrWaitTimeout is deprecated
285- if err == wait .ErrWaitTimeout {
285+ if ctx .Err () == context .DeadlineExceeded {
286286 return nil , fmt .Errorf ("timeout waiting at least one ingress-nginx pod running in namespace %v" , ns )
287287 }
288288
0 commit comments