From 70c48ff6bbf7c4094da34a1af256ac7fbc032399 Mon Sep 17 00:00:00 2001 From: Neha Alhat Date: Tue, 26 Jun 2018 17:39:31 +0530 Subject: [PATCH] Enable split logging for cinder-glanceclient interaction To enable split logging functionality [1], need to register 'split_loggers' conf option under [default] section of cinder.conf This patch registers 'split_loggers' conf option under [default] so that operator can set value of 'split_loggers' to True to enable split logging. [1]: https://review.openstack.org/#/c/505764/ DocImpact Change-Id: I05639133c7e5770e810be97d8c6bb98450c8c9ba --- cinder/common/config.py | 3 +++ cinder/image/glance.py | 6 ++++-- cinder/tests/unit/image/test_glance.py | 6 ++++-- ...dd-split-logger-conf-option-0424e3bd91de3a5a.yaml | 12 ++++++++++++ 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/add-split-logger-conf-option-0424e3bd91de3a5a.yaml diff --git a/cinder/common/config.py b/cinder/common/config.py index 9b59760d506..731cb1febbb 100644 --- a/cinder/common/config.py +++ b/cinder/common/config.py @@ -175,6 +175,9 @@ global_opts = [ cfg.StrOpt('group_api_class', default='cinder.group.api.API', help='The full class name of the group API class'), + cfg.BoolOpt('split_loggers', + default=False, + help='Log requests to multiple loggers.') ] CONF.register_opts(core_opts) diff --git a/cinder/image/glance.py b/cinder/image/glance.py index 381a32aa578..476ca7f8552 100644 --- a/cinder/image/glance.py +++ b/cinder/image/glance.py @@ -114,14 +114,16 @@ def _create_glance_client(context, netloc, use_ssl): if use_ssl and CONF.auth_strategy == 'noauth': params = {'insecure': CONF.glance_api_insecure, 'cacert': CONF.glance_ca_certificates_file, - 'timeout': CONF.glance_request_timeout + 'timeout': CONF.glance_request_timeout, + 'split_loggers': CONF.split_loggers } if CONF.auth_strategy == 'keystone': global _SESSION if not _SESSION: config_options = {'insecure': CONF.glance_api_insecure, 'cacert': CONF.glance_ca_certificates_file, - 'timeout': CONF.glance_request_timeout + 'timeout': CONF.glance_request_timeout, + 'split_loggers': CONF.split_loggers } _SESSION = ks_session.Session().load_from_options(**config_options) diff --git a/cinder/tests/unit/image/test_glance.py b/cinder/tests/unit/image/test_glance.py index 7809ee47d29..49c69baaed5 100644 --- a/cinder/tests/unit/image/test_glance.py +++ b/cinder/tests/unit/image/test_glance.py @@ -972,7 +972,8 @@ class TestGlanceImageServiceClient(test.TestCase): config_options = {'insecure': False, 'cacert': None, - 'timeout': None} + 'timeout': None, + 'split_loggers': False} mock_get_auth_plugin.return_value = context._ContextAuthPlugin mock_load.return_value = session.Session @@ -1003,7 +1004,8 @@ class TestGlanceImageServiceClient(test.TestCase): config_options = {'insecure': False, 'cacert': '/opt/stack/data/ca-bundle.pem', - 'timeout': 60} + 'timeout': 60, + 'split_loggers': False} mock_get_auth_plugin.return_value = context._ContextAuthPlugin mock_load.return_value = session.Session diff --git a/releasenotes/notes/add-split-logger-conf-option-0424e3bd91de3a5a.yaml b/releasenotes/notes/add-split-logger-conf-option-0424e3bd91de3a5a.yaml new file mode 100644 index 00000000000..f29f5010774 --- /dev/null +++ b/releasenotes/notes/add-split-logger-conf-option-0424e3bd91de3a5a.yaml @@ -0,0 +1,12 @@ +--- +features: + - | + Added boolean conf option 'split_loggers' in [default] section of + cinder.conf to `enable split logging`_ functionality. The default + value of split_loggers option is set to False. Operator can set it's + value to True to split HTTP content into subloggers to allow for + fine-grained control of what is logged and how. This new config option + 'split_loggers' should be enabled only when keystoneauth log level is + set to DEBUG in 'default_log_levels' config option. + + .. _`enable split logging`: https://docs.openstack.org/keystoneauth/latest/using-sessions.html#logging