Refactor migration for a cleaner up/bottom

- We only have dhcp and migration top level ymls
- Role default variables like 'var: "{{ var }}"' have been removed
- Containerless variables removed, as we don't provide support for that
  since Queens.

Change-Id: I02b0b2c644e931592c14ade5b3de66ffbd136b03
changes/21/590721/3
Miguel Angel Ajo 4 years ago
parent 1f00d9a7c9
commit cb621a082a
  1. 5
      migration/tripleo_environment/ovn_migration.sh
  2. 30
      migration/tripleo_environment/playbooks/migrate.yml
  3. 85
      migration/tripleo_environment/playbooks/ovn-migration.yml
  4. 52
      migration/tripleo_environment/playbooks/post-migration.yml
  5. 6
      migration/tripleo_environment/playbooks/roles/activate-ovn/defaults/main.yml
  6. 77
      migration/tripleo_environment/playbooks/roles/clone-dataplane/templates/clone-br-int.sh.j2
  7. 5
      migration/tripleo_environment/playbooks/roles/delete-neutron-resources/defaults/main.yml
  8. 20
      migration/tripleo_environment/playbooks/roles/delete-neutron-resources/tasks/main.yml
  9. 5
      migration/tripleo_environment/playbooks/roles/migration/defaults/main.yml
  10. 3
      migration/tripleo_environment/playbooks/roles/migration/tasks/activate-ovn.yml
  11. 1
      migration/tripleo_environment/playbooks/roles/migration/tasks/cleanup-dataplane.yml
  12. 0
      migration/tripleo_environment/playbooks/roles/migration/tasks/clone-dataplane.yml
  13. 21
      migration/tripleo_environment/playbooks/roles/migration/tasks/delete-neutron-resources.yml
  14. 18
      migration/tripleo_environment/playbooks/roles/migration/tasks/main.yml
  15. 20
      migration/tripleo_environment/playbooks/roles/migration/tasks/sync-dbs.yml
  16. 6
      migration/tripleo_environment/playbooks/roles/migration/templates/activate-ovn.sh.j2
  17. 77
      migration/tripleo_environment/playbooks/roles/migration/templates/clone-br-int.sh.j2
  18. 0
      migration/tripleo_environment/playbooks/roles/migration/templates/delete-neutron-resources.sh.j2
  19. 3
      migration/tripleo_environment/playbooks/roles/post-migration/defaults/main.yml
  20. 47
      migration/tripleo_environment/playbooks/roles/post-migration/tasks/main.yml
  21. 16
      migration/tripleo_environment/playbooks/roles/pre-migration/tasks/main.yml
  22. 2
      migration/tripleo_environment/playbooks/roles/resources/cleanup/defaults/main.yml
  23. 5
      migration/tripleo_environment/playbooks/roles/resources/create/defaults/main.yml
  24. 1
      migration/tripleo_environment/playbooks/roles/resources/validate/defaults/main.yml
  25. 21
      migration/tripleo_environment/playbooks/roles/sync-dbs/tasks/main.yml
  26. 2
      migration/tripleo_environment/playbooks/roles/tripleo-update/defaults/main.yml
  27. 15
      migration/tripleo_environment/playbooks/setup-ovn.yml

