While testing the Create server API with the master branch, I noticed from the (Compute server) logs that the context was getting set to None intermittently. After digging more into the issue, it looks like the calls to the 'get_admin_context( )' method in nova.context module is causing this.
If we trace the a request's path from the server logs, the context information needs to be available throughout the processing cycle of the request. However, since the calls to 'get_admin_context' sets the context to None, the '_log' method in NovaLogger fails to find the context and logs the messages without the request_id field. This results in the log messages after the call to 'get_admin_context' getting logged without request_id in it.
Same is also the case with the log messages after 'elevated' method is called.
This method needs to be fixed, so that a request path can be easily traced from the server logs.
I would propose all of the get_admin_context calls are converted to elevated. We should never be calling get_admin_context if we already have a context available. Then we can make elevated not clobber the local context.