Repository navigation
compute: stop re-decoding server list pages in IsEmpty and NextPageURL - #4044
Merged
mandre merged 4 commits intoNov 12, 2026
Merged
Conversation
ServerPage.IsEmpty and ServerPage.NextPageURL both went through ExtractInto, which re-encodes the page body that pagination.PageResultFrom has already decoded and then parses it again. Together with the ExtractServers call in the EachPage handler, every page returned by servers.List was serialised three times and parsed four times, which gets expensive with many servers or large user_data. Read the servers list and servers_links from the decoded body instead and only fall back to ExtractInto when the body is not the decoded map. ExtractServers is now the only full decode per page. Add a two page List fixture, which was not covered before, and a test that counts body re-encodes. Fix: gophercloud#3867 Signed-off-by: Youssef Omar Bouden <[email protected]>
mandre
reviewed
Oct 21, 2026
IsEmpty and NextPageURL returned decoded values even when the page carried an error, and NextPageURL dropped servers_links values that were not []any, such as a hand built []gophercloud.Link. Both now return r.Err first, and the fast paths only answer when the decoded value has the expected shape; anything else goes through ExtractInto as before so conversions and decoding errors are preserved. Signed-off-by: Youssef Omar Bouden <[email protected]>
mandre
reviewed
Oct 22, 2026
Signed-off-by: Youssef Omar Bouden <[email protected]>
mandre
approved these changes
Nov 12, 2026
mandre
enabled auto-merge
November 12, 2026 14:28
|
Failed to backport PR to |
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.
Fixes #3867
Links to the line numbers/files in the OpenStack source code that support the
code in this PR:
https://github.com/openstack/nova/blob/stable/2025.1/nova/api/openstack/compute/views/servers.py#L581-L587
https://github.com/openstack/nova/blob/stable/2025.1/nova/api/openstack/common.py#L416-L446
ServerPage.IsEmptyandServerPage.NextPageURLboth went throughExtractInto, which marshals the body thatpagination.PageResultFromhas already decoded and parses it again. With anEachPagehandler callingExtractServers, every page was serialised three times and parsed four times. They now readserversandservers_linksfrom the decoded map and fall back toExtractIntowhen the body is not that map or whenserversorservers_linksare not lists of objects, so those cases still return the same errors and hand built pages still work. What changes is the validation of the fields inside each server:IsEmptyno longer decodes them, so a type mismatch there is reported byExtractServersinstead, one step later forEachPageand after the merge forAllPages. The generic decode inPageResultFromstays,AllPagesandGetBodydepend on it.On a synthetic page of 500 servers (2.2 MB, 4 KiB user_data each):
IsEmptyNextPageURLEachPageiterationThe remainder is
ExtractServersitself, which still marshals the body once; halving that needs changes in the root package and is left out here.Adds a two page List fixture, which was not covered before, and a test that counts body re-encodes. The same pattern applies to most other packages; the servers code can be lifted into a
paginationhelper if you want it adopted more widely.