[placement] Do not import oslo_service for log_options

Placement does not use oslo_service, but it is imported for one single
configuration option: "log_options".

This change duplicates that option info nova/conf/placement.py (in the
DEFAULT group) so that oslo_service doesn't need to be imported and its
dependencies (e.g., eventlet) are also not imported.

This is relevant for at least two reasons:

* When running placement in isolation (such as a container) we don't
  want to have to include packages aren't really used

* When placement is extracted we don't want to require things (in
  requirements.txt) that aren't really used.

Change-Id: I5a19cd3e18bb8c0e0ad2d79f54194f8b941ce307
This commit is contained in:
Chris Dent 2018-06-04 17:09:21 -07:00
parent f902e0d5d8
commit 1d57be40be
2 changed files with 14 additions and 6 deletions

View File

@ -19,7 +19,6 @@ import os
import os.path
from oslo_log import log as logging
from oslo_service import _options as service_opts
from nova.api.openstack.placement import deploy
from nova import conf
@ -56,11 +55,7 @@ def init_application():
# initialize the logging system
setup_logging(conf.CONF)
# dump conf at debug (log_options option comes from oslo.service)
# FIXME(mriedem): This is gross but we don't have a public hook into
# oslo.service to register these options, so we are doing it manually for
# now; remove this when we have a hook method into oslo.service.
conf.CONF.register_opts(service_opts.service_opts)
# dump conf at debug if log_options
if conf.CONF.log_options:
conf.CONF.log_opt_values(
logging.getLogger(__name__),

View File

@ -47,9 +47,22 @@ is determined.
]
# Duplicate log_options from oslo_service so that we don't have to import
# that package into placement.
# NOTE(cdent): Doing so ends up requiring eventlet and other unnecessary
# packages for just this one setting.
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).'),
]
def register_opts(conf):
conf.register_group(placement_group)
conf.register_opts(placement_opts, group=placement_group)
conf.register_opts(service_opts)
confutils.register_ksa_opts(conf, placement_group, DEFAULT_SERVICE_TYPE)