Merge "Make association_refresh configurable" into stable/queens

This commit is contained in:
Zuul 2018-05-09 22:48:18 +00:00 committed by Gerrit Code Review
commit 00c2497209
4 changed files with 34 additions and 9 deletions

View File

@ -643,6 +643,21 @@ Possible values:
* Any positive integer representing a build failure count.
* Zero to never auto-disable.
"""),
cfg.IntOpt('resource_provider_association_refresh',
default=300,
min=1,
help="""
Interval for updating nova-compute-side cache of the compute node resource
provider's aggregates and traits info.
This option specifies the number of seconds between attempts to update a
provider's aggregates and traits information in the local cache of the compute
node.
Possible values:
* Any positive integer in seconds.
""")
]
interval_opts = [

View File

@ -44,9 +44,6 @@ _RE_INV_IN_USE = re.compile("Inventory for (.+) on resource provider "
"(.+) in use")
WARN_EVERY = 10
PLACEMENT_CLIENT_SEMAPHORE = 'placement_client'
# Number of seconds between attempts to update a provider's aggregates and
# traits
ASSOCIATION_REFRESH = 300
NESTED_PROVIDER_API_VERSION = '1.14'
POST_ALLOCATIONS_API_VERSION = '1.13'
@ -751,8 +748,8 @@ class SchedulerReportClient(object):
sharing providers for the specified resource provider uuid.
Only refresh if there has been no refresh during the lifetime of
this process, ASSOCIATION_REFRESH seconds have passed, or the force arg
has been set to True.
this process, CONF.compute.resource_provider_association_refresh
seconds have passed, or the force arg has been set to True.
Note that we do *not* refresh inventories. The reason is largely
historical: all code paths that get us here are doing inventory refresh
@ -820,10 +817,12 @@ class SchedulerReportClient(object):
"recently".
It is old if association_refresh_time for this uuid is not set
or more than ASSOCIATION_REFRESH seconds ago.
or more than CONF.compute.resource_provider_association_refresh
seconds ago.
"""
refresh_time = self.association_refresh_time.get(uuid, 0)
return (time.time() - refresh_time) > ASSOCIATION_REFRESH
return ((time.time() - refresh_time) >
CONF.compute.resource_provider_association_refresh)
def _update_inventory_attempt(self, context, rp_uuid, inv_data):
"""Update the inventory for this resource provider if needed.

View File

@ -2431,14 +2431,16 @@ class TestAssociations(SchedulerReportClientTestCase):
with mock.patch('time.time') as mock_future:
# Not called a second time because not enough time has passed.
mock_future.return_value = now + report.ASSOCIATION_REFRESH / 2
mock_future.return_value = (now +
CONF.compute.resource_provider_association_refresh / 2)
self.client._refresh_associations(self.context, uuid)
mock_agg_get.assert_not_called()
mock_trait_get.assert_not_called()
mock_shr_get.assert_not_called()
# Called because time has passed.
mock_future.return_value = now + report.ASSOCIATION_REFRESH + 1
mock_future.return_value = (now +
CONF.compute.resource_provider_association_refresh + 1)
self.client._refresh_associations(self.context, uuid)
mock_agg_get.assert_called_once_with(self.context, uuid)
mock_trait_get.assert_called_once_with(self.context, uuid)

View File

@ -0,0 +1,9 @@
---
fixes:
- |
The nova-compute service now allows specifying the interval for updating
nova-compute-side cache of the compute node resource provider's aggregates
and traits info via a new config option called
``[compute]/resource_provider_association_refresh`` which defaults to 300.
This was previously hard-coded to run every 300 seconds which may be too
often in a large deployment.