Check for context cancellation on each buffered chunk

TestListPager_EachListItem flakes without this change.

Signed-off-by: Monis Khan <mok@microsoft.com>

Kubernetes-commit: 7458ed01d6aa150b8a6046e0dbeba88d5d5ff1bb
This commit is contained in:
Monis Khan
2022-09-15 10:33:33 -04:00
committed by Kubernetes Publisher
parent 58155b7df0
commit 67030989c0

View File

@@ -203,6 +203,11 @@ func (p *ListPager) eachListChunkBuffered(ctx context.Context, options metav1.Li
}()
for o := range chunkC {
select {
case <-ctx.Done():
return ctx.Err()
default:
}
err := fn(o)
if err != nil {
return err // any fn error should be returned immediately