Add memcache flushing handler on db migrations

Flushing cache when schema changes occur to avoid drift between
what might be cached and what keystone queries expect.

Change-Id: Ibf8f3dd60d6f3c446a14dc8228fa005f12fcc840
Closes-Bug: 1793389
This commit is contained in:
rexredinger 2018-10-04 15:38:01 -04:00
parent 1d05548513
commit afc0e5b1ce
2 changed files with 14 additions and 0 deletions

View File

@ -164,6 +164,17 @@
retries: 5
delay: 2
- name: Flush all of the cache in memcached
vars:
nc_command:
debian: nc -q 1 $(awk '/^\-l/ {print $2}' "/etc/memcached.conf" | awk -F, '{print $1}') $(awk '/^\-p/ {print $2}' "/etc/memcached.conf")
redhat: nc $(awk -F '-l' '/^OPTIONS/ {print $2}' "/etc/sysconfig/memcached" | awk -F ',' '{gsub(/"/, "", $1); print $1}' | awk -F '-' '{print $1}') 11211
suse: nc -w 1 $(awk -F '-l' '/^MEMCACHED_PARAMS/ {print $2}' "/etc/sysconfig/memcached" | awk -F ',' '{gsub(/"/, "", $1); print $1}' | awk -F '-' '{print $1}') 11211
shell: "echo 'flush_all' | {{ nc_command.get(ansible_os_family | lower) }}"
delegate_to: "{{ item }}"
with_items: "{{ groups.memcached_all }}"
listen: flush cache
- meta: noop
listen: Manage LB
when: false

View File

@ -102,6 +102,7 @@
when:
- "ansible_local['openstack_ansible']['keystone']['need_db_expand'] | bool"
run_once: yes
notify: flush cache
- name: Perform a Keystone DB sync migrate
command: "{{ keystone_bin }}/keystone-manage db_sync --migrate"
@ -110,6 +111,7 @@
when:
- "ansible_local['openstack_ansible']['keystone']['need_db_migrate'] | bool"
run_once: yes
notify: flush cache
- name: Perform a Keystone DB sync contract
command: "{{ keystone_bin }}/keystone-manage db_sync --contract"
@ -119,3 +121,4 @@
- "(keystone_all_software_updated | default('no')) | bool"
- "ansible_local['openstack_ansible']['keystone']['need_db_contract'] | bool"
run_once: yes
notify: flush cache