Handle paginated responses potentially being disabled
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
OpenStack SDK |
Fix Released
|
Undecided
|
Brian Curtin |
Bug Description
Resources which respond with paginated bodies can have the pagination ability disabled. Currently, Neutron on devstack seems to do this, and Britt Houser reported this being the case in his internal environment.
According to at least the Neutron docs, pagination being enabled or disabled is not discoverable. If you make a request to /networks and pass parameters like limit or marker, they'll be accepted if pagination is enabled, or silently discarded if pagination is disabled. Silently discarding is where the problem lies.
In the disabled case, it causes our list generator to enter an infinite loop. We get back a body, make another call with the marker param set to the last ID in the list, get back the same body, set that same marker again, and on and on and on.
A possibility to solve this would be adding a User Preference to set whether or not pagination is supported, but this means we'd need to choose a default of our own. It also puts an additional configuration burden on the user to know this, and has potentially strong implications if set improperly.
* Disabled by default means we don't take advantage of what seem to be most services enabling pagination by default, thus causing larger responses and slower response time.
* Enabled by default means what we currently have, where some things may cause infinite loops or otherwise be broken.
One possible way of being smart about this would be to shift when we start yielding responses. Currently we make a request, get a response, yield from that response, then make another request. We can determine if pagination isn't supported by holding off on yielding until we've made the next request, e.g., req1, resp1, req2, if resp1 != resp2 then yield resp1, req3, if resp2 != resp3 then yield resp2, etc.
The User Preference part will work, but I'm going to see if the self-discovery part is feasible. It might be weird, it might work.
Changed in python-openstacksdk: | |
status: | New → In Progress |
assignee: | nobody → Brian Curtin (brian.curtin) |
Changed in python-openstacksdk: | |
milestone: | none → kilo |
Changed in python-openstacksdk: | |
status: | In Progress → Fix Released |
Change abandoned by Brian Curtin (<email address hidden>) on branch: master /review. openstack. org/147686
Review: https:/
Reason: This is too heavy-handed to be a general purpose solution. The way forward is to use page for one page responses, and list for paginated responses. We'll make them look the same in the higher level so in the end the problem is solved.