From e8e1274da685d5f1dfdcd6f8e6e018f338bd583f Mon Sep 17 00:00:00 2001 From: Mehdi Abaakouk Date: Fri, 12 Feb 2016 11:05:21 +0100 Subject: [PATCH] Allows to use cradox with ceph storage Change-Id: I7283132fb1f71496b134db11255f1bb8609e2b25 Signed-off-by: Mehdi Abaakouk --- devstack/plugin.sh | 8 ++++++++ devstack/settings | 2 +- doc/source/configuration.rst | 17 +++++++++++++++++ gnocchi/storage/ceph.py | 15 +++++++++++++-- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/devstack/plugin.sh b/devstack/plugin.sh index 8078473c8..707dbd2eb 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -321,6 +321,10 @@ function preinstall_gnocchi { else install_package postgresql-devel fi + if [[ "$GNOCCHI_STORAGE_BACKEND" = 'ceph' ]] ; then + install_package cython + install_package librados-dev + fi } # install_gnocchi() - Collect source and prepare @@ -334,6 +338,10 @@ function install_gnocchi { pip_install influxdb fi + if [[ "$GNOCCHI_STORAGE_BACKEND" = 'ceph' ]] ; then + pip_install cradox + fi + if is_service_enabled gnocchi-grafana then _gnocchi_install_grafana diff --git a/devstack/settings b/devstack/settings index e28c40e68..a1549c700 100644 --- a/devstack/settings +++ b/devstack/settings @@ -37,7 +37,7 @@ GNOCCHI_STATSD_RESOURCE_ID=${GNOCCHI_STATSD_RESOURCE_ID:-$(uuidgen)} GNOCCHI_STATSD_USER_ID=${GNOCCHI_STATSD_USER_ID:-$(uuidgen)} GNOCCHI_STATSD_PROJECT_ID=${GNOCCHI_STATSD_PROJECT_ID:-$(uuidgen)} -# ceph gnochi info +# ceph gnocchi info GNOCCHI_CEPH_USER=${GNOCCHI_CEPH_USER:-gnocchi} GNOCCHI_CEPH_POOL=${GNOCCHI_CEPH_POOL:-gnocchi} GNOCCHI_CEPH_POOL_PG=${GNOCCHI_CEPH_POOL_PG:-8} diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index 694d1a6f4..3adf64fbc 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -166,4 +166,21 @@ result from: So, in realistic scenarios, the direct relation between the archive policy and the size of the rados objects created by Gnocchi is not a problem. + +Also Gnocchi can use `cradox`_ Python libary if installed. This library is a +Python binding to librados written with `Cython`_, aiming to replace the one +written with `ctypes`_ provided by Ceph. +This new library will be part of next Ceph release (10.0.4). + +The new Cython binding divides the gnocchi-metricd times to process measures +by a large factor. + +So, if the Ceph installation doesn't use latest Ceph version, `cradox`_ can be +installed to improve the Ceph backend performance. + + .. _`Ceph extended attributes documentation`: http://docs.ceph.com/docs/master/rados/configuration/filestore-config-ref/#extended-attributes +.. _`cradox`: https://pypi.python.org/pypi/cradox +.. _`Cython`: http://cython.org/ +.. _`ctypes`: https://docs.python.org/2/library/ctypes.html +.. _`rados.py`: https://docs.python.org/2/library/ctypes.htm://github.com/ceph/ceph/blob/hammer/src/pybind/rados.py diff --git a/gnocchi/storage/ceph.py b/gnocchi/storage/ceph.py index 167b43412..beed4eaf1 100644 --- a/gnocchi/storage/ceph.py +++ b/gnocchi/storage/ceph.py @@ -28,8 +28,13 @@ from gnocchi.storage import _carbonara LOG = logging.getLogger(__name__) -# NOTE(sileht): rados module is not available on pypi -rados = importutils.try_import('rados') +for RADOS_MODULE_NAME in ('cradox', 'rados'): + rados = importutils.try_import(RADOS_MODULE_NAME) + if rados is not None: + break +else: + RADOS_MODULE_NAME = None + if rados is not None and hasattr(rados, 'run_in_thread'): rados.run_in_thread = lambda target, args, timeout=None: target(*args) LOG.info("rados.run_in_thread is monkeypatched.") @@ -58,6 +63,12 @@ class CephStorage(_carbonara.CarbonaraBasedStorage): if conf.ceph_keyring: options['keyring'] = conf.ceph_keyring + if not rados: + raise ImportError("No module named 'rados' nor 'cradox'") + + LOG.info("Ceph storage backend use '%s' python library" % + RADOS_MODULE_NAME) + # NOTE(sileht): librados handles reconnection itself, # by default if a call timeout (30sec), it raises # a rados.Timeout exception, and librados