Provide an upgrade period for enabling stores

1f6381a73f5c99f1f731d6c4f9defb91bd2d042d disabled all stores by default,
this casues upgrade issues for CD environments and folks that are not
aware of the change. This patch adds a way to attempt enabling the store
if its configuration parameters were set. If the store fails to load and
it's not in `known_stores` then no error will be reported.

The patch also warns the user when a store succeeds to load but it was
not explicitly enabled in `known_stores`. Note that there may be false
positives since some stores may not require any configuration parameter.

Change-Id: Ie784fe90003a5064aaf16fadb7266bf7a46e2cf5
Closes-Bug: #1290969
This commit is contained in:
Flavio Percoco 2014-03-12 13:57:02 +01:00
parent 09b583e303
commit b82e0b2c6f
3 changed files with 22 additions and 4 deletions

View File

@ -63,6 +63,16 @@ REGISTERED_STORES = set()
CONF = cfg.CONF
CONF.register_opts(store_opts)
_EXTRA_STORES = [
'glance.store.rbd.Store',
'glance.store.s3.Store',
'glance.store.swift.Store',
'glance.store.sheepdog.Store',
'glance.store.cinder.Store',
'glance.store.gridfs.Store',
'glance.store.vmware_datastore.Store'
]
class BackendException(Exception):
pass
@ -169,7 +179,7 @@ def create_stores():
"""
store_count = 0
store_classes = set()
for store_entry in CONF.known_stores:
for store_entry in (CONF.known_stores + _EXTRA_STORES):
store_entry = store_entry.strip()
if not store_entry:
continue
@ -177,8 +187,16 @@ def create_stores():
try:
store_instance = store_cls()
except exception.BadStoreConfiguration as e:
LOG.warn(_("%s Skipping store driver.") % unicode(e))
if store_entry in CONF.known_stores:
LOG.warn(_("%s Skipping store driver.") % unicode(e))
continue
finally:
# NOTE(flaper87): To be removed in Juno
if store_entry not in CONF.known_stores:
LOG.deprecated(_("%s not found in `known_store`. "
"Stores need to be explicitly enabled in "
"the configuration file.") % store_entry)
schemes = store_instance.get_schemes()
if not schemes:
raise BackendException('Unable to register store %s. '

View File

@ -69,7 +69,7 @@ class BaseTestCase(object):
def test_create_store(self):
self.config(known_stores=[self.store_cls_path])
count = glance.store.create_stores()
self.assertEqual(count, 1)
self.assertEqual(count, 7)
def test_lifecycle(self):
"""Add, get and delete an image"""

View File

@ -56,4 +56,4 @@ class TestStoreBase(test_base.StoreClearingUnitTest):
"glance.tests.unit.test_store_base.FakeUnconfigurableStoreDriver",
"glance.store.filesystem.Store"])
count = store.create_stores()
self.assertEqual(count, 1)
self.assertEqual(count, 8)