Skip to content

[LIBCLOUD-826] [GCE]: Improve performance of list nodes by caching volume information#813

Closed
supertom wants to merge 1 commit into
apache:trunkfrom
supertom:LIBCLOUD-826
Closed

[LIBCLOUD-826] [GCE]: Improve performance of list nodes by caching volume information#813
supertom wants to merge 1 commit into
apache:trunkfrom
supertom:LIBCLOUD-826

Conversation

@supertom
Copy link
Copy Markdown
Contributor

@supertom supertom commented Jun 15, 2016

[GCE] Improve performance of list nodes by caching volume information

Description

When listing nodes, the GCE driver currently calls the disk API for each disk attached to the node. This PR changes that behavior by using the aggregatedLIst call for disks (once per list_node request) and using that information to provide disk details.

See sample performance info in LIBCLOUD-826

Implementation:

For disk information, aggregated calls are now always used and the disk information is stored in a dictionary, called 'volume_dict'. If the user would like the most current information, they may set the use_cache keyword to false and the call (and subsequent population of volume_dict) will be made prior to returning disk information.

Code was added/changed in two classes. In GCENodeDriver, added two methods and an additional parameter to build, lookup and toggle the refresh of the volume cache. In GCEConnection, added convenience and helper methods to the class, which not only support this performance improvement but also support the longer term vision of leveraging aggregatedList calls elsewhere.

GCEConnection
  • (new method) def request_aggregated_items(self, api_name) - make all necessary calls, handling maxresults and saving the 'items' portion of the response.
  • (new method) def _merge_response_items(self, list_name, response_list) - helper method to merge responses into a single dictionary
GCENodeDriver
  • (new member) volume_dict - dictionary organized by name, zone. Name is always available to us, but is not unique across zones. Zones, though, are optionally supplied. By organizing by name, we remove the need to search through the entire list of disks each time and can do a single hash lookup to have access to all disks by that name. If we have the zone, another hash lookup, if not, we take the first key alphabetically.
  • (new method) _build_name_zone_dict(self, zone_dict) - internal method to populate volume dict
  • (new method) _ex_populate_volume_dict(self) - Void method to call API and build volume dictionary
  • (new method) _ex_lookup_volume(self, name, zone=None) - implements the actual lookup. If zone is not provided, take the disk with that name from the (alphabetical) first zone (this is only an issue if there are more than two disks with the same name).
  • (new parameter) list_nodes(self, ex_zone=None, use_disk_cache=True) - use_disk_cache parameter for list_nodes to pass through, defaults to True. If set to true, no more than one call per 500 disks would be made to populate all disk info for nodes
  • (new parameter, revision) ex_get_volume(self, name, zone=None, use_cache=False) - revised to check if volume_dict has been populated or should be used, followed by returning the call to _ex_lookup_volume

Status

  • done, ready for review

Checklist (tick everything that applies)

  • Code linting (required, can be done after the PR checks)
  • Documentation
  • Tests
  • ICLA (required for bigger changes)

/cc @erjohnso /cc @tonybaloney

@supertom supertom changed the title [GCE] LIBCLOUD-826: Improve performance of list nodes by caching volume information [LIBCLOUD-826] [GCE]: Improve performance of list nodes by caching volume information Jun 16, 2016
Comment thread libcloud/compute/drivers/gce.py Outdated
:rtype: :class:`StorageVolume` or raise ``ResourceNotFoundError``.
"""
if volume_name not in self.volume_dict:
raise ResourceNotFoundError(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this instead make an API call in case the cache is missing a recently created disk?


return response

def request_aggregated_items(self, api_name):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this always returns only up to 500 items, as the if self.gce_params: condition few lines above will always evaluate to false.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sayap, fixed.

We leverage the aggregated disk call and store the result.  For the list node operation, we've added an extra parameter to use the cached data, which results to true.

Tests and fixtures updated as well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants