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.
Reviewed: https:/ /review. openstack. org/484900 /git.openstack. org/cgit/ openstack/ nova/commit/ ?id=d67d3459afd 5271f09cc6bbeb0 359ad419a4ec7a
Committed: https:/
Submitter: Jenkins
Branch: master
commit d67d3459afd5271 f09cc6bbeb0359a d419a4ec7a
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 with_shared( ) returns a list of resource provider IDs
a dict with only the sharing resource provider usage information but
the _get_all_
including both the *sharing* resource provider *and* the shared-with
providers.
When the code attempts to cross-reference provider summaries (which are with_shared( ), we hit a KeyError on the
constructed by looping over the usage dicts) with each provider ID in
the result from _get_all_
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 shared_ with() function and then in
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_
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: I742fd093a8b33f f88244b29900217 84e4b65f51f