Merge "SIGHUP n-cpu to clear provider tree cache"

This commit is contained in:
Zuul 2018-12-04 02:23:39 +00:00 committed by Gerrit Code Review
commit 33c3759b85
5 changed files with 29 additions and 0 deletions

View File

@ -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:

View File

@ -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.

View File

@ -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."""

View File

@ -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,

View File

@ -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