From 9a8481bc2667ff0adc48017b7a54ced4cad4e6ae Mon Sep 17 00:00:00 2001 From: "Jesse Pretorius (odyssey4me)" Date: Wed, 12 Jul 2017 10:41:10 +0000 Subject: [PATCH] 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 647c4e33f1fcba771f23f7aabf0dc061b22f79ab. Change-Id: I3b5afae3b7abf58de0b71ec2e67df2c38b6da5e3 --- tasks/glance_db_setup.yml | 37 ++++--------------------------------- tasks/main.yml | 7 ------- 2 files changed, 4 insertions(+), 40 deletions(-) diff --git a/tasks/glance_db_setup.yml b/tasks/glance_db_setup.yml index ec355425..d9a66e91 100644 --- a/tasks/glance_db_setup.yml +++ b/tasks/glance_db_setup.yml @@ -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 diff --git a/tasks/main.yml b/tasks/main.yml index 9bf78de3..d09cf7f1 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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