From 3a39cfc471953f95b692c15ce2175bf92035a2da Mon Sep 17 00:00:00 2001 From: Surya Seetharaman Date: Tue, 1 May 2018 17:51:10 +0200 Subject: [PATCH] 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. Conflicts: nova/conf/compute.py - because 197539d7a050042463802f6ece98473bbbf9743b is missing in Queens. nova/scheduler/client/report.py - because f05e6279d092f9d53291ddf69c99a71bfe3989bf is missing in Queens. Change-Id: I00f92aac44d7b0169f94940ef389796c782b0cc1 Closes-Bug: #1767309 (cherry picked from commit 41d6b479fe8baf66578044b8773c3b892d64a2c4) --- nova/conf/compute.py | 15 +++++++++++++++ nova/scheduler/client/report.py | 13 ++++++------- nova/tests/unit/scheduler/client/test_report.py | 6 ++++-- ...ation-refresh-config-opt-d1ca1af238d10c9a.yaml | 9 +++++++++ 4 files changed, 34 insertions(+), 9 deletions(-) create mode 100644 releasenotes/notes/add-association-refresh-config-opt-d1ca1af238d10c9a.yaml diff --git a/nova/conf/compute.py b/nova/conf/compute.py index a2e516fb96b5..ecf39b721c26 100644 --- a/nova/conf/compute.py +++ b/nova/conf/compute.py @@ -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 = [ diff --git a/nova/scheduler/client/report.py b/nova/scheduler/client/report.py index 553b2904bcc9..532040b1f815 100644 --- a/nova/scheduler/client/report.py +++ b/nova/scheduler/client/report.py @@ -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' @@ -743,8 +740,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 @@ -812,10 +809,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. diff --git a/nova/tests/unit/scheduler/client/test_report.py b/nova/tests/unit/scheduler/client/test_report.py index 76db4b30e9f0..e544b50257bf 100644 --- a/nova/tests/unit/scheduler/client/test_report.py +++ b/nova/tests/unit/scheduler/client/test_report.py @@ -2399,14 +2399,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) diff --git a/releasenotes/notes/add-association-refresh-config-opt-d1ca1af238d10c9a.yaml b/releasenotes/notes/add-association-refresh-config-opt-d1ca1af238d10c9a.yaml new file mode 100644 index 000000000000..7df3c2c6b4ff --- /dev/null +++ b/releasenotes/notes/add-association-refresh-config-opt-d1ca1af238d10c9a.yaml @@ -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.