From 67030989c034f3305e38ea4a38493a9a6de10dc1 Mon Sep 17 00:00:00 2001 From: Monis Khan Date: Thu, 15 Sep 2022 10:33:33 -0400 Subject: [PATCH] Check for context cancellation on each buffered chunk TestListPager_EachListItem flakes without this change. Signed-off-by: Monis Khan Kubernetes-commit: 7458ed01d6aa150b8a6046e0dbeba88d5d5ff1bb --- tools/pager/pager.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/pager/pager.go b/tools/pager/pager.go index 805859e0..9ba988f6 100644 --- a/tools/pager/pager.go +++ b/tools/pager/pager.go @@ -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