Move some config options into senlin_api group
This patch moves the following configuration options into the `senlin_api` group. This is gonna make the configuration step a lot easier. This patch also fixes the problem of namespace used for config file generation. Change-Id: Ia58426c73c59ce29b2cb463a76e78b713721b4fc
This commit is contained in:
parent
cfb851395b
commit
4ff266ec8a
@ -63,7 +63,7 @@ copyright = u'2015-present, OpenStack Foundation'
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
from senlin.version import version_info
|
||||
from senlin.version import version_info # NOQA
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = version_info.release_string()
|
||||
# The short X.Y version.
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
upgrade:
|
||||
- Several configuration options are consolidated into the 'senlin_api' group
|
||||
in 'senlin.conf' file ('api_paste_config', 'wsgi_keep_alive',
|
||||
'client_socket_timeout', 'max_json_body_size').
|
@ -58,11 +58,11 @@ class JSONRequestDeserializer(object):
|
||||
|
||||
def from_json(self, datastring):
|
||||
try:
|
||||
if len(datastring) > cfg.CONF.max_json_body_size:
|
||||
if len(datastring) > cfg.CONF.senlin_api.max_json_body_size:
|
||||
msg = _('JSON body size (%(len)s bytes) exceeds maximum '
|
||||
'allowed size (%(limit)s bytes).'
|
||||
) % {'len': len(datastring),
|
||||
'limit': cfg.CONF.max_json_body_size}
|
||||
'limit': cfg.CONF.senlin_api.max_json_body_size}
|
||||
raise exception.RequestLimitExceeded(message=msg)
|
||||
return jsonutils.loads(datastring)
|
||||
except ValueError as ex:
|
||||
|
@ -81,44 +81,31 @@ api_opts = [
|
||||
help=_('The value for the socket option TCP_KEEPIDLE. This is '
|
||||
'the time in seconds that the connection must be idle '
|
||||
'before TCP starts sending keepalive probes.')),
|
||||
cfg.StrOpt('api_paste_config', default="api-paste.ini",
|
||||
deprecated_group='paste_deploy',
|
||||
help=_("The API paste config file to use.")),
|
||||
cfg.BoolOpt('wsgi_keep_alive', default=True,
|
||||
deprecated_group='eventlet_opts',
|
||||
help=_("If false, closes the client socket explicitly.")),
|
||||
cfg.IntOpt('client_socket_timeout', default=900,
|
||||
deprecated_group='eventlet_opts',
|
||||
help=_("Timeout for client connections' socket operations. "
|
||||
"If an incoming connection is idle for this number of "
|
||||
"seconds it will be closed. A value of '0' indicates "
|
||||
"waiting forever.")),
|
||||
cfg.IntOpt('max_json_body_size', default=1048576,
|
||||
deprecated_group='DEFAULT',
|
||||
help=_('Maximum raw byte size of JSON request body.'
|
||||
' Should be larger than max_template_size.'))
|
||||
|
||||
]
|
||||
api_group = cfg.OptGroup('senlin_api')
|
||||
cfg.CONF.register_group(api_group)
|
||||
cfg.CONF.register_opts(api_opts, group=api_group)
|
||||
|
||||
# Paste-deploy, paste-deploy
|
||||
paste_deploy_group = cfg.OptGroup('paste_deploy')
|
||||
paste_deploy_opts = [
|
||||
cfg.StrOpt('api_paste_config', default="api-paste.ini",
|
||||
help=_("The API paste config file to use."))]
|
||||
cfg.CONF.register_group(paste_deploy_group)
|
||||
cfg.CONF.register_opts(paste_deploy_opts, group=paste_deploy_group)
|
||||
|
||||
# eventlet_opts, eventlet
|
||||
wsgi_eventlet_opts = [
|
||||
cfg.BoolOpt('wsgi_keep_alive', default=True,
|
||||
help=_("If false, closes the client socket explicitly.")),
|
||||
cfg.IntOpt('client_socket_timeout', default=900,
|
||||
help=_("Timeout for client connections' socket operations. "
|
||||
"If an incoming connection is idle for this number of "
|
||||
"seconds it will be closed. A value of '0' indicates "
|
||||
"waiting forever.")),
|
||||
]
|
||||
wsgi_eventlet_group = cfg.OptGroup('eventlet_opts')
|
||||
cfg.CONF.register_group(wsgi_eventlet_group)
|
||||
cfg.CONF.register_opts(wsgi_eventlet_opts, group=wsgi_eventlet_group)
|
||||
|
||||
json_size_opt = cfg.IntOpt('max_json_body_size', default=1048576,
|
||||
help=_('Maximum raw byte size of JSON request body.'
|
||||
' Should be larger than max_template_size.'))
|
||||
cfg.CONF.register_opt(json_size_opt)
|
||||
|
||||
|
||||
def wsgi_opts():
|
||||
yield None, [json_size_opt]
|
||||
yield paste_deploy_group.name, paste_deploy_opts
|
||||
yield api_group.name, api_opts
|
||||
yield wsgi_eventlet_group.name, wsgi_eventlet_opts
|
||||
|
||||
|
||||
def get_bind_addr(conf, default_port=None):
|
||||
@ -435,7 +422,7 @@ class Server(object):
|
||||
eventlet.hubs.use_hub('poll')
|
||||
eventlet.patcher.monkey_patch(all=False, socket=True)
|
||||
self.pool = eventlet.GreenPool(size=self.threads)
|
||||
socket_timeout = cfg.CONF.eventlet_opts.client_socket_timeout or None
|
||||
socket_timeout = cfg.CONF.senlin_api.client_socket_timeout or None
|
||||
|
||||
try:
|
||||
eventlet.wsgi.server(
|
||||
@ -444,7 +431,7 @@ class Server(object):
|
||||
url_length_limit=URL_LENGTH_LIMIT,
|
||||
log=self._logger,
|
||||
debug=cfg.CONF.debug,
|
||||
keepalive=cfg.CONF.eventlet_opts.wsgi_keep_alive,
|
||||
keepalive=cfg.CONF.senlin_api.wsgi_keep_alive,
|
||||
socket_timeout=socket_timeout)
|
||||
except socket.error as err:
|
||||
if err[0] != errno.EINVAL:
|
||||
@ -843,7 +830,7 @@ class Controller(object):
|
||||
|
||||
|
||||
def log_exception(err, exc_info):
|
||||
args = {'exc_info': exc_info} if cfg.CONF.verbose or cfg.CONF.debug else {}
|
||||
args = {'exc_info': exc_info}
|
||||
LOG.error(_LE("Unexpected error occurred serving API: %s"), err, **args)
|
||||
|
||||
|
||||
@ -969,8 +956,7 @@ def _get_deployment_config_file():
|
||||
|
||||
The retrieved item is formatted as an absolute pathname.
|
||||
"""
|
||||
config_path = cfg.CONF.find_file(
|
||||
cfg.CONF.paste_deploy['api_paste_config'])
|
||||
config_path = cfg.CONF.find_file(cfg.CONF.senlin_api.api_paste_config)
|
||||
if config_path is None:
|
||||
return None
|
||||
|
||||
|
@ -151,16 +151,17 @@ class JSONRequestDeserializerTest(base.SenlinTestCase):
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_from_json_exceeds_max_json_mb(self):
|
||||
cfg.CONF.set_override('max_json_body_size', 10, enforce_type=True)
|
||||
body = jsonutils.dumps(['a'] * cfg.CONF.max_json_body_size)
|
||||
self.assertGreater(len(body), cfg.CONF.max_json_body_size)
|
||||
cfg.CONF.set_override('max_json_body_size', 10, group='senlin_api',
|
||||
enforce_type=True)
|
||||
body = jsonutils.dumps(['a'] * cfg.CONF.senlin_api.max_json_body_size)
|
||||
self.assertGreater(len(body), cfg.CONF.senlin_api.max_json_body_size)
|
||||
obj = serializers.JSONRequestDeserializer()
|
||||
error = self.assertRaises(exception.RequestLimitExceeded,
|
||||
obj.from_json,
|
||||
body)
|
||||
msg = ('Request limit exceeded: JSON body size '
|
||||
'(%s bytes) exceeds maximum allowed size (%s bytes).'
|
||||
) % (len(body), cfg.CONF.max_json_body_size)
|
||||
) % (len(body), cfg.CONF.senlin_api.max_json_body_size)
|
||||
self.assertEqual(msg, six.text_type(error))
|
||||
|
||||
|
||||
|
@ -25,6 +25,8 @@ from senlin.api.common import wsgi
|
||||
from senlin.common import exception
|
||||
from senlin.tests.unit.common import base
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
||||
|
||||
class RequestTest(base.SenlinTestCase):
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
[DEFAULT]
|
||||
output_file = etc/senlin/senlin.conf.sample
|
||||
wrap_width = 119
|
||||
namespace = senlin.common.config
|
||||
namespace = senlin.config
|
||||
namespace = keystonemiddleware.auth_token
|
||||
namespace = oslo.db
|
||||
namespace = oslo.log
|
||||
|
Loading…
Reference in New Issue
Block a user