Implement data migrations for rolling upgrades

In order to cater for artifact-based installed, and
rolling upgrades, this patch implements a set of local
facts to inform the db sync and online migrations
tasks.

The 'cinder_all_software_updated' variables will be
set by the playbook on each run to ensure that the
online migrations only happen once all venvs are
homogenous. This ensures that the playbook can be
executed in a serialised fashion and the data will
not be corrupted.

Change-Id: I9aacda78f92355374af3f4ab24d2d9a9b47491ed
This commit is contained in:
Jesse Pretorius 2017-06-02 20:13:51 +01:00 committed by Jesse Pretorius (odyssey4me)
parent b98100fe0c
commit bca5c325eb
4 changed files with 91 additions and 4 deletions

View File

@ -0,0 +1,9 @@
---
features:
- The ``os_cinder`` role now provides for doing
online data migrations once the db sync has
been completed. The data migrations will not
be executed until the boolean variable
``cinder_all_software_updated`` is true. This
variable will need to be set by the playbook
consuming the role.

View File

@ -17,4 +17,45 @@
command: "{{ cinder_bin }}/cinder-manage db sync"
become: yes
become_user: "{{ cinder_system_user_name }}"
when:
- "ansible_local['openstack_ansible']['cinder']['need_db_sync'] | bool"
changed_when: false
register: dbsync
- name: Disable the db sync requirement
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: cinder
option: need_db_sync
value: False
when:
- dbsync | succeeded
- name: Record the need for online data migrations
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: cinder
option: need_online_data_migrations
value: True
when:
- dbsync | succeeded
- name: Perform online data migrations
command: "{{ cinder_bin }}/cinder-manage db online-data-migrations"
become: yes
become_user: "{{ cinder_system_user_name }}"
when:
- "(cinder_all_software_updated | default('no')) | bool"
- "ansible_local['openstack_ansible']['cinder']['need_online_data_migrations'] | bool"
changed_when: false
register: data_migrations
- name: Disable the online migrations requirement
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: cinder
option: need_online_data_migrations
value: False
when:
- data_migrations | succeeded

View File

@ -112,6 +112,36 @@
virtualenv-tools --update-path=auto --reinitialize {{ cinder_bin | dirname }}
when: cinder_get_venv | changed
- name: Record the need for a db sync
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: cinder
option: need_db_sync
value: True
when: cinder_get_venv | changed or
cinder_venv_dir | changed or
install_packages | changed
- name: Initialise the online data migration local fact
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: cinder
option: need_online_data_migrations
value: False
when: cinder_get_venv | changed or
cinder_venv_dir | changed or
install_packages | changed
- name: Record the need for a service restart
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: cinder
option: need_service_restart
value: True
when: cinder_get_venv | changed or
cinder_venv_dir | changed or
install_packages | changed
- name: Record the venv tag deployed
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"

View File

@ -33,21 +33,28 @@
tags:
- cinder-install
- name: refresh local facts
setup:
filter: ansible_local
gather_subset: "!all"
tags:
- cinder-config
- include: cinder_post_install.yml
tags:
- cinder-config
- include: cinder_db_setup.yml
when:
- groups['cinder_all'] | length > 0
- inventory_hostname == groups['cinder_all'][0]
- groups['cinder_api'] | length > 0
- inventory_hostname == groups['cinder_api'][0]
tags:
- cinder-config
- include: cinder_service_setup.yml
when:
- groups['cinder_all'] | length > 0
- inventory_hostname == groups['cinder_all'][0]
- groups['cinder_api'] | length > 0
- inventory_hostname == groups['cinder_api'][0]
tags:
- cinder-config