Add the ability to configure glanceclient debug logging
It's currently not possible to configure debug logging for glanceclient, it's hard-coded to warning level. It would be great to be able to just change config and restart nova-compute, for example, when needing to debug issues with glance. Change-Id: I964e40085b68561af48b476c82288fc84d02bcc4
This commit is contained in:
parent
1d8836828b
commit
eb5dc52407
@ -76,6 +76,9 @@ Glance v2 will be a hard requirement in Ocata.
|
|||||||
default=False,
|
default=False,
|
||||||
help='Require Nova to perform signature verification on '
|
help='Require Nova to perform signature verification on '
|
||||||
'each image downloaded from Glance.'),
|
'each image downloaded from Glance.'),
|
||||||
|
cfg.BoolOpt('debug',
|
||||||
|
default=False,
|
||||||
|
help='Enable or disable debug logging with glanceclient.'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -26,16 +26,18 @@ from nova import version
|
|||||||
|
|
||||||
CONF = nova.conf.CONF
|
CONF = nova.conf.CONF
|
||||||
|
|
||||||
_EXTRA_DEFAULT_LOG_LEVELS = ['glanceclient=WARN']
|
|
||||||
|
|
||||||
|
|
||||||
def parse_args(argv, default_config_files=None, configure_db=True,
|
def parse_args(argv, default_config_files=None, configure_db=True,
|
||||||
init_rpc=True):
|
init_rpc=True):
|
||||||
log.register_options(CONF)
|
log.register_options(CONF)
|
||||||
# We use the oslo.log default log levels which includes suds=INFO
|
# We use the oslo.log default log levels which includes suds=INFO
|
||||||
# and add only the extra levels that Nova needs
|
# and add only the extra levels that Nova needs
|
||||||
|
if CONF.glance.debug:
|
||||||
|
extra_default_log_levels = ['glanceclient=DEBUG']
|
||||||
|
else:
|
||||||
|
extra_default_log_levels = ['glanceclient=WARN']
|
||||||
log.set_defaults(default_log_levels=log.get_default_log_levels() +
|
log.set_defaults(default_log_levels=log.get_default_log_levels() +
|
||||||
_EXTRA_DEFAULT_LOG_LEVELS)
|
extra_default_log_levels)
|
||||||
rpc.set_defaults(control_exchange='nova')
|
rpc.set_defaults(control_exchange='nova')
|
||||||
config.set_middleware_defaults()
|
config.set_middleware_defaults()
|
||||||
|
|
||||||
|
@ -16,9 +16,11 @@ import os
|
|||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
|
import mock
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
import nova.conf.virt
|
import nova.conf.virt
|
||||||
|
from nova import config
|
||||||
from nova import test
|
from nova import test
|
||||||
|
|
||||||
|
|
||||||
@ -80,3 +82,18 @@ class ConfTest(test.NoDBTestCase):
|
|||||||
# a dict.
|
# a dict.
|
||||||
actual = [{'node': '0', 'size': '2048', 'count': '64'}]
|
actual = [{'node': '0', 'size': '2048', 'count': '64'}]
|
||||||
self.assertEqual(actual, self.conf.reserved_huge_pages)
|
self.assertEqual(actual, self.conf.reserved_huge_pages)
|
||||||
|
|
||||||
|
|
||||||
|
class TestParseArgs(test.NoDBTestCase):
|
||||||
|
|
||||||
|
@mock.patch.object(config.log, 'register_options')
|
||||||
|
def test_parse_args_glance_debug_false(self, register_options):
|
||||||
|
self.flags(debug=False, group='glance')
|
||||||
|
config.parse_args([], configure_db=False, init_rpc=False)
|
||||||
|
self.assertIn('glanceclient=WARN', config.CONF.default_log_levels)
|
||||||
|
|
||||||
|
@mock.patch.object(config.log, 'register_options')
|
||||||
|
def test_parse_args_glance_debug_true(self, register_options):
|
||||||
|
self.flags(debug=True, group='glance')
|
||||||
|
config.parse_args([], configure_db=False, init_rpc=False)
|
||||||
|
self.assertIn('glanceclient=DEBUG', config.CONF.default_log_levels)
|
||||||
|
Loading…
Reference in New Issue
Block a user