@ -35,7 +35,6 @@ LANG=C
: ${PUBLIC_NETWORK_NAME:=public}
: ${IMAGE_NAME:=cirros}
: ${SERVER_USER_NAME:=cirros}
: ${IS_CONTAINER_DEPLOYMENT:=False}
: ${VALIDATE_MIGRATION:=True}
: ${DHCP_RENEWAL_TIME:=30}
@ -162,7 +161,7 @@ generate_ansible_inventory_file() {
for node_name in $OVN_CONTROLLERS
do
node_ip=$(get_host_ip /tmp/ansible-inventory.txt $node_name)
echo $node_name ansible_host=$node_ip ansible_ssh_user=heat-admin ansible_become=true >> hosts_for_migration
echo $node_name ansible_host=$node_ip ansible_ssh_user=heat-admin ansible_become=true ovn_controller=true >> hosts_for_migration
done
rm -f /tmp/ansible-inventory.txt
echo "" >> hosts_for_migration
@ -188,7 +187,6 @@ public_network_name=$PUBLIC_NETWORK_NAME
image_name=$IMAGE_NAME
working_dir=$OPT_WORKDIR
server_user_name=$SERVER_USER_NAME
container_deployment=$IS_CONTAINER_DEPLOYMENT
validate_migration=$VALIDATE_MIGRATION
overcloud_ovn_deploy_script=$OVERCLOUD_OVN_DEPLOY_SCRIPT
overcloudrc=$OVERCLOUDRC_FILE
@ -254,7 +252,6 @@ start_migration() {
-e overcloud_ovn_deploy_script=$OVERCLOUD_OVN_DEPLOY_SCRIPT \
-e server_user_name=$SERVER_USER_NAME \
-e overcloudrc=$OVERCLOUDRC_FILE \
-e container_deployment=$IS_CONTAINER_DEPLOYMENT \
-e validate_migration=$VALIDATE_MIGRATION $*
rc=$?

@ -1,30 +0,0 @@
---
- name: "Clone stuff in br-int to br-migration and create false bridge-mappings"
hosts: ovn-controllers
roles:
- clone-dataplane
- name: Sync Neutron and OVN DBs
hosts: ovn-dbs
roles:
- sync-dbs
- name: Activate OVN controller
hosts: ovn-controllers
roles:
- activate-ovn
- name: Cleanup Neutron dataplane resources
hosts: ovn-controllers
roles:
- cleanup
- name: Delete Neutron resources
hosts: localhost
roles:
- delete-neutron-resources
vars:
ovn_migration_temp_dir: "{{ working_dir }}/delete_neutron_resources"
# TODO: Remove ovs_hybrid_plug='True' from the pre migation ports' binding_vif_details'

@ -1,25 +1,94 @@
# This is the playbook used by ovn-migration.sh.
# This is the start of the migration
- import_playbook: pre-migration.yml
#
# Pre migration and validation tasks will make sure that the initial cloud
# is functional, and will create resources which will be checked after
# migration.
#
- name: Pre migration and validation tasks
hosts: localhost
roles:
- pre-migration
tags:
- pre-migration
when: validate_migration|bool
- import_playbook: setup-ovn.yml
#
# This step is executed before migration, and will backup some config
# files related to containers before those get lost.
#
- name: Backup tripleo container config files on the nodes
hosts: ovn-controllers
roles:
- backup
tags:
- setup
#
# TripleO / Director is executed to deploy ovn using "br-migration" for the
# dataplane, while br-int is left intact to avoid dataplane disruption.
#
- name: Set up OVN and configure it using tripleo
hosts: localhost
roles:
- tripleo-update
vars:
ovn_bridge: br-migration
tags:
- setup
become: false
- import_playbook: migrate.yml
#
# Once everything is migrated prepare everything by syncing the neutron DB
# into the OVN NB database, and then switching the dataplane to br-int
# letting ovn-controller take control, afterwards any remaining neutron
# resources, namespaces or processes which are not needed anymore are
# cleaned up.
#
- name: Do the DB sync and dataplane switch
hosts: ovn-controllers, ovn-dbs
roles:
- migration
vars:
ovn_bridge: br-int
tags:
- migrate
- migration
#
# Verify that the initial resources are still reachable, remove them,
# and afterwards create new resources and repeat the connectivity tests.
#
- import_playbook: post-migration.yml
- name: Post migration
hosts: localhost
roles:
- post-migration
tags:
- post-migration
when: validate_migration|bool
#
# Final step to make sure tripleo knows about OVNIntegrationBridge == br-int.
#
- name: Rerun the stack update to reset the OVNIntegrationBridge to br-int
include_role:
name: tripleo-update
vars:
ovn_bridge: "br-int"
tags:
- ovn-setup
become: false
#
# Announce that it's done and ready.
#
- hosts: localhost
tasks:
- name: Migration successful.
debug:
msg: Migration from ML2OVS to OVN is now complete.

@ -1,52 +0,0 @@
- name: Validate pre migration resources after migration
hosts: localhost
roles:
- resources/validate
vars:
ovn_migration_temp_dir: "{{ working_dir }}/pre_migration_resources"
restart_server: true
- name: Delete the pre migration resources
hosts: localhost
roles:
- resources/cleanup
tags:
- post-migration
vars:
ovn_migration_temp_dir: "{{ working_dir }}/pre_migration_resources"
- name: Create post-migration resources
hosts: localhost
roles:
- resources/create
vars:
ovn_migration_temp_dir: "{{ working_dir }}/post_migration_resources"
resource_suffix: "post"
- name: Validate post migration resources
hosts: localhost
roles:
- resources/validate
vars:
ovn_migration_temp_dir: "{{ working_dir }}/post_migration_resources"
- name: Delete the post migration resources
hosts: localhost
roles:
- resources/cleanup
tags:
- post-migration
vars:
ovn_migration_temp_dir: "{{ working_dir }}/post_migration_resources"
resource_suffix: "post"
# Do we really need to do this ?
- name: Rerun the stack update to reset the OVNIntegrationBridge to br-int
hosts: localhost
roles:
- tripleo-update
vars:
ovn_bridge: "br-int"
tags:
- ovn-setup

@ -1,6 +0,0 @@
---
tunnel_bridge: "br-tun"
integration_bridge: "br-int"
external_bridge: "br-ex"
activate_ovn_script: activate-ovn.sh.j2

@ -1,77 +0,0 @@
# The purpose of this script is to make a clone of the br-int content
# into br-migration, and to create fake provider bridges.
# This way, while we synchronize the neutron database into the OVN
# northbound DB, and that translates into southbound content all
# the ovn-controllers around are able to create the SBDB content
# safely, without disrupting the existing neutron ml2/ovs dataplane.
OVN_MIG_PREFIX=br-mig
OVN_BR_MIGRATION=${OVN_BR_MIGRATION:-br-migration}
function recreate_bridge_mappings() {
function new_bridge_mappings() {
orig_bms=$1
if echo $orig_bms | grep $OVN_MIG_PREFIX; then
echo $orig_bms
return
fi
ovn_bms=$(echo $1 | sed 's/\"//g' | sed 's/,/ /g')
final_bm=""
br_n=0
for bm in $ovn_bms; do
parts=($(echo $bm | sed 's/:/ /g'))
physnet=${parts[0]}
bridge="${OVN_MIG_PREFIX}-${br_n}"
mapping="${physnet}:${bridge}"
if [[ -z "$final_bm" ]]; then
final_bm=$mapping
else
final_bm="${final_bm},${mapping}"
fi
# ensure bridge
ovs-vsctl --may-exist add-br $bridge
br_n=$(( br_n + 1 ))
done
echo $final_bm
}
ovn_orig_bm=$(ovs-vsctl get open . external_ids:ovn-bridge-mappings)
# backup the original mapping if we didn't already do
ovs-vsctl get open . external_ids:ovn-bridge-mappings-back || \
ovs-vsctl set open . external_ids:ovn-bridge-mappings-back="$ovn_orig_bm"
new_mapping=$(new_bridge_mappings $ovn_orig_bm)
ovs-vsctl set open . external_ids:ovn-bridge-mappings="$new_mapping"
}
function copy_interfaces_to_br_migration() {
interfaces=$(ovs-vsctl list-ifaces br-int | egrep -v 'qr-|ha-|qg-|rfp-')
for interface in $interfaces; do
if [[ "$interface" == "br-int" ]]; then
continue
fi
ifmac=$(ovs-vsctl get Interface $interface external-ids:attached-mac)
if [ $? -ne 0 ]; then
echo "Can't get port details for $interface"
continue
fi
ifstatus=$(ovs-vsctl get Interface $interface external-ids:iface-status)
ifid=$(ovs-vsctl get Interface $interface external-ids:iface-id)
ifname=x$interface
ovs-vsctl -- --may-exist add-port $OVN_BR_MIGRATION $ifname \
-- set Interface $ifname type=internal \
-- set Interface $ifname external-ids:iface-status=$ifstatus \
-- set Interface $ifname external-ids:attached-mac=$ifmac \
-- set Interface $ifname external-ids:iface-id=$ifid
echo cloned port $interface from br-int as $ifname on $OVN_BR_MIGRATION
done
}
recreate_bridge_mappings
docker restart ovn_controller
copy_interfaces_to_br_migration

@ -1,5 +0,0 @@
---
delete_neutron_resources_script: delete-neutron-resources.sh.j2
ovn_migration_temp_dir: "{{ ovn_migration_temp_dir }}"
overcloudrc: "{{ overcloudrc }}"

@ -1,20 +0,0 @@
- name: Delete temp file directory if present
file:
state: absent
path: "{{ ovn_migration_temp_dir }}"
- name : Create temp file directory if not present
file:
state: directory
path: "{{ ovn_migration_temp_dir }}"
- name: Generate neutron resources cleanup script
template:
src: "{{ delete_neutron_resources_script }}"
dest: "{{ ovn_migration_temp_dir }}/delete-neutron-resources.sh"
mode: 0744
- name: Deleting the neutron agents
shell: >
{{ ovn_migration_temp_dir }}/delete-neutron-resources.sh 2>&1 >
{{ ovn_migration_temp_dir }}/delete-neutron-resources.sh.log

@ -9,4 +9,7 @@ agent_cleanups:
neutron_dhcp:
config: --config-file /usr/share/neutron/neutron-dist.conf --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/dhcp_agent.ini --config-dir /etc/neutron/conf.d/common --config-dir /etc/neutron/conf.d/neutron-dhcp-agent --log-file=/var/log/neutron/netns-cleanup-dhcp.log
cleanup_type: dhcp
netns_regex: "qdhcp-"
netns_regex: "qdhcp-"
ovn_migration_temp_dir_del: "{{ working_dir }}/delete_neutron_resources"
tunnel_bridge: "br-tun"
ovn_bridge: "br-int"

@ -1,8 +1,7 @@
---
- name: Generate OVN activation script
template:
src: "{{ activate_ovn_script }}"
src: "activate-ovn.sh.j2"
dest: "/tmp/activate-ovn.sh"
mode: 0744

@ -1,3 +1,4 @@
---
- name: Quickly disable neutron router and dhcp interfaces
shell: |
for p in `ovs-vsctl show | egrep 'qr-|ha-|qg-|rfp-' | grep Interface | awk '{print $2}'`

@ -0,0 +1,21 @@
---
- name: Delete temp file directory if present
file:
state: absent
path: "{{ ovn_migration_temp_dir_del }}"
- name : Create temp file directory if not present
file:
state: directory
path: "{{ ovn_migration_temp_dir_del }}"
- name: Generate neutron resources cleanup script
template:
src: "delete-neutron-resources.sh.j2"
dest: "{{ ovn_migration_temp_dir_del }}/delete-neutron-resources.sh"
mode: 0744
- name: Deleting the neutron agents
shell: >
{{ ovn_migration_temp_dir_del }}/delete-neutron-resources.sh 2>&1 >
{{ ovn_migration_temp_dir_del }}/delete-neutron-resources.sh.log

@ -0,0 +1,18 @@
---
- include_tasks: clone-dataplane.yml
- include_tasks: sync-dbs.yml
when: ovn_central is defined
- include_tasks: activate-ovn.yml
- include_tasks: cleanup-dataplane.yml
when: ovn_controller is defined
tags:
- cleanup-dataplane
- include_tasks: delete-neutron-resources.yml
delegate_to: localhost
when: ovn_central is defined
tags:
- cleanup-neutron-resources

@ -0,0 +1,20 @@
---
- name: Get the neutron docker ID
shell:
docker ps | grep neutron-server-ovn | awk '{print $1}'
register: neutron_docker_id
- name: Sync neutron db with OVN db (container) - Run 1
command: docker exec "{{ neutron_docker_id.stdout }}"
neutron-ovn-db-sync-util --config-file /etc/neutron/neutron.conf
--config-file /etc/neutron/plugins/ml2/ml2_conf.ini
--ovn-neutron_sync_mode repair
- name: Sync neutron db with OVN db (container) - Run 2
command: docker exec "{{ neutron_docker_id.stdout }}"
neutron-ovn-db-sync-util --config-file /etc/neutron/neutron.conf
--config-file /etc/neutron/plugins/ml2/ml2_conf.ini
--ovn-neutron_sync_mode repair
- name: Pause and let ovn-controllers settle before doing the final activation (5 minute)
pause: minutes=5

@ -12,7 +12,7 @@ ovs-vsctl remove open . external_ids ovn-bridge-mappings-back
ovn_bms=$(echo $ovn_orig_bm | sed 's/\"//g' | sed 's/,/ /g')
# Reset OpenFlow protocol version before ovn-controller takes over
ovs-vsctl set Bridge {{ integration_bridge }} protocols=[]
ovs-vsctl set Bridge {{ ovn_bridge }} protocols=[]
for bm in $ovn_bms; do
parts=($(echo $bm | sed 's/:/ /g'))
@ -21,10 +21,10 @@ for bm in $ovn_bms; do
done
# Delete controller from integration bridge
ovs-vsctl del-controller {{ integration_bridge }}
ovs-vsctl del-controller {{ ovn_bridge }}
# Activate ovn-controller by configuring integration bridge
ovs-vsctl set open . external_ids:ovn-bridge={{ integration_bridge }}
ovs-vsctl set open . external_ids:ovn-bridge={{ ovn_bridge }}
docker start ovn_controller

@ -0,0 +1,77 @@
# The purpose of this script is to make a clone of the br-int content
# into br-migration, and to create fake provider bridges.
# This way, while we synchronize the neutron database into the OVN
# northbound DB, and that translates into southbound content all
# the ovn-controllers around are able to create the SBDB content
# safely, without disrupting the existing neutron ml2/ovs dataplane.
OVN_MIG_PREFIX=br-mig
OVN_BR_MIGRATION=${OVN_BR_MIGRATION:-br-migration}
function recreate_bridge_mappings() {
function new_bridge_mappings() {
orig_bms=$1
if echo $orig_bms | grep $OVN_MIG_PREFIX; then
echo $orig_bms
return
fi
ovn_bms=$(echo $1 | sed 's/\"//g' | sed 's/,/ /g')
final_bm=""
br_n=0
for bm in $ovn_bms; do
parts=($(echo $bm | sed 's/:/ /g'))
physnet=${parts[0]}
bridge="${OVN_MIG_PREFIX}-${br_n}"
mapping="${physnet}:${bridge}"
if [[ -z "$final_bm" ]]; then
final_bm=$mapping
else
final_bm="${final_bm},${mapping}"
fi
# ensure bridge
ovs-vsctl --may-exist add-br $bridge
br_n=$(( br_n + 1 ))
done
echo $final_bm
}
ovn_orig_bm=$(ovs-vsctl get open . external_ids:ovn-bridge-mappings)
# backup the original mapping if we didn't already do
ovs-vsctl get open . external_ids:ovn-bridge-mappings-back || \
ovs-vsctl set open . external_ids:ovn-bridge-mappings-back="$ovn_orig_bm"
new_mapping=$(new_bridge_mappings $ovn_orig_bm)
ovs-vsctl set open . external_ids:ovn-bridge-mappings="$new_mapping"
}
function copy_interfaces_to_br_migration() {
interfaces=$(ovs-vsctl list-ifaces br-int | egrep -v 'qr-|ha-|qg-|rfp-')
for interface in $interfaces; do
if [[ "$interface" == "br-int" ]]; then
continue
fi
ifmac=$(ovs-vsctl get Interface $interface external-ids:attached-mac)
if [ $? -ne 0 ]; then
echo "Can't get port details for $interface"
continue
fi
ifstatus=$(ovs-vsctl get Interface $interface external-ids:iface-status)
ifid=$(ovs-vsctl get Interface $interface external-ids:iface-id)
ifname=x$interface
ovs-vsctl -- --may-exist add-port $OVN_BR_MIGRATION $ifname \
-- set Interface $ifname type=internal \
-- set Interface $ifname external-ids:iface-status=$ifstatus \
-- set Interface $ifname external-ids:attached-mac=$ifmac \
-- set Interface $ifname external-ids:iface-id=$ifid
echo cloned port $interface from br-int as $ifname on $OVN_BR_MIGRATION
done
}
recreate_bridge_mappings
docker restart ovn_controller
copy_interfaces_to_br_migration

@ -0,0 +1,3 @@
---
ovn_migration_temp_dir: "{{ working_dir }}/post_migration_resources"

@ -0,0 +1,47 @@
---
#
# Validate pre-migration resources and then clean those up
#
- name: Validate pre migration resources after migration
include_role:
name: resources/validate
vars:
ovn_migration_temp_dir: "{{ working_dir }}/pre_migration_resources"
restart_server: true
when: validate_migration|bool
- name: Delete the pre migration resources
include_role:
name: resources/cleanup
tags:
- post-migration
vars:
ovn_migration_temp_dir: "{{ working_dir }}/pre_migration_resources"
when: validate_migration|bool
#
# Create post-migration resources, validate, and then clean up
#
- name: Create post-migration resources
include_role:
name: resources/create
vars:
resource_suffix: "post"
when: validate_migration|bool
- name: Validate post migration resources
include_role:
name: resources/validate
when: validate_migration|bool
- name: Delete the post migration resources
include_role:
name: resources/cleanup
tags:
- post-migration
vars:
resource_suffix: "post"
when: validate_migration|bool

@ -1,17 +1,13 @@
# Playbook to create pre migration resources
- name: Create the pre migration resource stack
hosts: localhost
roles:
- resources/create
include_role:
name: resources/create
vars:
ovn_migration_temp_dir: "{{ working_dir }}/pre_migration_resources"
tags:
- pre-migration
when: validate_migration|bool
- name: Validate the pre migration resources
hosts: localhost
roles:
- resources/validate
include_role:
name: resources/validate
vars:
ovn_migration_temp_dir: "{{ working_dir }}/pre_migration_resources"
when: validate_migration|bool

@ -1,6 +1,4 @@
---
cleanup_resource_script: cleanup-resources.sh.j2
ovn_migration_temp_dir: "{{ ovn_migration_temp_dir }}"
overcloudrc: "{{ overcloudrc }}"
resource_suffix: "pre"

@ -1,9 +1,4 @@
---
public_network_name: "{{ public_network_name }}"
create_migration_resource_script: create-resources.sh.j2
ovn_migration_temp_dir: "{{ ovn_migration_temp_dir }}"
image_name: "{{ image_name }}"
server_user_name: "{{ server_user_name }}"
overcloudrc: "{{ overcloudrc }}"
resource_suffix: "pre"

@ -1,5 +1,4 @@
validate_resources_script: validate-resources.sh.j2
ovn_migration_temp_dir: "{{ ovn_migration_temp_dir }}"
server_user_name: "cirros"
restart_server: false
resource_suffix: "pre"

@ -1,21 +0,0 @@
- block:
- name: Get the neutron docker ID
shell:
docker ps | grep neutron-server-ovn | awk '{print $1}'
register: neutron_docker_id
- name: Sync neutron db with OVN db (container) - Run 1
command: docker exec "{{ neutron_docker_id.stdout }}"
neutron-ovn-db-sync-util --config-file /etc/neutron/neutron.conf
--config-file /etc/neutron/plugins/ml2/ml2_conf.ini
--ovn-neutron_sync_mode repair
- name: Sync neutron db with OVN db (container) - Run 2
command: docker exec "{{ neutron_docker_id.stdout }}"
neutron-ovn-db-sync-util --config-file /etc/neutron/neutron.conf
--config-file /etc/neutron/plugins/ml2/ml2_conf.ini
--ovn-neutron_sync_mode repair
- name: Pause and let ovn-controllers settle before doing the final activation (1 minute)
pause: minutes=5
when: ovn_central is defined

@ -1,6 +1,4 @@
---
generate_ovn_extras: generate-ovn-extras.sh.j2
ovn_bridge: "{{ ovn-bridge }}"
ovn_migration_temp_dir: "{{ working_dir }}/temp_files"
container_deployment: "{{ container_deployment }}"

@ -1,15 +0,0 @@
---
- name: Backup tripleo container config files on the nodes
hosts: ovn-controllers
roles:
- backup
- name: Set up OVN and configure it using tripleo
hosts: localhost
roles:
- tripleo-update
vars:
ovn_bridge: br-migration
tags:
- ovn-setup
become: false
Loading…
Cancel
Save