Enable pooling in devstack

This patch enables pooling by default. Pooling has become a central
piece for Zaqar, therefore, we ought to test on it always.

The patch also changes the behavior for pools in Zaqar. That is,
whenever a default pool is not found and a `message_store` section has
been configured, such section will be used as the default store. No
pools will be created out of this configurations so that users can still
configure their default store using zaqarclient.

Change-Id: I820ac017ee44b806dead9bc484664228d4022f81
Depends-On: If5c91ebe136017cea2eeecf62a580d050e49617d
This commit is contained in:
Flavio Percoco 2015-04-28 11:06:33 +02:00
parent c09f24ee5d
commit 9352bb600f
2 changed files with 33 additions and 9 deletions

View File

@ -118,14 +118,20 @@ function configure_zaqar {
iniset $ZAQAR_CONF DEFAULT unreliable True iniset $ZAQAR_CONF DEFAULT unreliable True
iniset $ZAQAR_CONF DEFAULT admin_mode True iniset $ZAQAR_CONF DEFAULT admin_mode True
iniset $ZAQAR_CONF DEFAULT use_syslog $SYSLOG iniset $ZAQAR_CONF DEFAULT use_syslog $SYSLOG
# Enable pooling by default for now
iniset $ZAQAR_CONF DEFAULT admin_mode True
iniset $ZAQAR_CONF 'drivers:transport:wsgi' bind $ZAQAR_SERVICE_HOST iniset $ZAQAR_CONF 'drivers:transport:wsgi' bind $ZAQAR_SERVICE_HOST
configure_auth_token_middleware $ZAQAR_CONF zaqar $ZAQAR_AUTH_CACHE_DIR configure_auth_token_middleware $ZAQAR_CONF zaqar $ZAQAR_AUTH_CACHE_DIR
if [ "$ZAQAR_BACKEND" = 'mongodb' ] ; then if [ "$ZAQAR_BACKEND" = 'mongodb' ] ; then
iniset $ZAQAR_CONF DEFAULT pooling True
iniset $ZAQAR_CONF drivers storage mongodb iniset $ZAQAR_CONF drivers storage mongodb
iniset $ZAQAR_CONF 'drivers:message_store:mongodb' uri mongodb://localhost:27017/zaqar iniset $ZAQAR_CONF 'drivers:message_store:mongodb' uri mongodb://localhost:27017/zaqar
iniset $ZAQAR_CONF 'drivers:message_store:mongodb' database zaqar iniset $ZAQAR_CONF 'drivers:message_store:mongodb' database zaqar
iniset $ZAQAR_CONF 'drivers:management_store:mongodb' uri mongodb://localhost:27017/zaqar_mgmt
iniset $ZAQAR_CONF 'drivers:management_store:mongodb' database zaqar_mgmt
configure_mongodb configure_mongodb
elif [ "$ZAQAR_BACKEND" = 'redis' ] ; then elif [ "$ZAQAR_BACKEND" = 'redis' ] ; then
iniset $ZAQAR_CONF drivers storage redis iniset $ZAQAR_CONF drivers storage redis

View File

@ -415,7 +415,7 @@ class Catalog(object):
self._catalogue_ctrl = control.catalogue_controller self._catalogue_ctrl = control.catalogue_controller
# FIXME(cpp-cabrera): https://bugs.launchpad.net/zaqar/+bug/1252791 # FIXME(cpp-cabrera): https://bugs.launchpad.net/zaqar/+bug/1252791
def _init_driver(self, pool_id): def _init_driver(self, pool_id, pool_conf=None):
"""Given a pool name, returns a storage driver. """Given a pool name, returns a storage driver.
:param pool_id: The name of a pool. :param pool_id: The name of a pool.
@ -423,7 +423,10 @@ class Catalog(object):
:returns: a storage driver :returns: a storage driver
:rtype: zaqar.storage.base.DataDriverBase :rtype: zaqar.storage.base.DataDriverBase
""" """
if pool_id is not None:
pool = self._pools_ctrl.get(pool_id, detailed=True) pool = self._pools_ctrl.get(pool_id, detailed=True)
else:
pool = pool_conf
conf = utils.dynamic_conf(pool['uri'], pool['options'], conf = utils.dynamic_conf(pool['uri'], pool['options'],
conf=self._conf) conf=self._conf)
storage = utils.load_storage_driver(conf, storage = utils.load_storage_driver(conf,
@ -581,15 +584,30 @@ class Catalog(object):
except errors.QueueNotMapped as ex: except errors.QueueNotMapped as ex:
LOG.debug(ex) LOG.debug(ex)
conf_section = ('drivers:message_store:%s' %
self._conf.drivers.storage)
if conf_section not in self._conf:
# NOTE(kgriffs): Return `None`, rather than letting the # NOTE(kgriffs): Return `None`, rather than letting the
# exception bubble up, so that the higher layer doesn't # exception bubble up, so that the higher layer doesn't
# have to duplicate the try..except..log code all over # have to duplicate the try..except..log code all over
# the place. # the place.
return None return None
# NOTE(flaper87): This assumes the storage driver type is the
# same as the management.
pool_conf = {'uri': self._conf[conf_section].uri,
'options': {}}
# NOTE(flaper87): This will be using the config
# storage configuration as the default one if no
# default storage has been registered in the pool
# store.
return self.get_driver(None, pool_conf)
return self.get_driver(pool_id) return self.get_driver(pool_id)
def get_driver(self, pool_id): def get_driver(self, pool_id, pool_conf=None):
"""Get storage driver, preferably cached, from a pool name. """Get storage driver, preferably cached, from a pool name.
:param pool_id: The name of a pool. :param pool_id: The name of a pool.
@ -602,6 +620,6 @@ class Catalog(object):
return self._drivers[pool_id] return self._drivers[pool_id]
except KeyError: except KeyError:
# NOTE(cpp-cabrera): cache storage driver connection # NOTE(cpp-cabrera): cache storage driver connection
self._drivers[pool_id] = self._init_driver(pool_id) self._drivers[pool_id] = self._init_driver(pool_id, pool_conf)
return self._drivers[pool_id] return self._drivers[pool_id]