Make logging option values configurable

It is not always desirable to log full set of conf at service
start. This change adds new option "log_options" that allows to
enable or disable logging values of all registered options.

Also moved list_opts function for service submodule to service.py
as service and eventlet_backdoor opts have to be grouped together
and changed the entrypoint accordingly.

Change-Id: I2a97ebf736fd361e6f1d05796d5077bc9627ff85
Closes-Bug: #1461250
This commit is contained in:
Elena Ezhova 2015-06-05 14:19:44 +03:00
parent 2988ec7b2a
commit 8c56f24291
4 changed files with 24 additions and 12 deletions

View File

@ -34,6 +34,13 @@ periodic_opts = [
'Should we run them here?'),
]
service_opts = [
cfg.BoolOpt('log_options',
default=True,
help='Enables or disables logging values of all registered '
'options when starting a service (at DEBUG level).'),
]
ssl_opts = [
cfg.StrOpt('ca_file',
help="CA certificate file to use to verify "

View File

@ -16,7 +16,6 @@
from __future__ import print_function
import copy
import errno
import gc
import logging
@ -39,12 +38,6 @@ CONF.register_opts(_options.eventlet_backdoor_opts)
LOG = logging.getLogger(__name__)
def list_opts():
"""Entry point for oslo-config-generator.
"""
return [(None, copy.deepcopy(_options.eventlet_backdoor_opts))]
class EventletBackdoorConfigValueError(Exception):
def __init__(self, port_range, help_msg, ex):
msg = ('Invalid backdoor_port configuration %(range)s: %(ex)s. '

View File

@ -29,6 +29,7 @@ one instance of ServiceLauncher and ProcessLauncher classes per process.
"""
import abc
import copy
import errno
import io
import logging
@ -45,14 +46,23 @@ from oslo_config import cfg
from oslo_service import eventlet_backdoor
from oslo_service._i18n import _LE, _LI, _LW
from oslo_service import _options
from oslo_service import systemd
from oslo_service import threadgroup
CONF = cfg.CONF
CONF.register_opts(_options.service_opts)
LOG = logging.getLogger(__name__)
def list_opts():
"""Entry point for oslo-config-generator."""
return [(None, copy.deepcopy(_options.eventlet_backdoor_opts +
_options.service_opts))]
def _sighup_supported():
return hasattr(signal, 'SIGHUP')
@ -191,8 +201,9 @@ class ServiceLauncher(Launcher):
status = None
signo = 0
LOG.debug('Full set of CONF:')
CONF.log_opt_values(LOG, logging.DEBUG)
if CONF.log_options:
LOG.debug('Full set of CONF:')
CONF.log_opt_values(LOG, logging.DEBUG)
try:
if ready_callback:
@ -410,8 +421,9 @@ class ProcessLauncher(object):
"""Loop waiting on children to die and respawning as necessary."""
systemd.notify_once()
LOG.debug('Full set of CONF:')
CONF.log_opt_values(LOG, logging.DEBUG)
if CONF.log_options:
LOG.debug('Full set of CONF:')
CONF.log_opt_values(LOG, logging.DEBUG)
try:
while True:

View File

@ -30,7 +30,7 @@ warnerrors = true
[entry_points]
oslo.config.opts =
oslo.service.periodic_task = oslo_service.periodic_task:list_opts
oslo.service.service = oslo_service.eventlet_backdoor:list_opts
oslo.service.service = oslo_service.service:list_opts
oslo.service.sslutils = oslo_service.sslutils:list_opts
[build_sphinx]