Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix buggy pager func #4306

Merged
merged 2 commits into from
Nov 9, 2021
Merged

fix buggy pager func #4306

merged 2 commits into from
Nov 9, 2021

Conversation

alaypatel07
Copy link
Contributor

@alaypatel07 alaypatel07 commented Nov 1, 2021

  • fix buggy pager func

fix paging items in to use list options passed by the paging function

The client-go pager sets the Limit options for the list call
to paginate the request[1]. This PR fixes the paging function
to use the options passed by the pager instead of shadowed options
This is required for the pagination to work correctly.

  • simplify the pager list implementation by using pager.List()
    The List() function already implements a lot of the logic that was
    needed for paging here, using it simplifies the code.
  1. https://github.com/kubernetes/kubernetes/blob/3f40906dd8a54fb91650553a6457496181f591bc/staging/src/k8s.io/client-go/tools/pager/pager.go#L219

Signed-off-by: Alay Patel alay1431@gmail.com

Thank you for contributing to Velero!

Please add a summary of your change

Does your change fix a particular issue?

Fixes #(issue)

Please indicate you've done the following:

@alaypatel07
Copy link
Contributor Author

fixes #4244

err = meta.EachListItem(list, func(object runtime.Object) error {
u, ok := object.(*unstructured.Unstructured)
if !ok {
log.WithError(errors.WithStack(fmt.Errorf("expected *unstructured.Unstructured but got %T", u))).Error("unable to understand entry in the list")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we return from here directly if the object isn't Unstructured rather than putting it into the item list?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 yes. Missed returning the error here, good catch

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alaypatel07 Could you make an update for this? This is the only comment from my side

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated, PTAL

@ywk253100 ywk253100 added this to the v1.7.1 milestone Nov 8, 2021
fix paging items in to use list options passed by the paging function

The client-go pager sets the Limit options for the list call
to paginate the request[1]. This PR fixes the paging function
to use the options passed by the pager instead of shadowed options
This is required for the pagination to work correctly.

- simplify the pager list implementation by using pager.List()
The List() function already implements a lot of the logic that was
needed for paging here, using it simplifies the code.

1. https://github.com/kubernetes/kubernetes/blob/3f40906dd8a54fb91650553a6457496181f591bc/staging/src/k8s.io/client-go/tools/pager/pager.go#L219

Signed-off-by: Alay Patel <alay1431@gmail.com>
Signed-off-by: Alay Patel <alay1431@gmail.com>
@ywk253100 ywk253100 merged commit 6801ddc into vmware-tanzu:main Nov 9, 2021
@ywk253100
Copy link
Contributor

@alaypatel07 Could you open another PR to cherry-pick the fix into branch release-1.7?

@alaypatel07 alaypatel07 mentioned this pull request Nov 10, 2021
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants