From 59c5f1e7adad55002e1c80e6d9d3052dd8431d23 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Mon, 2 Nov 2020 10:22:36 +0000 Subject: [PATCH] db: Remove 'cinder.database.migration_backend' entrypoint We don't provide multiple backends in-tree and couldn't possibly support those provided out-of-tree. Remove this knob. Change-Id: Ia05eb6536bd4b2977358c0086293757091aa5e68 Signed-off-by: Stephen Finucane --- cinder/db/migration.py | 33 +++++-------------- ...le-migration-backend-aaee5a2f808c9b36.yaml | 6 ++++ setup.cfg | 2 -- 3 files changed, 15 insertions(+), 26 deletions(-) create mode 100644 releasenotes/notes/remove-configurable-migration-backend-aaee5a2f808c9b36.yaml diff --git a/cinder/db/migration.py b/cinder/db/migration.py index 4f4e1ca695b..6b16ae7071d 100644 --- a/cinder/db/migration.py +++ b/cinder/db/migration.py @@ -17,22 +17,16 @@ """Database setup and migration commands.""" import os -import threading from oslo_config import cfg from oslo_db import options -from stevedore import driver +from oslo_db.sqlalchemy import migration from cinder.db.sqlalchemy import api as db_api - -INIT_VERSION = 122 - -_IMPL = None -_LOCK = threading.Lock() - options.set_defaults(cfg.CONF) +INIT_VERSION = 122 MIGRATE_REPO_PATH = os.path.join( os.path.abspath(os.path.dirname(__file__)), 'sqlalchemy', @@ -40,23 +34,14 @@ MIGRATE_REPO_PATH = os.path.join( ) -def get_backend(): - global _IMPL - if _IMPL is None: - with _LOCK: - if _IMPL is None: - _IMPL = driver.DriverManager( - "cinder.database.migration_backend", - cfg.CONF.database.backend).driver - return _IMPL - - -def db_sync(version=None, init_version=INIT_VERSION, engine=None): +def db_sync(version=None, engine=None): """Migrate the database to `version` or the most recent version.""" if engine is None: engine = db_api.get_engine() - return get_backend().db_sync(engine=engine, - abs_path=MIGRATE_REPO_PATH, - version=version, - init_version=init_version) + + return migration.db_sync( + engine=engine, + abs_path=MIGRATE_REPO_PATH, + version=version, + init_version=INIT_VERSION) diff --git a/releasenotes/notes/remove-configurable-migration-backend-aaee5a2f808c9b36.yaml b/releasenotes/notes/remove-configurable-migration-backend-aaee5a2f808c9b36.yaml new file mode 100644 index 00000000000..d5dd24e6d24 --- /dev/null +++ b/releasenotes/notes/remove-configurable-migration-backend-aaee5a2f808c9b36.yaml @@ -0,0 +1,6 @@ +--- +upgrade: + - | + Support for the ``cinder.database.migration_backend`` entrypoint, which + provided for configurable database migration backends, has been removed. + This was never exercised and was a source of unnecessary complexity. diff --git a/setup.cfg b/setup.cfg index b0b969272df..cd1057dcb49 100644 --- a/setup.cfg +++ b/setup.cfg @@ -75,8 +75,6 @@ console_scripts = cinder-volume-usage-audit = cinder.cmd.volume_usage_audit:main wsgi_scripts = cinder-wsgi = cinder.wsgi.wsgi:initialize_application -cinder.database.migration_backend = - sqlalchemy = oslo_db.sqlalchemy.migration [extras] all =