Comment 2 for bug 1705071

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/484900
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=d67d3459afd5271f09cc6bbeb0359ad419a4ec7a
Submitter: Jenkins
Branch: master

commit d67d3459afd5271f09cc6bbeb0359ad419a4ec7a
Author: Jay Pipes <email address hidden>
Date: Tue Jul 18 14:03:53 2017 -0400

    placement: alloc candidates only shared resources

    When attempting to perform a GET /allocation_candidates request for
    only resources that are shared, a KeyError was being produced:

    http://paste.openstack.org/show/615753/

    The problem is that the _get_usages_by_provider_and_rc() method returns
    a dict with only the sharing resource provider usage information but
    the _get_all_with_shared() returns a list of resource provider IDs
    including both the *sharing* resource provider *and* the shared-with
    providers.

    When the code attempts to cross-reference provider summaries (which are
    constructed by looping over the usage dicts) with each provider ID in
    the result from _get_all_with_shared(), we hit a KeyError on the
    shared-with provider IDs because there was no usage record (because the
    usage query filters on resource class ID and we requested only a
    resource class ID that was shared)

    This patch fixes the problem with a KeyError being produced for those
    providers that do not provide any resources (i.e. they are only
    included in the returned results because they have requested resource
    shared *with* them) by returning both the internal integer ID and the
    UUID of providers from the _get_all_shared_with() function and then in
    the loop to create allocation requests, simply ignoring any resource provider
    that doesn't exist in the provider_summaries dict.

    Closes-Bug: #1705071

    Change-Id: I742fd093a8b33ff88244b2990021784e4b65f51f