@@ -144,8 +144,7 @@ func (f *Framework) EnsureDeployment(deployment *appsv1.Deployment) *appsv1.Depl
144
144
145
145
// waitForPodsReady waits for a given amount of time until a group of Pods is running in the given namespace.
146
146
func 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 ) {
149
148
pl , err := kubeClientSet .CoreV1 ().Pods (namespace ).List (context .TODO (), * opts )
150
149
if err != nil {
151
150
return false , nil
@@ -172,8 +171,7 @@ func waitForPodsReady(kubeClientSet kubernetes.Interface, timeout time.Duration,
172
171
173
172
// waitForPodsDeleted waits for a given amount of time until a group of Pods are deleted in the given namespace.
174
173
func 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 ) {
177
175
pl , err := kubeClientSet .CoreV1 ().Pods (namespace ).List (context .TODO (), * opts )
178
176
if err != nil {
179
177
return false , nil
@@ -192,8 +190,8 @@ func WaitForEndpoints(kubeClientSet kubernetes.Interface, timeout time.Duration,
192
190
if expectedEndpoints == 0 {
193
191
return nil
194
192
}
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 ) {
197
195
endpoint , err := kubeClientSet .CoreV1 ().Endpoints (ns ).Get (context .TODO (), name , metav1.GetOptions {})
198
196
if k8sErrors .IsNotFound (err ) {
199
197
return false , nil
@@ -207,6 +205,8 @@ func WaitForEndpoints(kubeClientSet kubernetes.Interface, timeout time.Duration,
207
205
208
206
return false , nil
209
207
})
208
+
209
+ return err
210
210
}
211
211
212
212
func countReadyEndpoints (e * core.Endpoints ) int {
@@ -254,8 +254,9 @@ func isPodReady(p *core.Pod) bool {
254
254
// getIngressNGINXPod returns the ingress controller running pod
255
255
func getIngressNGINXPod (ns string , kubeClientSet kubernetes.Interface ) (* core.Pod , error ) {
256
256
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 ) {
259
260
l , err := kubeClientSet .CoreV1 ().Pods (ns ).List (context .TODO (), metav1.ListOptions {
260
261
LabelSelector : "app.kubernetes.io/name=ingress-nginx" ,
261
262
})
@@ -281,8 +282,7 @@ func getIngressNGINXPod(ns string, kubeClientSet kubernetes.Interface) (*core.Po
281
282
return false , nil
282
283
})
283
284
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 {
286
286
return nil , fmt .Errorf ("timeout waiting at least one ingress-nginx pod running in namespace %v" , ns )
287
287
}
288
288
0 commit comments