diff --git a/nova/compute/manager.py b/nova/compute/manager.py index beec08f96b38..f6a5259b73d1 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -548,6 +548,7 @@ class ComputeManager(manager.Manager): LOG.info('Reloading compute RPC API') compute_rpcapi.LAST_VERSION = None self.compute_rpcapi = compute_rpcapi.ComputeAPI() + self._get_resource_tracker().reportclient.clear_provider_cache() def _get_resource_tracker(self): if not self._resource_tracker: diff --git a/nova/conf/compute.py b/nova/conf/compute.py index 9a404a6f21be..c364eee09629 100644 --- a/nova/conf/compute.py +++ b/nova/conf/compute.py @@ -652,6 +652,8 @@ Related options: default=300, min=0, mutable=True, + # TODO(efried): Provide more/better explanation of what this option is + # all about. Reference bug(s). Unless we're just going to remove it. help=""" Interval for updating nova-compute-side cache of the compute node resource provider's aggregates and traits info. @@ -662,6 +664,9 @@ node. A value of zero disables cache refresh completely. +The cache can be cleared manually at any time by sending SIGHUP to the compute +process, causing it to be repopulated the next time the data is accessed. + Possible values: * Any positive integer in seconds, or zero to disable refresh. diff --git a/nova/scheduler/client/report.py b/nova/scheduler/client/report.py index 1ec4b42b601e..a1e0ed6c0e9f 100644 --- a/nova/scheduler/client/report.py +++ b/nova/scheduler/client/report.py @@ -274,6 +274,11 @@ class SchedulerReportClient(object): # NOTE(danms): Keep track of how naggy we've been self._warn_count = 0 + def clear_provider_cache(self): + LOG.info("Clearing the report client's provider cache.") + self._provider_tree = provider_tree.ProviderTree() + self._association_refresh_time = {} + @utils.synchronized(PLACEMENT_CLIENT_SEMAPHORE) def _create_client(self): """Create the HTTP session accessing the placement service.""" diff --git a/nova/tests/unit/compute/test_compute_mgr.py b/nova/tests/unit/compute/test_compute_mgr.py index c1b8f4154a11..d6b12119a955 100644 --- a/nova/tests/unit/compute/test_compute_mgr.py +++ b/nova/tests/unit/compute/test_compute_mgr.py @@ -4744,6 +4744,20 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase): mock_rpc.assert_called_once_with() self.assertIsNot(orig_rpc, self.compute.compute_rpcapi) + def test_reset_clears_provider_cache(self): + # Seed the cache so we can tell we've cleared it + reportclient = self.compute._get_resource_tracker().reportclient + ptree = reportclient._provider_tree + ptree.new_root('foo', uuids.foo) + self.assertEqual([uuids.foo], ptree.get_provider_uuids()) + times = reportclient._association_refresh_time + times[uuids.foo] = time.time() + self.compute.reset() + ptree = reportclient._provider_tree + self.assertEqual([], ptree.get_provider_uuids()) + times = reportclient._association_refresh_time + self.assertEqual({}, times) + @mock.patch('nova.objects.BlockDeviceMappingList.get_by_instance_uuid') @mock.patch('nova.compute.manager.ComputeManager._delete_instance') def test_terminate_instance_no_bdm_volume_id(self, mock_delete_instance, diff --git a/releasenotes/notes/disable-rt-cache-refresh-9f6633e585516760.yaml b/releasenotes/notes/disable-rt-cache-refresh-9f6633e585516760.yaml index 98e1f69e23a2..05b21bef7142 100644 --- a/releasenotes/notes/disable-rt-cache-refresh-9f6633e585516760.yaml +++ b/releasenotes/notes/disable-rt-cache-refresh-9f6633e585516760.yaml @@ -7,4 +7,8 @@ features: 1767309`_ allowing more aggressive reduction in the amount of traffic to the placement service. + The cache can be cleared manually at any time by sending SIGHUP to the + compute process. This will cause the cache to be repopulated the next time + the data is accessed. + .. _`bug 1767309`: https://bugs.launchpad.net/nova/+bug/1767309