Fix compatibility with oslo.db 12.1.0

oslo.db 12.1.0 has changed the default value for the 'autocommit'
parameter of 'LegacyEngineFacade' from 'True' to 'False'. This is a
necessary step to ensure compatibility with SQLAlchemy 2.0. However, we
are currently relying on the autocommit behavior and need changes to
explicitly manage sessions. Until that happens, we need to override the
default.

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I8e679f20a209867dc55c3b7c34374721090731d5
This commit is contained in:
Stephen Finucane 2022-09-05 17:26:03 +01:00
parent 30cc734f0f
commit 2921e723b6
1 changed files with 7 additions and 1 deletions

View File

@ -85,7 +85,13 @@ def _create_facade_lazily():
if _FACADE is None:
with _LOCK:
if _FACADE is None:
_FACADE = session.EngineFacade.from_config(cfg.CONF)
# FIXME(stephenfin): Remove autocommit=True (and ideally use of
# LegacyEngineFacade) asap since it's not compatible with
# SQLAlchemy 2.0
_FACADE = session.EngineFacade.from_config(
cfg.CONF,
autocommit=True,
)
if CONF.profiler.enabled and CONF.profiler.trace_sqlalchemy:
osprofiler_sqlalchemy.add_tracing(sqlalchemy,
_FACADE.get_engine(),