mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-15 22:58:24 +00:00
pager.go: Don't set ResourveVersion on subsequent List calls
Ref. https://github.com/kubernetes/kubernetes/issues/85221#issuecomment-553748143 Kubernetes-commit: 977ca43d640d2a85e199a8a282e2df8ebd88055a
This commit is contained in:
committed by
Kubernetes Publisher
parent
6f03b71b98
commit
d7b4c23325
@@ -77,6 +77,7 @@ func (p *ListPager) List(ctx context.Context, options metav1.ListOptions) (runti
|
||||
if options.Limit == 0 {
|
||||
options.Limit = p.PageSize
|
||||
}
|
||||
requestedResourceVersion := options.ResourceVersion
|
||||
var list *metainternalversion.List
|
||||
for {
|
||||
select {
|
||||
@@ -94,9 +95,11 @@ func (p *ListPager) List(ctx context.Context, options metav1.ListOptions) (runti
|
||||
if !errors.IsResourceExpired(err) || !p.FullListIfExpired || options.Continue == "" {
|
||||
return nil, err
|
||||
}
|
||||
// the list expired while we were processing, fall back to a full list
|
||||
// the list expired while we were processing, fall back to a full list at
|
||||
// the requested ResourceVersion.
|
||||
options.Limit = 0
|
||||
options.Continue = ""
|
||||
options.ResourceVersion = requestedResourceVersion
|
||||
return p.PageFn(ctx, options)
|
||||
}
|
||||
m, err := meta.ListAccessor(obj)
|
||||
@@ -129,6 +132,10 @@ func (p *ListPager) List(ctx context.Context, options metav1.ListOptions) (runti
|
||||
|
||||
// set the next loop up
|
||||
options.Continue = m.GetContinue()
|
||||
// Clear the ResourceVersion on the subsequent List calls to avoid the
|
||||
// `specifying resource version is not allowed when using continue` error.
|
||||
// See https://github.com/kubernetes/kubernetes/issues/85221#issuecomment-553748143.
|
||||
options.ResourceVersion = ""
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user