Fix glance-api if cache is disabled
This patch fixes glance when cache is disabled. Change-Id: I3c3560ba9c87c7098d75173a095642bdd1d7c687
This commit is contained in:
parent
519ce0b94d
commit
309ca3aec2
@ -33,10 +33,13 @@ CONF.import_opt("image_cache_sqlite_db", "glance.image_cache.drivers.sqlite")
|
||||
|
||||
|
||||
def can_migrate_to_central_db():
|
||||
# Return immediately if cache is disabled
|
||||
if not (CONF.paste_deploy.flavor and 'cache' in CONF.paste_deploy.flavor):
|
||||
return False
|
||||
|
||||
is_centralized_db_driver = CONF.image_cache_driver == "centralized_db"
|
||||
# Check worker_self_reference_url is set if cache is enabled and
|
||||
# cache driver is centralized_db
|
||||
is_centralized_db_driver = CONF.image_cache_driver == "centralized_db"
|
||||
if CONF.paste_deploy.flavor and 'cache' in CONF.paste_deploy.flavor:
|
||||
if is_centralized_db_driver and not CONF.worker_self_reference_url:
|
||||
msg = _("'worker_self_reference_url' needs to be set "
|
||||
"if `centralized_db` is defined as cache driver "
|
||||
|
@ -101,10 +101,16 @@ class TestMigrate(test_utils.BaseTestCase):
|
||||
self.config(image_cache_driver="sqlite")
|
||||
self.assertFalse(sqlite_migration.migrate_if_required())
|
||||
|
||||
def test_migrate_if_required_cache_disabled(self):
|
||||
self.config(flavor="keystone", group="paste_deploy")
|
||||
self.config(image_cache_driver="centralized_db")
|
||||
self.assertFalse(sqlite_migration.migrate_if_required())
|
||||
|
||||
@mock.patch('os.path.exists')
|
||||
@mock.patch('os.path.join', new=mock.MagicMock())
|
||||
def test_migrate_if_required_db_not_found(self, mock_exists):
|
||||
mock_exists.return_value = False
|
||||
self.config(flavor="keystone+cache", group="paste_deploy")
|
||||
self.config(image_cache_driver="centralized_db")
|
||||
with mock.patch.object(sqlite_migration, 'LOG') as mock_log:
|
||||
sqlite_migration.migrate_if_required()
|
||||
|
Loading…
Reference in New Issue
Block a user