Return the cursor when listing applications without label filter - #7101
Open
vipulpandey21 wants to merge 1 commit into
Open
Return the cursor when listing applications without label filter#7101vipulpandey21 wants to merge 1 commit into
vipulpandey21 wants to merge 1 commit into
Conversation
ListApplications returns early when no label filter is given, and that path was not setting the Cursor field, so clients could never move to the next page. ListDeployments sets it in the same situation. Fixes pipe-cd#7100 Signed-off-by: Vipul Subhash Pandey <vipulpandey7917@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this PR does:
Sets the
Cursorfield on the responseAPIService.ListApplicationsreturns when the request has no label filter.Why we need it:
That early return was the only path in the function that did not set the cursor, so a client without a label filter always received an empty cursor and could not ask for the next page.
pipectl application listhas a documented--cursorflag but there was no value to pass to it.The other two returns in the same function set it, and
ListDeploymentssets it in the same situation. It also used to be set here before #4186 added label filtering. Details and the history I looked at are in #7100.I kept this to the one line. The label filtering loop below it has its own paging behaviour, which I did not touch.
How I tested it
Added
TestListApplicationsCursorcovering both the no label and the with label case.Without the fix the no label case fails:
With the fix:
go test ./pkg/app/server/grpcapi/...passes, andgo build ./cmd/pipecd ./cmd/pipectlis fine.One thing I wanted to be sure about before changing this: whether handing back a real cursor could make a client loop forever. It cannot, because
applicationStore.Listreturns an empty cursor once there are no more records:So a client that loops until the cursor is empty still terminates.
Which issue(s) this PR fixes:
Fixes #7100
Does this PR introduce a user-facing change?:
ListApplicationsandpipectl application listreturn a usable cursor when no label filter is given, so paging past the first page works. A client that loops until the cursor is empty now walks through all applications instead of stopping after the first page.