From 67c761cb2c32d130bcb4bcb1c97ac65e828f6c80 Mon Sep 17 00:00:00 2001 From: melanie witt Date: Thu, 12 Jul 2018 18:27:59 +0000 Subject: [PATCH] Don't overwrite greenthread-local context in host manager There are a couple of places in host manager where we create a blank RequestContext for internal database operations without passing overwrite=False, so they will overwrite the greenthread-local context that will be used for logging request_id, replacing them with newly generated request_ids. This changes the RequestContext creations to get_admin_context calls, (which uses overwrite=False) to be more explicit about the admin-ness of the internal database operations we're doing in these methods. Related-Bug: #1773102 Change-Id: I752eb677d9ccc5ec65147380efe4067456fa312b --- nova/scheduler/host_manager.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nova/scheduler/host_manager.py b/nova/scheduler/host_manager.py index 489e1fb051ec..d723211f02b6 100644 --- a/nova/scheduler/host_manager.py +++ b/nova/scheduler/host_manager.py @@ -418,7 +418,7 @@ class HostManager(object): """ def _async_init_instance_info(computes_by_cell): - context = context_module.RequestContext() + context = context_module.get_admin_context() LOG.debug("START:_async_init_instance_info") self._instance_info = {} @@ -449,7 +449,7 @@ class HostManager(object): "deleted": False} with context_module.target_cell(context, cell) as cctxt: result = objects.InstanceList.get_by_filters( - cctxt.elevated(), filters) + cctxt, filters) instances = result.objects LOG.debug("Adding %s instances for hosts %s-%s", len(instances), start_node, end_node) @@ -642,7 +642,7 @@ class HostManager(object): def refresh_cells_caches(self): # NOTE(tssurya): This function is called from the scheduler manager's # reset signal handler and also upon startup of the scheduler. - context = context_module.RequestContext() + context = context_module.get_admin_context() temp_cells = objects.CellMappingList.get_all(context) # NOTE(tssurya): filtering cell0 from the list since it need # not be considered for scheduling.