Ensure only api app initializes secret store
Right now, the multiple secret store initialization code is run whenever the db is initialized - whether it be running the clean db script, starting the worker, starting the keystone listener or manage db script. This periodically causes deadlocks when the worker,listener and app are started soon after each other. Its not altogether clear why the deadlock happens, but the only table that is being written to is the secret_store table, which has no foreign keys etc. In any case, though, it was never the intention that anything other than the app itself initialize the secret stores from its config file. This patch makes sure that happens. Change-Id: I711b91b19b9d65260a21b41d6f9e18b9e282138a Closes-bug: 1738863
This commit is contained in:
parent
a74f898752
commit
0539a28ee9
barbican
@ -80,7 +80,9 @@ def main_app(func):
|
||||
# Initializing the database engine and session factory before the app
|
||||
# starts ensures we don't lose requests due to lazy initialization of
|
||||
# db connections.
|
||||
repositories.setup_database_engine_and_factory()
|
||||
repositories.setup_database_engine_and_factory(
|
||||
initialize_secret_stores=True
|
||||
)
|
||||
|
||||
wsgi_app = func(global_config, **local_conf)
|
||||
|
||||
|
@ -92,7 +92,7 @@ def hard_reset():
|
||||
setup_database_engine_and_factory()
|
||||
|
||||
|
||||
def setup_database_engine_and_factory():
|
||||
def setup_database_engine_and_factory(initialize_secret_stores=False):
|
||||
global sa_logger, _SESSION_FACTORY, _ENGINE
|
||||
|
||||
LOG.info('Setting up database engine and session factory')
|
||||
@ -109,7 +109,8 @@ def setup_database_engine_and_factory():
|
||||
# session instance per thread.
|
||||
session_maker = sa_orm.sessionmaker(bind=_ENGINE)
|
||||
_SESSION_FACTORY = sqlalchemy.orm.scoped_session(session_maker)
|
||||
_initialize_secret_stores_data()
|
||||
if initialize_secret_stores:
|
||||
_initialize_secret_stores_data()
|
||||
|
||||
|
||||
def start():
|
||||
|
Loading…
x
Reference in New Issue
Block a user