From e4989c103ff23cbf937faa8cc12c39e9720f9fd7 Mon Sep 17 00:00:00 2001
From: Matt Riedemann <mriedem.os@gmail.com>
Date: Thu, 25 Jan 2018 15:50:34 -0500
Subject: [PATCH] backup: set default swiftclient log level to WARN

Similar to change I0857cecd7d8ab0ee7e3e9bd6e15f4987ede4d653, the
swift backup driver cannot be logging stuff while in a thread during
read and write operations. swiftclient logs requests and responses
at DEBUG level, which can cause a thread switch and break the backup
operation.

This sets a default log level of WARN for swiftclient for the
cinder-backup service.

Change-Id: I67ac11276715290839c39fc1d0e333c61a38c461
Closes-Bug: #1745168
---
 cinder/cmd/backup.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/cinder/cmd/backup.py b/cinder/cmd/backup.py
index 073435f9223..d6d4b8c3daf 100644
--- a/cinder/cmd/backup.py
+++ b/cinder/cmd/backup.py
@@ -47,12 +47,21 @@ from cinder import version
 
 CONF = cfg.CONF
 
+# NOTE(mriedem): The default backup driver uses swift and performs read/write
+# operations in a thread. swiftclient will log requests and responses at DEBUG
+# level, which can cause a thread switch and break the backup operation. So we
+# set a default log level of WARN for swiftclient to try and avoid this issue.
+_EXTRA_DEFAULT_LOG_LEVELS = ['swiftclient=WARN']
+
 
 def main():
     objects.register_all()
     gmr_opts.set_defaults(CONF)
     CONF(sys.argv[1:], project='cinder',
          version=version.version_string())
+    logging.set_defaults(
+        default_log_levels=logging.get_default_log_levels() +
+        _EXTRA_DEFAULT_LOG_LEVELS)
     logging.setup(CONF, "cinder")
     python_logging.captureWarnings(True)
     priv_context.init(root_helper=shlex.split(utils.get_root_helper()))