Fix memcache caching w/ multiple cache servers

We found a bug recently where either oslo.cache or python-memcached
aren't using the `backend_argument` properly with more than one
memcached server defined. Until we get the memcached client libraries
figured out, `memcache_servers` works just the same for a single
memcached instance and it works defined with a ring of memcached
instances.

The current variable used for the directive memcache_servers was
pointing to localhost servers, that were historically used for
UUID token cache. Only the ``keystone_cache_backend_argument``
has the right list of servers, but the variable's content is
already formatted to match the cache_backend_argument directive,
and therefore needs editing to be used in ``memcache_servers``.

This is far too fragile, and simplification was needed. This
patch moves to a new variable (with a graceful deprecation
cycle), ``keystone_cache_servers``, a simple list containing the
servers.

The variable ``keystone_memcached_max_compare_and_set_retry``
wasn't used and was therefore removed too.

Related-Bug: 1743036
Closes-Bug: 1681695
Co-Authored-By: Lance Bragstad <lbragstad@gmail.com>

Change-Id: I85ebce8b41dd440e1866a08aa1329b3df798c04f
This commit is contained in:
Jean-Philippe Evrard 2018-01-26 12:54:47 +00:00
parent 16dafa4718
commit ab66ca247e
4 changed files with 33 additions and 9 deletions

View File

@ -88,11 +88,6 @@ keystone_resource_driver: sql
keystone_bind_address: 0.0.0.0
## Memcached servers used within keystone.
# String or Comma separated list of servers.
keystone_memcached_servers: 127.0.0.1
keystone_memcached_max_compare_and_set_retry: 16
## Database info
keystone_database_connection_string: >-
mysql+pymysql://{{ keystone_galera_user }}:{{ keystone_container_mysql_password }}@{{ keystone_galera_address }}/{{ keystone_galera_database }}?charset=utf8{% if keystone_galera_use_ssl | bool %}&ssl_ca={{ keystone_galera_ssl_ca_cert }}{% endif %}
@ -253,8 +248,12 @@ keystone_external_ssl: false
keystone_secure_proxy_ssl_header: HTTP_X_FORWARDED_PROTO
## Caching
# If set this will enable dog pile cache for keystone.
# keystone_cache_backend_argument: url:127.0.0.1:11211
# This is a list of strings, each string contains a cache server's
# information (IP:port for example)
# The cache_servers default backend is memcached, so this variable
# should point to a list of memcached servers.
# If empty, caching is disabled.
keystone_cache_servers: []
## LDAP Section
# Define Keystone LDAP domain configuration here.

View File

@ -0,0 +1,6 @@
---
deprecations:
- |
The variables ``keystone_memcached_servers`` and
``keystone_cache_backend_argument`` have been deprecated in favor of
``keystone_cache_servers``, a list of servers for caching purposes.

View File

@ -21,6 +21,20 @@
tags:
- always
- name: Handle deprecation of keystone_memcached_servers
set_fact:
keystone_cache_servers: "{{ keystone_cache_servers + (_ | deprecated(keystone_memcached_servers, 'keystone_memcached_servers', 'keystone_cache_servers', 'queens')).split(',') }}"
when: keystone_memcached_servers is defined
tags:
- always
- name: Handle deprecation of keystone_cache_backend_argument
set_fact:
keystone_cache_servers: "{{ keystone_cache_servers + (_ | deprecated(keystone_cache_backend_argument.replace('url:',''), 'keystone_cache_backend_argument', 'keystone_cache_servers', 'queens')).split(',') }}"
when: keystone_cache_backend_argument is defined
tags:
- always
- name: Gather variables for each operating system
include_vars: "{{ item }}"
with_first_found:

View File

@ -32,10 +32,15 @@ driver = messagingv2
transport_url = rabbit://{% for host in keystone_rabbitmq_telemetry_servers.split(',') %}{{ keystone_rabbitmq_telemetry_userid }}:{{ keystone_rabbitmq_telemetry_password }}@{{ host }}:{{ keystone_rabbitmq_telemetry_port }}{% if not loop.last %},{% else %}/{{ keystone_rabbitmq_telemetry_vhost }}{% endif %}{% endfor %}
{% endif %}
{% if keystone_cache_backend_argument is defined %}
{% if keystone_cache_servers | length > 0 %}
[cache]
backend = dogpile.cache.memcached
backend_argument = {{ keystone_cache_backend_argument }}
# FIXME(lbragstad): Some strange behaviors have been reported when using
# multiple memcached instances with backend_argument. This has been documented
# in https://bugs.launchpad.net/oslo.cache/+bug/1743036
# For the time being, memcache_servers works with a single memcached instance
# and multiple instances.
memcache_servers = {{ keystone_cache_servers | join(',') }}
config_prefix = cache.keystone
distributed_lock = True
enabled = true