Resolve migration issues

A run_once task decides on a host without the
context of conditionals related to the task.
The filter is done prior to evaluating any
conditionals.

Also, only the neutron-server neutron.conf has
the database connection credentials as a
security measure, so it is not able to execute
the database migrations.

This patch ensures that the database migrations
are only run once, but are also executed
wherever neutron-server is. It also adds
multiple instances of neutron-server and
neutron-agents to better test against problems
of this nature happening again.

Additionally, the patch uses the handlers for
the offline migrations to ensure that
neutron-server is only restarted once when a
new tag is deployed.

Change-Id: I672ceb0848415c8f2653ebc8f7556db77f7f001c
This commit is contained in:
Jesse Pretorius 2017-06-22 19:00:33 +01:00
parent 2f10f75425
commit afe63f6f19
14 changed files with 166 additions and 60 deletions

View File

@ -63,6 +63,16 @@
remote_src: yes
listen: "Restart neutron services"
- name: Perform a DB contract
command: "{{ neutron_bin }}/neutron-db-manage upgrade --contract"
become: yes
become_user: "{{ neutron_system_user_name }}"
delegate_to: "{{ groups[neutron_services['neutron-server']['group']][0] }}"
when:
- "ansible_local['openstack_ansible']['neutron']['need_db_contract'] | bool"
run_once: yes
listen: "Restart neutron services"
- name: Start services
service:
name: "{{ item.service_name }}"

View File

@ -86,14 +86,11 @@
- neutron-config
- include: neutron_db_setup.yml
when:
- "neutron_services['neutron-server']['group'] in group_names"
tags:
- neutron-config
- include: neutron_service_setup.yml
when:
- "neutron_services['neutron-server']['group'] in group_names"
run_once: yes
tags:
- neutron-config

View File

@ -17,14 +17,25 @@
command: "{{ neutron_bin }}/neutron-db-manage upgrade --expand"
become: yes
become_user: "{{ neutron_system_user_name }}"
delegate_to: "{{ groups[neutron_services['neutron-server']['group']][0] }}"
when:
- "ansible_local['openstack_ansible']['neutron']['need_db_expand'] | bool"
run_once: yes
- name: Disable the db expand fact
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: neutron
option: "need_db_expand"
value: "False"
- name: Check for available offline migrations
command: "{{ neutron_bin }}/neutron-db-manage has_offline_migrations"
register: _offline_migrations_check
become: yes
become_user: "{{ neutron_system_user_name }}"
delegate_to: "{{ groups[neutron_services['neutron-server']['group']][0] }}"
changed_when: false
register: _offline_migrations_check
failed_when:
- "_offline_migrations_check.rc == 1"
- "'Need to apply migrations from neutron contract branch' not in _offline_migrations_check.stdout"
@ -35,37 +46,13 @@
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: neutron
option: "need_db_contract"
value: "{{ ('Need to apply migrations from neutron contract branch' in _offline_migrations_check.stdout) | bool }}"
value: "True"
when:
- "'stdout' in _offline_migrations_check"
- "'Need to apply migrations from neutron contract branch' in _offline_migrations_check.stdout"
notify: Restart neutron services
- name: Refresh local facts
setup:
filter: ansible_local
gather_subset: "!all"
- name: Stop Neutron server
service:
name: "neutron-server"
state: stopped
when:
- "ansible_local['openstack_ansible']['neutron']['need_db_contract'] | bool"
- name: Perform a DB contract
command: "{{ neutron_bin }}/neutron-db-manage upgrade --contract"
become: yes
become_user: "{{ neutron_system_user_name }}"
when:
- "ansible_local['openstack_ansible']['neutron']['need_db_contract'] | bool"
run_once: yes
notify: Restart neutron services
- name: Disable the db sync local facts
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: neutron
option: "{{ item.name }}"
value: "{{ item.state }}"
with_items:
- name: "need_db_expand"
state: "False"
- name: "need_db_contract"
state: "False"

View File

@ -14,6 +14,10 @@
src: https://git.openstack.org/openstack/openstack-ansible-galera_server
scm: git
version: master
- name: haproxy_server
src: https://git.openstack.org/openstack/openstack-ansible-haproxy_server
scm: git
version: master
- name: lxc_container_create
src: https://git.openstack.org/openstack/openstack-ansible-lxc_container_create
scm: git

