092f606adc
We're seeing some neutron db sync failures in master branch (liberty). It looks like there may be a few issues with the way we're handling migrations: 1. We're not capturing the correct information in the 'Check last DB revision' task as the first line returned by 'neutron-db-manage history' is a header (this also means that the 'Inspect on disk neutron DB revision' task will never do what we intend). 2. We delegate 'Check last DB revision' to 'neutron_all' group, but in an ideal world this is probably only necessary on 'neutron_server'. 3. When stopping neutron server to run 'Perform a Neutron DB Upgrade', we're only stopping it on groups['neutron_server'][0], while all other neutron server containers are up servicing requests. 4. Perform a db stamp, which doesn't appear to be necessary. This change makes the following changes: 1. Bumps neutron SHA to include 43c00a9, which introduces new --expand / --contract upgrade options (otherwise, you have to specify liberty_expand@head / liberty_contract@head which may no longer work when neutron gets bumped in the future) 2. Checks if migrations have previously run, and if not runs a 'neutron-db-manage upgrade heads' 3. If migrations have previously run: a) it runs an online migration against expand alembic branch using 'neutron-db-manage upgrade --expand'. b) it stops all neutron-server services c) it runs an offline migration against contract alembic branch using 'neutron-db-manage upgrade --contract' d) it starts all neutron-server instances 4. It removes the temporary pin introduced in https://review.openstack.org/218572 as the SHA bump includes the upstream fix https://review.openstack.org/218723 TODO: Currently, we upgrade expand and contract branches (shutting down neutron-server in the proceses), even if there are no pending migrations. We need to find a clean way to check what migration we are on and compare to alembic HEADS file to see if we're up to date. Unfortunately, 'neutron-db-manage current' doesn't indicate which migration is in which alembic branch, so you would have to further grep for each migration in the neutron migrations code to determine the branch. NOTE: Liberty introduces the split alembic branches for online/offline migrations, see [1] for more information. [1] http://docs.openstack.org/developer/neutron/devref/alembic_migrations.html Change-Id: I1176b5fe12cad1ee732486ae179e76deea5623e1 Closes-Bug: #1486593
112 lines
3.3 KiB
YAML
112 lines
3.3 KiB
YAML
---
|
|
# Copyright 2014, Rackspace US, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
- name: Create DB for service
|
|
mysql_db:
|
|
login_user: "{{ galera_root_user }}"
|
|
login_password: "{{ galera_root_password }}"
|
|
login_host: "{{ neutron_galera_address }}"
|
|
name: "{{ neutron_galera_database }}"
|
|
state: "present"
|
|
tags:
|
|
- neutron-db-setup
|
|
|
|
- name: Grant access to the DB for the service
|
|
mysql_user:
|
|
login_user: "{{ galera_root_user }}"
|
|
login_password: "{{ galera_root_password }}"
|
|
login_host: "{{ neutron_galera_address }}"
|
|
name: "{{ neutron_galera_user }}"
|
|
password: "{{ neutron_container_mysql_password }}"
|
|
host: "{{ item }}"
|
|
state: "present"
|
|
priv: "{{ neutron_galera_database }}.*:ALL"
|
|
with_items:
|
|
- "localhost"
|
|
- "%"
|
|
tags:
|
|
- neutron-db-setup
|
|
|
|
- name: Check for existing migrations
|
|
shell: |
|
|
neutron-db-manage --config-file {{ neutron_db_config }} --config-file {{ neutron_db_plugin }} current | egrep "^[0-9a-z]{12}"
|
|
sudo: yes
|
|
sudo_user: "{{ neutron_system_user_name }}"
|
|
failed_when: false
|
|
register: neutron_migrations_previously_run
|
|
tags:
|
|
- neutron-db-setup
|
|
- neutron-upgrade
|
|
|
|
- name: Perform an initial Neutron DB sync
|
|
command: |
|
|
neutron-db-manage --config-file {{ neutron_db_config }}
|
|
--config-file {{ neutron_db_plugin }}
|
|
upgrade {{ neutron_db_revision }}
|
|
sudo: yes
|
|
sudo_user: "{{ neutron_system_user_name }}"
|
|
when: neutron_migrations_previously_run.rc == 1
|
|
tags:
|
|
- neutron-db-setup
|
|
- neutron-upgrade
|
|
|
|
- name: Perform a Neutron DB online upgrade (expand)
|
|
command: |
|
|
neutron-db-manage --config-file {{ neutron_db_config }}
|
|
--config-file {{ neutron_db_plugin }}
|
|
upgrade --expand
|
|
sudo: yes
|
|
sudo_user: "{{ neutron_system_user_name }}"
|
|
when: neutron_migrations_previously_run.rc == 0
|
|
tags:
|
|
- neutron-db-setup
|
|
- neutron-upgrade
|
|
|
|
- name: Stop Neutron server
|
|
service:
|
|
name: "neutron-server"
|
|
state: stopped
|
|
pattern: "neutron-server"
|
|
delegate_to: "{{ item }}"
|
|
with_items: groups['neutron_server']
|
|
when: neutron_migrations_previously_run.rc == 0
|
|
tags:
|
|
- neutron-db-setup
|
|
- neutron-upgrade
|
|
|
|
- name: Perform a Neutron DB offline upgrade (contract)
|
|
command: |
|
|
neutron-db-manage --config-file {{ neutron_db_config }}
|
|
--config-file {{ neutron_db_plugin }}
|
|
upgrade --contract
|
|
sudo: yes
|
|
sudo_user: "{{ neutron_system_user_name }}"
|
|
when: neutron_migrations_previously_run.rc == 0
|
|
tags:
|
|
- neutron-db-setup
|
|
- neutron-upgrade
|
|
|
|
- name: Start neutron server
|
|
service:
|
|
name: "neutron-server"
|
|
state: started
|
|
pattern: "neutron-server"
|
|
delegate_to: "{{ item }}"
|
|
with_items: groups['neutron_server']
|
|
when: neutron_migrations_previously_run.rc == 0
|
|
tags:
|
|
- neutron-db-setup
|
|
- neutron-upgrade
|