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
This commit is contained in:
Jens Rosenboom 2016-04-19 13:18:52 +02:00
parent cdfbb9a668
commit 59192cfbf9
2 changed files with 15 additions and 5 deletions

View File

@ -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

View File

@ -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
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.