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

Add pagination support for show/list spire-server CLI commands that use List APIs #2443

Closed
rturner3 opened this issue Aug 5, 2021 · 5 comments · Fixed by #2456 or #3135
Closed

Add pagination support for show/list spire-server CLI commands that use List APIs #2443

rturner3 opened this issue Aug 5, 2021 · 5 comments · Fixed by #2456 or #3135
Labels
good first issue Issues with this label are good candidates for first-time contributions

Comments

@rturner3
Copy link
Collaborator

rturner3 commented Aug 5, 2021

When using the spire-server CLI to fetch data via SPIRE Server APIs with commands like entry show or agent list, if the amount of data returned by the SPIRE Server APIs exceeds the gRPC default max response size of 4 MB, the entire command fails to execute.

For larger scale environments, this greatly reduces the usefulness of these CLI commands, since many times the command fails due to too much data being returned by the Server. It would be very helpful in such cases if these CLI commands used pagination in their Server API requests so that the data can actually be presented to the user, since the Server APIs are implemented with gRPC and are not otherwise easy to invoke without writing a custom application.

@sachinkumarsingh092
Copy link
Contributor

@rturner3 aren't we already paginating the response from the server API and then using the same for listings?

@rturner3
Copy link
Collaborator Author

rturner3 commented Aug 9, 2021

In order for the server to use pagination, the client needs to set the page_size field to a value > 0 for each request, and for all but the first request, the client needs to set the page_token field to the value of next_page_token from the previous response. The CLI commands are not setting page_size or page_token in the API request messages today.

See ListAgents and ListEntries handlers for reference.

@rturner3 rturner3 added the good first issue Issues with this label are good candidates for first-time contributions label Aug 10, 2021
@sachinkumarsingh092
Copy link
Contributor

@rturner3 what would be a good page_size and page_token value to be set here? I think this should fix the pagination for the above two references (ListAgents and ListEntries).

@rturner3
Copy link
Collaborator Author

The page size should depend on the approximated maximum size of each entity represented as a serialized protobuf message.

Taking ListAgentsResponse as one example, we need to consider the maximum number of bytes it may take to represent an Agent, and the maximum size of a page token (size of a UUID represented as a string).

The page token in the request message is directly copied from the previous response message, e.g. for ListAgents: https://github.com/spiffe/spire-api-sdk/blob/7ff3eb0759ce242a38fd02aa368b3d7a33ac7316/proto/spire/api/server/agent/v1/agent.proto#L103

@rturner3
Copy link
Collaborator Author

rturner3 commented Jan 6, 2022

The entry show command was never updated to use pagination. Re-opening this issue until that is completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Issues with this label are good candidates for first-time contributions
Projects
None yet
2 participants