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 <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane 2020-11-02 10:22:36 +00:00
parent ea7ae8e655
commit 59c5f1e7ad
3 changed files with 15 additions and 26 deletions

View File

@ -17,22 +17,16 @@
"""Database setup and migration commands.""" """Database setup and migration commands."""
import os import os
import threading
from oslo_config import cfg from oslo_config import cfg
from oslo_db import options from oslo_db import options
from stevedore import driver from oslo_db.sqlalchemy import migration
from cinder.db.sqlalchemy import api as db_api from cinder.db.sqlalchemy import api as db_api
INIT_VERSION = 122
_IMPL = None
_LOCK = threading.Lock()
options.set_defaults(cfg.CONF) options.set_defaults(cfg.CONF)
INIT_VERSION = 122
MIGRATE_REPO_PATH = os.path.join( MIGRATE_REPO_PATH = os.path.join(
os.path.abspath(os.path.dirname(__file__)), os.path.abspath(os.path.dirname(__file__)),
'sqlalchemy', 'sqlalchemy',
@ -40,23 +34,14 @@ MIGRATE_REPO_PATH = os.path.join(
) )
def get_backend(): def db_sync(version=None, engine=None):
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):
"""Migrate the database to `version` or the most recent version.""" """Migrate the database to `version` or the most recent version."""
if engine is None: if engine is None:
engine = db_api.get_engine() engine = db_api.get_engine()
return get_backend().db_sync(engine=engine,
return migration.db_sync(
engine=engine,
abs_path=MIGRATE_REPO_PATH, abs_path=MIGRATE_REPO_PATH,
version=version, version=version,
init_version=init_version) init_version=INIT_VERSION)

View File

@ -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.

View File

@ -75,8 +75,6 @@ console_scripts =
cinder-volume-usage-audit = cinder.cmd.volume_usage_audit:main cinder-volume-usage-audit = cinder.cmd.volume_usage_audit:main
wsgi_scripts = wsgi_scripts =
cinder-wsgi = cinder.wsgi.wsgi:initialize_application cinder-wsgi = cinder.wsgi.wsgi:initialize_application
cinder.database.migration_backend =
sqlalchemy = oslo_db.sqlalchemy.migration
[extras] [extras]
all = all =