Make association_refresh configurable

The provider-tree refresh in the SchedulerReportClient() instance
of each compute node happens every five minutes as it is hard coded.
This patch adds this update interval as a new config option which
can be set/changed on each compute node.

Change-Id: I00f92aac44d7b0169f94940ef389796c782b0cc1
Closes-Bug: #1767309
This commit is contained in:
Surya Seetharaman 2018-05-01 17:51:10 +02:00
parent c15a0139af
commit 41d6b479fe
4 changed files with 34 additions and 9 deletions

View File

@ -640,6 +640,21 @@ Possible values:
Related options: Related options:
* ``shutdown_timeout`` * ``shutdown_timeout``
"""),
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.
""") """)
] ]

View File

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

View File

@ -2273,14 +2273,16 @@ class TestAssociations(SchedulerReportClientTestCase):
with mock.patch('time.time') as mock_future: with mock.patch('time.time') as mock_future:
# Not called a second time because not enough time has passed. # 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) self.client._refresh_associations(self.context, uuid)
mock_agg_get.assert_not_called() mock_agg_get.assert_not_called()
mock_trait_get.assert_not_called() mock_trait_get.assert_not_called()
mock_shr_get.assert_not_called() mock_shr_get.assert_not_called()
# Called because time has passed. # 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) self.client._refresh_associations(self.context, uuid)
mock_agg_get.assert_called_once_with(self.context, uuid) mock_agg_get.assert_called_once_with(self.context, uuid)
mock_trait_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.