From afc0e5b1ce660224593f2f9d1886d45f1c69f174 Mon Sep 17 00:00:00 2001 From: rexredinger Date: Thu, 4 Oct 2018 15:38:01 -0400 Subject: [PATCH] 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 --- handlers/main.yml | 11 +++++++++++ tasks/keystone_db_setup.yml | 3 +++ 2 files changed, 14 insertions(+) diff --git a/handlers/main.yml b/handlers/main.yml index 2e71f13e..70ee35b4 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -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 diff --git a/tasks/keystone_db_setup.yml b/tasks/keystone_db_setup.yml index b6e8e4cd..bc98e378 100644 --- a/tasks/keystone_db_setup.yml +++ b/tasks/keystone_db_setup.yml @@ -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