"Fossies" - the Fresh Open Source Software Archive

Member "keystone-18.0.0/keystone/cmd/doctor/caching.py" (14 Oct 2020, 2089 Bytes) of package /linux/misc/openstack/keystone-18.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "caching.py" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 17.0.0_vs_18.0.0.

    1 # Licensed under the Apache License, Version 2.0 (the "License"); you may
    2 # not use this file except in compliance with the License. You may obtain
    3 # a copy of the License at
    4 #
    5 #      http://www.apache.org/licenses/LICENSE-2.0
    6 #
    7 # Unless required by applicable law or agreed to in writing, software
    8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   10 # License for the specific language governing permissions and limitations
   11 # under the License.
   12 
   13 from keystone.common import cache
   14 import keystone.conf
   15 
   16 
   17 CONF = keystone.conf.CONF
   18 
   19 
   20 def symptom_caching_disabled():
   21     """`keystone.conf [cache] enabled` is not enabled.
   22 
   23     Caching greatly improves the performance of keystone, and it is highly
   24     recommended that you enable it.
   25     """
   26     return not CONF.cache.enabled
   27 
   28 
   29 def symptom_caching_enabled_without_a_backend():
   30     """Caching is not completely configured.
   31 
   32     Although caching is enabled in `keystone.conf [cache] enabled`, the default
   33     backend is still set to the no-op backend. Instead, configure keystone to
   34     point to a real caching backend like memcached.
   35     """
   36     return CONF.cache.enabled and CONF.cache.backend == 'dogpile.cache.null'
   37 
   38 
   39 def symptom_connection_to_memcached():
   40     """Memcached isn't reachable.
   41 
   42     Caching is enabled and the `keystone.conf [cache] backend` option is
   43     configured but one or more Memcached servers are not reachable or marked
   44     as dead. Please ensure `keystone.conf [cache] memcache_servers` is
   45     configured properly.
   46     """
   47     memcached_drivers = [
   48         'dogpile.cache.memcached',
   49         'oslo_cache.memcache_pool'
   50     ]
   51     if CONF.cache.enabled and CONF.cache.backend in memcached_drivers:
   52         cache.configure_cache()
   53         cache_stats = cache.CACHE_REGION.actual_backend.client.get_stats()
   54         memcached_server_count = len(CONF.cache.memcache_servers)
   55         if len(cache_stats) != memcached_server_count:
   56             return True
   57         else:
   58             return False
   59     else:
   60         return False