mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-03 16:16:06 +00:00
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:
committed by
Kubernetes Publisher
parent
58155b7df0
commit
67030989c0
@@ -203,6 +203,11 @@ func (p *ListPager) eachListChunkBuffered(ctx context.Context, options metav1.Li
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
for o := range chunkC {
|
for o := range chunkC {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
return ctx.Err()
|
||||||
|
default:
|
||||||
|
}
|
||||||
err := fn(o)
|
err := fn(o)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err // any fn error should be returned immediately
|
return err // any fn error should be returned immediately
|
||||||
|
Reference in New Issue
Block a user