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,
Aodh is currently relying on the autocommit behavior and needs changes
to explicitly manage sessions. Until that happens, we need to override
the default.

Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Change-Id: I129b54b06e1a5c3fafd2a03f295cc1cfd9c9e33c
This commit is contained in:
Stephen Finucane 2022-09-05 16:57:17 +01:00
parent 165c96b51d
commit 45e8c6ae0c
1 changed files with 4 additions and 0 deletions

View File

@ -106,6 +106,10 @@ class Connection(base.Connection):
# in storage.__init__.get_connection_from_config function
options = dict(conf.database.items())
options['max_retries'] = 0
# FIXME(stephenfin): Remove this (and ideally use of
# LegacyEngineFacade) asap since it's not compatible with SQLAlchemy
# 2.0
options['autocommit'] = True
# oslo.db doesn't support options defined by Aodh
for opt in storage.OPTS:
options.pop(opt.name, None)