Check for context cancellation on each buffered chunk

TestListPager_EachListItem flakes without this change.

Signed-off-by: Monis Khan <mok@microsoft.com>
This commit is contained in:
Monis Khan
2022-09-15 10:33:33 -04:00
parent 7a68c8a21a
commit 7458ed01d6

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