Init config before service start

registering options during oslo.service start can result in a race with
oslo.service's own startup logging of options, producing error

RuntimeError: dictionary changed size during iteration

Groups found to be responsible are [ssl] (from oslo_service.sslutils)
and [keystone_authtoken] (from keystonemiddleware.auth_token).

This was cought when starting designate-api with `--log-config-append`
option with extra logging config containing many handlers
(some are heavier to init than others, like fluentd),
thus introducing enough time lapse for race to surface.

Change-Id: I2295d91077b5cdc905eafa6f24a7b73168ceb1aa
This commit is contained in:
Pavlo Shchelokovskyy 2018-06-20 14:18:58 +00:00
parent fe60c5b11e
commit 056ceb7f4b
2 changed files with 3 additions and 1 deletions

View File

@ -29,6 +29,7 @@ from designate.api import service as api_service
CONF = cfg.CONF
CONF.import_opt('workers', 'designate.api', group='service:api')
CONF.import_opt('threads', 'designate.api', group='service:api')
cfg.CONF.import_group('keystone_authtoken', 'keystonemiddleware.auth_token')
def main():

View File

@ -214,6 +214,7 @@ class WSGIService(object):
def __init__(self, *args, **kwargs):
super(WSGIService, self).__init__(*args, **kwargs)
self._use_ssl = sslutils.is_enabled(CONF)
self._wsgi_socks = []
@abc.abstractproperty
@ -232,7 +233,7 @@ class WSGIService(object):
wsgi_sock = utils.bind_tcp(
host, port, CONF.backlog, CONF.tcp_keepidle)
if sslutils.is_enabled(CONF):
if self._use_ssl:
wsgi_sock = sslutils.wrap(CONF, wsgi_sock)
self._wsgi_socks.append(wsgi_sock)