Fixed bug where the method _find_zone_or_region cannot see some instances #1203
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.
Fixed bug where _find_zone_or_region cannot see some instances
Description
The method
_find_zone_or_region
queries the google cloud api on the endpointinstances.aggregatedList
.This endpoint cannot return more than 500 results but has a pagination mechanic. The method
_find_zone_or_region
does not make use of the pagination mechanic because it made a manual request to the api.I removed the manual request and replaced it by the method
request_aggregated_items
that was made for this exact purpose.This bug was found while trying to use the libcloud in ansible (via the gce_snapshot ansible module) and getting an error
libcloud.common.google.ResourceNotFoundError: "Node 'node_name' not found in any zone."
.Indeed without the pagination, if a google cloud project has more than 500 instances, the code will crash when trying to identify the zone for a gce instance that wasn't in the 500 instances returned by the first api call.
Here is the stack trace I saw :
Status
ready for review
Checklist (tick everything that applies)
Python 2.7.13 :: Continuum Analytics, Inc.