Only sync glance database on major versions
Since Glance doesn't yet have rolling upgrades, nor is the tooling
idempotent, we avoid running the database operations during minor
upgrades to maintain uptime.
Major upgrades will still run the sync operations, and the database will
be synced if there is no existing database regardless of the type of
upgrade.
In order for a load balancer to know that a service should be drained,
we must set a flag within the role communicating the update.
Combined backport of:
https://review.openstack.org/475470
https://review.openstack.org/478214
Change-Id: I4a4d8f23f05a16d25878340ede019be7ccdb7196
(cherry picked from commit 647c4e33f1
)
This commit is contained in:
parent
13cdc93e92
commit
8a5fb5df53
@ -13,14 +13,43 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Perform a Glance DB sync
|
||||
command: "{{ glance_bin }}/glance-manage db_sync"
|
||||
- name: Check Glance DB version
|
||||
command: "{{ glance_bin }}/glance-manage db version"
|
||||
become: yes
|
||||
become_user: "{{ glance_system_user_name }}"
|
||||
register: db_version
|
||||
changed_when: false
|
||||
|
||||
- name: Load glance metadata definitions
|
||||
command: "{{ glance_bin }}/glance-manage db_load_metadefs {{ glance_etc_dir }}/metadefs"
|
||||
# We only set to minor here if the version_compare filter passes, and we make
|
||||
# sure that can't be accessed unless there's actually a '.' in the version.
|
||||
# Passing in 'major' or 'testing' to version_compare causes a Jinja error.
|
||||
- name: Determine whether a major or minor release was installed
|
||||
set_fact:
|
||||
upgrade_type: |-
|
||||
{% set existing = glance_venv_tag %}
|
||||
{% set upgrade_type = 'major' %}
|
||||
{% if '.' in existing %}
|
||||
{% set existing_major = existing.split('.')[0] %}
|
||||
{% set venv_major = glance_venv_tag.split('.')[0] %}
|
||||
{% if existing_major != venv_major %}
|
||||
{% set upgrade_type = 'major' %}
|
||||
{% elif existing | version_compare(glance_venv_tag, '!=', strict=True) %}
|
||||
{% set upgrade_type = 'minor' %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{{ upgrade_type }}
|
||||
delegate_to: localhost
|
||||
|
||||
- name: Perform a Glance DB sync
|
||||
command: "{{ glance_bin }}/glance-manage db sync"
|
||||
changed_when: false
|
||||
become: yes
|
||||
become_user: "{{ glance_system_user_name }}"
|
||||
when: upgrade_type == 'major' or db_version.stdout.startswith('Database is either not under migration control')
|
||||
|
||||
- name: Load glance metadata definitions
|
||||
command: "{{ glance_bin }}/glance-manage db load_metadefs"
|
||||
changed_when: false
|
||||
become: yes
|
||||
become_user: "{{ glance_system_user_name }}"
|
||||
when: upgrade_type == 'major' or db_version.stdout.startswith('Database is either not under migration control')
|
||||
|
@ -113,6 +113,16 @@
|
||||
virtualenv-tools --update-path=auto --reinitialize {{ glance_bin | dirname }}
|
||||
when: glance_get_venv | changed
|
||||
|
||||
- name: Record the need for a service restart
|
||||
ini_file:
|
||||
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
|
||||
section: glance
|
||||
option: need_service_restart
|
||||
value: True
|
||||
when: glance_get_venv | changed or
|
||||
glance_venv_dir | changed or
|
||||
install_packages | changed
|
||||
|
||||
- name: Record the venv tag deployed
|
||||
ini_file:
|
||||
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
|
||||
|
@ -33,6 +33,13 @@
|
||||
tags:
|
||||
- glance-install
|
||||
|
||||
- name: refresh local facts
|
||||
setup:
|
||||
filter: ansible_local
|
||||
gather_subset: "!all"
|
||||
tags:
|
||||
- glance-config
|
||||
|
||||
- include: glance_post_install.yml
|
||||
tags:
|
||||
- glance-config
|
||||
@ -42,12 +49,19 @@
|
||||
- glance-config
|
||||
|
||||
- include: glance_db_setup.yml
|
||||
when: inventory_hostname == groups['glance_all'][0]
|
||||
run_once: true
|
||||
tags:
|
||||
- glance-config
|
||||
|
||||
- include: glance_service_setup.yml
|
||||
when: inventory_hostname == groups['glance_all'][0]
|
||||
run_once: true
|
||||
tags:
|
||||
- glance-config
|
||||
|
||||
- name: refresh local facts
|
||||
setup:
|
||||
filter: ansible_local
|
||||
gather_subset: "!all"
|
||||
tags:
|
||||
- glance-config
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user