From 1a569e15c35d772a8ca236d75cd1840a415983d3 Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Mon, 15 Jan 2018 21:29:02 +0100 Subject: [PATCH] Fix Backup uses latest req-id for all log calls Currently all log entries will have the request ID of the latest request that was received in the Backup service. So you would receive a request with ID 1 and you would start logging that thread log calls with its ID, but as soon as you receive another request, let's say with ID 2, you will have both request logging with ID 2 instead of each one logging with its own request ID. The reason for this is that we are monkey patching after we have imported OSLO logging and we should be doing the monkey patching before, because OSLO logging imports OSLO context, which in turn imports threading and defines the _request_store where the context is stored as threading.local, which is not the monkey patched version and therefore will be shared among all the greenthreads that share the same python thread. To fix this we just move the monkey patching earlier in the imports. Closes-Bug: #1743461 Change-Id: I677a8e39de4292fe4fa8e70d7b6ae2fc3d5cf2ac --- cinder/cmd/backup.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cinder/cmd/backup.py b/cinder/cmd/backup.py index 8c913053b35..073435f9223 100644 --- a/cinder/cmd/backup.py +++ b/cinder/cmd/backup.py @@ -21,14 +21,18 @@ import logging as python_logging import shlex import sys +# NOTE(geguileo): Monkey patching must go before OSLO.log import, otherwise +# OSLO.context will not use greenthread thread local and all greenthreads will +# share the same context. import eventlet +eventlet.monkey_patch() + from oslo_config import cfg from oslo_log import log as logging from oslo_privsep import priv_context from oslo_reports import guru_meditation_report as gmr from oslo_reports import opts as gmr_opts -eventlet.monkey_patch() from cinder import i18n i18n.enable_lazy()