Repository navigation
Conversation
clientv3.WithPrefix computes the range end from the key of each request. After the first chunk the key is the last key returned plus a NUL byte, so the next request only covered keys under that key, returned nothing and ended the loop. augerctl get, which pages by 500 by default, listed at most one chunk of any resource. Use WithRange with the range end of the whole prefix for every chunk. Signed-off-by: Lucas Barros <lucasbarros.kam@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: lbarrosby The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
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.
client.Getpages through a prefix withclientv3.WithPrefix()andWithLimit(chunkSize), and for the next page it moves the key to the last key returned plus\x00.WithPrefixdoes not keep the range of the original prefix. It computes the range end from the key of each request (op.end = getPrefix(op.key)). So the second request asks for[/registry/pods/default/pod-2\x00, /registry/pods/default/pod-2\x01), gets nothing back withMore: false, and the loop stops.augerctl getpages with--chunk-size 500by default, so any resource with more than 500 objects was listed only up to the first chunk, with no error. With a smaller--chunk-sizethe truncation shows up sooner.The chunked branch now uses
WithRange(clientv3.GetPrefixRangeEnd(path))with the limit (and the pinned revision), so every page stays inside the prefix. The single-key and unpaged paths are unchanged.TestGetChunkedReturnsEveryKeyrunsGeton aclientv3.Clientwhose KV is a small fake that serves[key, end)withlimitandMorethe way etcd does. It covers one chunk, several chunks, and several chunks with--limit. On main the two multi-chunk cases return 3 of the 8 pods. With the fix all cases return every key in order.go test ./pkg/... ./cmd/...andgolangci-lint run --config tools/.golangci.yaml ./...are clean.AI disclosure: written with the help of Claude Code, reviewed and tested by me.