Revert "Only sync glance database on major versions"

The current major upgrade detection compares
the same variable against itself. It also takes
place after the new venv tag has been placed
and the local facts are refreshed so there's
no good way to figure out the origin version.

Additionally, the version_compare filter only
works with semver version strings which is
unnecessarily strict.

Additionally, there does not appear to be any
evidence in the glance documentation that
the db sync action requires services to be
shut down or any other orchestration, so the
previously implemented action of doing a db
sync on every playbook execution should be
just fine. If there is nothing for it to do (which
will be the case for a minor upgrade) then it
will do nothing. If there is something for it to
do (which will be the case for a major upgrade)
then it will do what needs to be done.

As such, there appears to be no point in
implementing this extra set of tasks and
conditionals.

This reverts commit 647c4e33f1.

Change-Id: I3b5afae3b7abf58de0b71ec2e67df2c38b6da5e3
This commit is contained in:
Jesse Pretorius (odyssey4me) 2017-07-12 10:41:10 +00:00 committed by Jesse Pretorius
parent f006470f27
commit 9a8481bc26
2 changed files with 4 additions and 40 deletions

View File

@ -13,43 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- 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
# 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
command: "{{ glance_bin }}/glance-manage db_sync"
become: yes
become_user: "{{ glance_system_user_name }}"
when: upgrade_type == 'major' or db_version.stdout.startswith('Database is either not under migration control')
changed_when: false
- name: Load glance metadata definitions
command: "{{ glance_bin }}/glance-manage db load_metadefs"
changed_when: false
command: "{{ glance_bin }}/glance-manage db_load_metadefs {{ glance_etc_dir }}/metadefs"
become: yes
become_user: "{{ glance_system_user_name }}"
when: upgrade_type == 'major' or db_version.stdout.startswith('Database is either not under migration control')
changed_when: false

View File

@ -33,13 +33,6 @@
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