Remove db_enforce_mysql_charset option for db_sync of glance-manage
This is a deprecated option only should be used for migration. As we scheduled before, now glance removes it out from Juno release. Change-Id: Ice4ade659307ee5e635a75d6637b4664ee431c20 Signed-off-by: Zhi Yan Liu <zhiyanl@cn.ibm.com>
This commit is contained in:
parent
18a09024a3
commit
ee842bbb66
@ -566,15 +566,6 @@ scrubber_datadir = /var/lib/glance/scrubber
|
|||||||
# Base directory that the Image Cache uses
|
# Base directory that the Image Cache uses
|
||||||
image_cache_dir = /var/lib/glance/image-cache/
|
image_cache_dir = /var/lib/glance/image-cache/
|
||||||
|
|
||||||
# =============== Manager Options =================================
|
|
||||||
|
|
||||||
# DEPRECATED. TO BE REMOVED IN THE JUNO RELEASE.
|
|
||||||
# Whether or not to enforce that all DB tables have charset utf8.
|
|
||||||
# If your database tables do not have charset utf8 you will
|
|
||||||
# need to convert before this option is removed. This option is
|
|
||||||
# only relevant if your database engine is MySQL.
|
|
||||||
#db_enforce_mysql_charset = True
|
|
||||||
|
|
||||||
# =============== Database Options =================================
|
# =============== Database Options =================================
|
||||||
|
|
||||||
[database]
|
[database]
|
||||||
|
@ -52,12 +52,10 @@ from glance.openstack.common import log
|
|||||||
from glance.openstack.common import strutils
|
from glance.openstack.common import strutils
|
||||||
|
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
LOG = log.getLogger(__name__)
|
LOG = log.getLogger(__name__)
|
||||||
_LW = gettextutils._LW
|
_LW = gettextutils._LW
|
||||||
|
|
||||||
CONF = cfg.CONF
|
|
||||||
CONF.import_opt('db_enforce_mysql_charset', 'glance.common.config')
|
|
||||||
|
|
||||||
|
|
||||||
# Decorators for actions
|
# Decorators for actions
|
||||||
def args(*args, **kwargs):
|
def args(*args, **kwargs):
|
||||||
@ -73,15 +71,6 @@ class DbCommands(object):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _need_sanity_check(self):
|
|
||||||
if not CONF.db_enforce_mysql_charset:
|
|
||||||
LOG.warning(_LW('Warning: '
|
|
||||||
'The db_enforce_mysql_charset option is now '
|
|
||||||
'deprecated and will be removed in the Juno '
|
|
||||||
'release. Please migrate DB manually e.g. '
|
|
||||||
'convert data of all tables to UTF-8 charset.'))
|
|
||||||
return CONF.db_enforce_mysql_charset
|
|
||||||
|
|
||||||
def version(self):
|
def version(self):
|
||||||
"""Print database's current migration level"""
|
"""Print database's current migration level"""
|
||||||
print(migration.db_version(db_api.get_engine(),
|
print(migration.db_version(db_api.get_engine(),
|
||||||
@ -93,16 +82,14 @@ class DbCommands(object):
|
|||||||
"""Upgrade the database's migration level"""
|
"""Upgrade the database's migration level"""
|
||||||
migration.db_sync(db_api.get_engine(),
|
migration.db_sync(db_api.get_engine(),
|
||||||
db_migration.MIGRATE_REPO_PATH,
|
db_migration.MIGRATE_REPO_PATH,
|
||||||
version,
|
version)
|
||||||
sanity_check=self._need_sanity_check())
|
|
||||||
|
|
||||||
@args('--version', metavar='<version>', help='Database version')
|
@args('--version', metavar='<version>', help='Database version')
|
||||||
def downgrade(self, version=None):
|
def downgrade(self, version=None):
|
||||||
"""Downgrade the database's migration level"""
|
"""Downgrade the database's migration level"""
|
||||||
migration.db_sync(db_api.get_engine(),
|
migration.db_sync(db_api.get_engine(),
|
||||||
db_migration.MIGRATE_REPO_PATH,
|
db_migration.MIGRATE_REPO_PATH,
|
||||||
version,
|
version)
|
||||||
sanity_check=self._need_sanity_check())
|
|
||||||
|
|
||||||
@args('--version', metavar='<version>', help='Database version')
|
@args('--version', metavar='<version>', help='Database version')
|
||||||
def version_control(self, version=None):
|
def version_control(self, version=None):
|
||||||
@ -125,8 +112,7 @@ class DbCommands(object):
|
|||||||
version=current_version)
|
version=current_version)
|
||||||
migration.db_sync(db_api.get_engine(),
|
migration.db_sync(db_api.get_engine(),
|
||||||
db_migration.MIGRATE_REPO_PATH,
|
db_migration.MIGRATE_REPO_PATH,
|
||||||
version,
|
version)
|
||||||
sanity_check=self._need_sanity_check())
|
|
||||||
|
|
||||||
@args('--path', metavar='<path>', help='Path to the directory where '
|
@args('--path', metavar='<path>', help='Path to the directory where '
|
||||||
'json metadata files are stored')
|
'json metadata files are stored')
|
||||||
|
@ -32,7 +32,6 @@ class TestManageBase(testtools.TestCase):
|
|||||||
def clear_conf():
|
def clear_conf():
|
||||||
manage.CONF.reset()
|
manage.CONF.reset()
|
||||||
manage.CONF.unregister_opt(manage.command_opt)
|
manage.CONF.unregister_opt(manage.command_opt)
|
||||||
manage.CONF.db_enforce_mysql_charset = True
|
|
||||||
self.addCleanup(clear_conf)
|
self.addCleanup(clear_conf)
|
||||||
|
|
||||||
self.patcher = mock.patch('glance.db.sqlalchemy.api.get_engine')
|
self.patcher = mock.patch('glance.db.sqlalchemy.api.get_engine')
|
||||||
@ -59,16 +58,14 @@ class TestLegacyManage(TestManageBase):
|
|||||||
self._main_test_helper(['glance.cmd.manage', 'db_sync'],
|
self._main_test_helper(['glance.cmd.manage', 'db_sync'],
|
||||||
migration.db_sync,
|
migration.db_sync,
|
||||||
db_api.get_engine(),
|
db_api.get_engine(),
|
||||||
db_migration.MIGRATE_REPO_PATH, None,
|
db_migration.MIGRATE_REPO_PATH, None)
|
||||||
sanity_check=True)
|
|
||||||
|
|
||||||
@mock.patch.object(migration, 'db_sync')
|
@mock.patch.object(migration, 'db_sync')
|
||||||
def test_legacy_db_upgrade(self, db_sync):
|
def test_legacy_db_upgrade(self, db_sync):
|
||||||
self._main_test_helper(['glance.cmd.manage', 'db_upgrade'],
|
self._main_test_helper(['glance.cmd.manage', 'db_upgrade'],
|
||||||
migration.db_sync,
|
migration.db_sync,
|
||||||
db_api.get_engine(),
|
db_api.get_engine(),
|
||||||
db_migration.MIGRATE_REPO_PATH, None,
|
db_migration.MIGRATE_REPO_PATH, None)
|
||||||
sanity_check=True)
|
|
||||||
|
|
||||||
@mock.patch.object(migration, 'db_version_control')
|
@mock.patch.object(migration, 'db_version_control')
|
||||||
def test_legacy_db_version_control(self, db_version_control):
|
def test_legacy_db_version_control(self, db_version_control):
|
||||||
@ -82,51 +79,21 @@ class TestLegacyManage(TestManageBase):
|
|||||||
self._main_test_helper(['glance.cmd.manage', 'db_sync', '20'],
|
self._main_test_helper(['glance.cmd.manage', 'db_sync', '20'],
|
||||||
migration.db_sync,
|
migration.db_sync,
|
||||||
db_api.get_engine(),
|
db_api.get_engine(),
|
||||||
db_migration.MIGRATE_REPO_PATH, '20',
|
db_migration.MIGRATE_REPO_PATH, '20')
|
||||||
sanity_check=True)
|
|
||||||
|
|
||||||
@mock.patch.object(migration, 'db_sync')
|
@mock.patch.object(migration, 'db_sync')
|
||||||
def test_legacy_db_upgrade_version(self, db_sync):
|
def test_legacy_db_upgrade_version(self, db_sync):
|
||||||
self._main_test_helper(['glance.cmd.manage', 'db_upgrade', '20'],
|
self._main_test_helper(['glance.cmd.manage', 'db_upgrade', '20'],
|
||||||
migration.db_sync,
|
migration.db_sync,
|
||||||
db_api.get_engine(),
|
db_api.get_engine(),
|
||||||
db_migration.MIGRATE_REPO_PATH, '20',
|
db_migration.MIGRATE_REPO_PATH, '20')
|
||||||
sanity_check=True)
|
|
||||||
|
|
||||||
@mock.patch.object(migration, 'db_sync')
|
@mock.patch.object(migration, 'db_sync')
|
||||||
def test_legacy_db_downgrade_version(self, db_sync):
|
def test_legacy_db_downgrade_version(self, db_sync):
|
||||||
self._main_test_helper(['glance.cmd.manage', 'db_downgrade', '20'],
|
self._main_test_helper(['glance.cmd.manage', 'db_downgrade', '20'],
|
||||||
migration.db_sync,
|
migration.db_sync,
|
||||||
db_api.get_engine(),
|
db_api.get_engine(),
|
||||||
db_migration.MIGRATE_REPO_PATH, '20',
|
db_migration.MIGRATE_REPO_PATH, '20')
|
||||||
sanity_check=True)
|
|
||||||
|
|
||||||
@mock.patch.object(migration, 'db_sync')
|
|
||||||
def test_legacy_db_sync_version_without_sanity_check(self, db_sync):
|
|
||||||
manage.CONF.db_enforce_mysql_charset = False
|
|
||||||
self._main_test_helper(['glance.cmd.manage', 'db_sync', '20'],
|
|
||||||
migration.db_sync,
|
|
||||||
db_api.get_engine(),
|
|
||||||
db_migration.MIGRATE_REPO_PATH, '20',
|
|
||||||
sanity_check=False)
|
|
||||||
|
|
||||||
@mock.patch.object(migration, 'db_sync')
|
|
||||||
def test_legacy_db_upgrade_version_without_sanity_check(self, db_sync):
|
|
||||||
manage.CONF.db_enforce_mysql_charset = False
|
|
||||||
self._main_test_helper(['glance.cmd.manage', 'db_upgrade', '40'],
|
|
||||||
migration.db_sync,
|
|
||||||
db_api.get_engine(),
|
|
||||||
db_migration.MIGRATE_REPO_PATH, '40',
|
|
||||||
sanity_check=False)
|
|
||||||
|
|
||||||
@mock.patch.object(migration, 'db_sync')
|
|
||||||
def test_legacy_db_downgrade_version_without_sanity_check(self, db_sync):
|
|
||||||
manage.CONF.db_enforce_mysql_charset = False
|
|
||||||
self._main_test_helper(['glance.cmd.manage', 'db_downgrade', '20'],
|
|
||||||
migration.db_sync,
|
|
||||||
db_api.get_engine(),
|
|
||||||
db_migration.MIGRATE_REPO_PATH, '20',
|
|
||||||
sanity_check=False)
|
|
||||||
|
|
||||||
def test_db_metadefs_unload(self):
|
def test_db_metadefs_unload(self):
|
||||||
db_metadata.db_unload_metadefs = mock.Mock()
|
db_metadata.db_unload_metadefs = mock.Mock()
|
||||||
@ -179,16 +146,14 @@ class TestManage(TestManageBase):
|
|||||||
self._main_test_helper(['glance.cmd.manage', 'db', 'sync'],
|
self._main_test_helper(['glance.cmd.manage', 'db', 'sync'],
|
||||||
migration.db_sync,
|
migration.db_sync,
|
||||||
db_api.get_engine(),
|
db_api.get_engine(),
|
||||||
db_migration.MIGRATE_REPO_PATH, None,
|
db_migration.MIGRATE_REPO_PATH, None)
|
||||||
sanity_check=True)
|
|
||||||
|
|
||||||
@mock.patch.object(migration, 'db_sync')
|
@mock.patch.object(migration, 'db_sync')
|
||||||
def test_db_upgrade(self, db_sync):
|
def test_db_upgrade(self, db_sync):
|
||||||
self._main_test_helper(['glance.cmd.manage', 'db', 'upgrade'],
|
self._main_test_helper(['glance.cmd.manage', 'db', 'upgrade'],
|
||||||
migration.db_sync,
|
migration.db_sync,
|
||||||
db_api.get_engine(),
|
db_api.get_engine(),
|
||||||
db_migration.MIGRATE_REPO_PATH, None,
|
db_migration.MIGRATE_REPO_PATH, None)
|
||||||
sanity_check=True)
|
|
||||||
|
|
||||||
@mock.patch.object(migration, 'db_version_control')
|
@mock.patch.object(migration, 'db_version_control')
|
||||||
def test_db_version_control(self, db_version_control):
|
def test_db_version_control(self, db_version_control):
|
||||||
@ -202,51 +167,21 @@ class TestManage(TestManageBase):
|
|||||||
self._main_test_helper(['glance.cmd.manage', 'db', 'sync', '20'],
|
self._main_test_helper(['glance.cmd.manage', 'db', 'sync', '20'],
|
||||||
migration.db_sync,
|
migration.db_sync,
|
||||||
db_api.get_engine(),
|
db_api.get_engine(),
|
||||||
db_migration.MIGRATE_REPO_PATH, '20',
|
db_migration.MIGRATE_REPO_PATH, '20')
|
||||||
sanity_check=True)
|
|
||||||
|
|
||||||
@mock.patch.object(migration, 'db_sync')
|
@mock.patch.object(migration, 'db_sync')
|
||||||
def test_db_upgrade_version(self, db_sync):
|
def test_db_upgrade_version(self, db_sync):
|
||||||
self._main_test_helper(['glance.cmd.manage', 'db', 'upgrade', '20'],
|
self._main_test_helper(['glance.cmd.manage', 'db', 'upgrade', '20'],
|
||||||
migration.db_sync,
|
migration.db_sync,
|
||||||
db_api.get_engine(),
|
db_api.get_engine(),
|
||||||
db_migration.MIGRATE_REPO_PATH, '20',
|
db_migration.MIGRATE_REPO_PATH, '20')
|
||||||
sanity_check=True)
|
|
||||||
|
|
||||||
@mock.patch.object(migration, 'db_sync')
|
@mock.patch.object(migration, 'db_sync')
|
||||||
def test_db_downgrade_version(self, db_sync):
|
def test_db_downgrade_version(self, db_sync):
|
||||||
self._main_test_helper(['glance.cmd.manage', 'db', 'downgrade', '20'],
|
self._main_test_helper(['glance.cmd.manage', 'db', 'downgrade', '20'],
|
||||||
migration.db_sync,
|
migration.db_sync,
|
||||||
db_api.get_engine(),
|
db_api.get_engine(),
|
||||||
db_migration.MIGRATE_REPO_PATH, '20',
|
db_migration.MIGRATE_REPO_PATH, '20')
|
||||||
sanity_check=True)
|
|
||||||
|
|
||||||
@mock.patch.object(migration, 'db_sync')
|
|
||||||
def test_db_sync_version_without_sanity_check(self, db_sync):
|
|
||||||
manage.CONF.db_enforce_mysql_charset = False
|
|
||||||
self._main_test_helper(['glance.cmd.manage', 'db', 'sync', '20'],
|
|
||||||
migration.db_sync,
|
|
||||||
db_api.get_engine(),
|
|
||||||
db_migration.MIGRATE_REPO_PATH, u'20',
|
|
||||||
sanity_check=False)
|
|
||||||
|
|
||||||
@mock.patch.object(migration, 'db_sync')
|
|
||||||
def test_db_upgrade_version_without_sanity_check(self, db_sync):
|
|
||||||
manage.CONF.db_enforce_mysql_charset = False
|
|
||||||
self._main_test_helper(['glance.cmd.manage', 'db', 'upgrade', '40'],
|
|
||||||
migration.db_sync,
|
|
||||||
db_api.get_engine(),
|
|
||||||
db_migration.MIGRATE_REPO_PATH, '40',
|
|
||||||
sanity_check=False)
|
|
||||||
|
|
||||||
@mock.patch.object(migration, 'db_sync')
|
|
||||||
def test_db_downgrade_version_without_sanity_check(self, db_sync):
|
|
||||||
manage.CONF.db_enforce_mysql_charset = False
|
|
||||||
self._main_test_helper(['glance.cmd.manage', 'db', 'downgrade', '20'],
|
|
||||||
migration.db_sync,
|
|
||||||
db_api.get_engine(),
|
|
||||||
db_migration.MIGRATE_REPO_PATH, '20',
|
|
||||||
sanity_check=False)
|
|
||||||
|
|
||||||
def test_db_metadefs_unload(self):
|
def test_db_metadefs_unload(self):
|
||||||
db_metadata.db_unload_metadefs = mock.Mock()
|
db_metadata.db_unload_metadefs = mock.Mock()
|
||||||
|
Loading…
Reference in New Issue
Block a user