View File

@ -0,0 +1,18 @@
---
# Copyright 2016, 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.
ansible_host: 10.1.0.5
ansible_become: True
ansible_user: root

View File

@ -0,0 +1,18 @@
---
# Copyright 2016, 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.
ansible_host: 10.1.0.6
ansible_become: True
ansible_user: root

View File

@ -0,0 +1,18 @@
---
# Copyright 2016, 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.
ansible_host: 10.1.0.4
ansible_become: True
ansible_user: root

View File

@ -1,14 +1,20 @@
[all]
localhost
infra1
openstack1
server1
server2
agents1
agents2
[physical_host]
localhost
[all_containers]
infra1
openstack1
server1
server2
agents1
agents2
[rabbitmq_all]
infra1
@ -25,33 +31,41 @@ galera_all
memcached_all
[keystone_all]
openstack1
infra1
[neutron_agent]
openstack1
agents1
agents2
[neutron_dhcp_agent]
openstack1
agents1
agents2
[neutron_linuxbridge_agent]
openstack1
agents1
agents2
[neutron_openvswitch_agent]
[neutron_metering_agent]
openstack1
agents1
agents2
[neutron_l3_agent]
openstack1
agents1
agents2
[neutron_lbaas_agent]
openstack1
agents1
agents2
[neutron_metadata_agent]
openstack1
agents1
agents2
[neutron_server]
openstack1
server1
server2
[neutron_calico_dhcp_agent]
@ -67,4 +81,10 @@ neutron_metadata_agent
neutron_server
[utility_all]
openstack1
infra1
[haproxy_all:children]
haproxy
[haproxy]
localhost

View File

@ -22,3 +22,19 @@ tempest_plugins:
tempest_test_whitelist:
- neutron.tests.tempest.api.test_networks*
haproxy_ssl: false
external_lb_vip_address: 10.1.0.1
internal_lb_vip_address: 10.1.0.1
test_neutron_server_host: "{{ external_lb_vip_address }}"
haproxy_default_services:
- service:
haproxy_service_name: neutron_server
haproxy_backend_nodes: "{{ groups['neutron_server'] | default([]) }}"
haproxy_port: 9696
haproxy_ssl: "{{ haproxy_ssl }}"
haproxy_balance_type: http
haproxy_backend_options:
- "httpchk GET /"

View File

@ -1,14 +1,20 @@
[all]
localhost
infra1
openstack1
server1
server2
agents1
agents2
[physical_host]
localhost
[all_containers]
infra1
openstack1
server1
server2
agents1
agents2
[rabbitmq_all]
infra1
@ -25,33 +31,41 @@ galera_all
memcached_all
[keystone_all]
openstack1
infra1
[neutron_agent]
openstack1
agents1
agents2
[neutron_dhcp_agent]
openstack1
agents1
agents2
[neutron_linuxbridge_agent]
[neutron_openvswitch_agent]
openstack1
agents1
agents2
[neutron_metering_agent]
openstack1
agents1
agents2
[neutron_l3_agent]
openstack1
agents1
agents2
[neutron_lbaas_agent]
openstack1
agents1
agents2
[neutron_metadata_agent]
openstack1
agents1
agents2
[neutron_server]
openstack1
server1
server2
[neutron_calico_dhcp_agent]
@ -67,4 +81,4 @@ neutron_metadata_agent
neutron_server
[utility_all]
openstack1
infra1

View File

@ -17,9 +17,7 @@
hosts: localhost
user: root
become: true
# TODO: remove the static reference to openstack1
vars:
test_keystone_host: openstack1
working_dir: "{{ lookup('env', 'WORKING_DIR') }}"
tasks:
- name: Install openstack sdk

View File

@ -16,6 +16,9 @@
# Setup the user ssh keys, host and containers
- include: common/test-setup-host.yml
# Install haproxy
- include: common/test-install-haproxy.yml
# Install RabbitMQ/MariaDB
- include: common/test-install-infra.yml

View File

@ -16,6 +16,9 @@
# Setup the user ssh keys, host and containers
- include: common/test-setup-host.yml
# Install haproxy
- include: common/test-install-haproxy.yml
# Install RabbitMQ/MariaDB
- include: common/test-install-infra.yml