libcloud icon indicating copy to clipboard operation
libcloud copied to clipboard

list_nodes on GCE Projects Only Returns 500 Results

Open TheSushiChef opened this issue 7 years ago • 2 comments

Summary

When running list_nodes against a GCE environment that has greater than 500 instances, only the top 500 results will be returned.

Detailed Information

Using libcloud 2.6.0, running list_nodes using the GCE Provider will only return the top 500 results. This is similar to issue #1203 where the list_nodes function is running self.connection.request rather than self.connection.request_aggregated_items.

I believe changing lines 19-23 of the list_nodes function to something like this will fix the issue:

if zone is None:
        response = self.connection.request_aggregated_items('instances')
    else:
        request = '/zones/%s/instances' % (zone.name)
        response = self.connection.request(request, method='GET').object

TheSushiChef avatar Oct 29 '19 01:10 TheSushiChef

@erjohnso Maybe you have an input on this issue?

request_aggregated_items approach seems reasonable to me, I don't have any account with that many instances to test it, but I guess I could also decrease page size (maxResults) to test that change.

On a related note, I assume we also need to correctly handle pagination when user explicitly specifies a zone to use?

Kami avatar Jan 14 '20 05:01 Kami

#1409 should fix this issue.

Kami avatar Jan 20 '20 06:01 Kami