From 59192cfbf9482fe3798cdcd4c2044d8c85f66e95 Mon Sep 17 00:00:00 2001 From: Jens Rosenboom Date: Tue, 19 Apr 2016 13:18:52 +0200 Subject: [PATCH] Warn when using null cache backend The default backend for oslo_cache is dogpile.cache.null, leading to a broken setup when following the current release notes or the deprecation message verbatim. So we should at least emit a warning when the config does not specify a different backend. Note: I'm not sure whether it is possible to amend the release note like this or whether there needs a new note to be added, please advise. Change-Id: I16647e424d8382dae98f13cb1f73a7e0c0aebaf5 Closes-Bug: 1572062 --- nova/cache_utils.py | 15 ++++++++++++--- .../switch-to-oslo-cache-7114a0ab2dea52df.yaml | 5 +++-- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/nova/cache_utils.py b/nova/cache_utils.py index bc0851c4cb7b..e764738a5146 100644 --- a/nova/cache_utils.py +++ b/nova/cache_utils.py @@ -14,24 +14,32 @@ # License for the specific language governing permissions and limitations # under the License. -"""Super simple fake memcache client.""" +"""Simple wrapper for oslo_cache.""" from oslo_cache import core as cache +from oslo_log import log as logging import nova.conf -from nova.i18n import _ - +from nova.i18n import _, _LW CONF = nova.conf.CONF +LOG = logging.getLogger(__name__) + WEEK = 604800 +def _warn_if_null_backend(): + if CONF.cache.backend == 'dogpile.cache.null': + LOG.warning(_LW("Cache enabled with backend dogpile.cache.null.")) + + def get_memcached_client(expiration_time=0): """Used ONLY when memcached is explicitly needed.""" # If the operator has [cache]/enabled flag on then we let oslo_cache # configure the region from the configuration settings if CONF.cache.enabled and CONF.cache.memcache_servers: + _warn_if_null_backend() return CacheClient( _get_default_cache_region(expiration_time=expiration_time)) @@ -41,6 +49,7 @@ def get_client(expiration_time=0): # If the operator has [cache]/enabled flag on then we let oslo_cache # configure the region from configuration settings. if CONF.cache.enabled: + _warn_if_null_backend() return CacheClient( _get_default_cache_region(expiration_time=expiration_time)) # If [cache]/enabled flag is off, we use the dictionary backend diff --git a/releasenotes/notes/switch-to-oslo-cache-7114a0ab2dea52df.yaml b/releasenotes/notes/switch-to-oslo-cache-7114a0ab2dea52df.yaml index 2cc24234da74..509664eb986c 100644 --- a/releasenotes/notes/switch-to-oslo-cache-7114a0ab2dea52df.yaml +++ b/releasenotes/notes/switch-to-oslo-cache-7114a0ab2dea52df.yaml @@ -5,5 +5,6 @@ deprecations: - Option ``memcached_servers`` is deprecated in Mitaka. Operators should use oslo.cache configuration instead. Specifically ``enabled`` option - under [cache] section should be set to True and the url(s) for the - memcached servers should be in [cache]/memcache_servers option. \ No newline at end of file + under [cache] section should be set to True, the ``backend`` option to + ``oslo_cache.memcache_pool`` and the location(s) of the + memcached servers should be in [cache]/memcache_servers option.