From bfeb52b9752efdcdfcbae93c040ef7e723cf11fe Mon Sep 17 00:00:00 2001 From: Jakub Libosvar Date: Tue, 28 Apr 2020 09:47:10 +0200 Subject: [PATCH] migration: Replace paunch with podman and ip commands The patch removes paunch and cleans network namespaces by iterating over namespaces belonging to Neutron agents. It also clears side-car containers spawned by Neutron using podman command. Change-Id: I017e7b3c3674e065a523eff5ebbea352f619f45e --- .../roles/migration/defaults/main.yml | 11 ---- .../migration/tasks/cleanup-dataplane.yml | 51 ++++--------------- 2 files changed, 11 insertions(+), 51 deletions(-) diff --git a/tools/ovn_migration/tripleo_environment/playbooks/roles/migration/defaults/main.yml b/tools/ovn_migration/tripleo_environment/playbooks/roles/migration/defaults/main.yml index 94af8d4ab72..ce745eda184 100644 --- a/tools/ovn_migration/tripleo_environment/playbooks/roles/migration/defaults/main.yml +++ b/tools/ovn_migration/tripleo_environment/playbooks/roles/migration/defaults/main.yml @@ -1,15 +1,4 @@ --- -agent_cleanups: - neutron_l3_agent: - config: --config-file /usr/share/neutron/neutron-dist.conf --config-dir /usr/share/neutron/l3_agent --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/l3_agent.ini --config-dir /etc/neutron/conf.d/common --config-dir /etc/neutron/conf.d/neutron-l3-agent --log-file=/var/log/neutron/netns-cleanup-l3.log - cleanup_type: l3 - netns_regex: "fip-|snat-|qrouter-" - - 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-" - tunnel_bridge: "br-tun" ovn_bridge: "br-int" diff --git a/tools/ovn_migration/tripleo_environment/playbooks/roles/migration/tasks/cleanup-dataplane.yml b/tools/ovn_migration/tripleo_environment/playbooks/roles/migration/tasks/cleanup-dataplane.yml index d9c8661161e..bdedb11115c 100644 --- a/tools/ovn_migration/tripleo_environment/playbooks/roles/migration/tasks/cleanup-dataplane.yml +++ b/tools/ovn_migration/tripleo_environment/playbooks/roles/migration/tasks/cleanup-dataplane.yml @@ -35,45 +35,16 @@ changed_when: "'Security groups cleaned' in out.stdout" - name: Cleanup neutron datapath resources + become: yes shell: | - # avoid cleaning up dhcp namespaces if the neutron dhcp agent is up (SR-IOV use case) - if [[ "{{ item.value.cleanup_type }}" == "dhcp" ]]; then - docker inspect neutron_dhcp && echo "Shouldn't clean DHCP namespaces if neutron_dhcp docker is up" && exit 0 - fi - - if ip netns | egrep -e "{{ item.value.netns_regex }}" - then - echo "Cleaning up" - cmd="$(paunch debug --file {{ ovn_migration_backups }}/tripleo-config/hashed-container-startup-config-step_4.json \ - --action print-cmd --container {{ item.key }} \ - --interactive | \ - sed 's/--interactive /--volume=\/tmp\/cleanup-{{ item.key }}.sh:\/cleanup.sh:ro /g ' )" - - f="/tmp/cleanup-{{ item.key }}.sh" - f_cmd="/tmp/container-cmd-{{ item.key }}.sh" - - echo "#!/bin/sh" > $f - echo "set -x" >> $f - echo "set -e" >> $f - echo "sudo -E kolla_set_configs" >> $f - echo "neutron-netns-cleanup {{ item.value.config }} --agent-type {{ item.value.cleanup_type }} --force" >> $f - - chmod a+x $f - - echo $cmd /cleanup.sh - - echo "#!/bin/sh" > $f_cmd - echo "set -x" >> $f_cmd - echo "set -e" >> $f_cmd - echo $cmd /cleanup.sh >> $f_cmd - chmod a+x $f_cmd - $f_cmd - - fi - with_dict: "{{ agent_cleanups }}" - register: out - changed_when: "'Cleaning up' in out.stdout" - - - + for container in $(podman ps -a --format {% raw %}"{{.ID}}"{% endraw %} --filter "name=(neutron-(dibbler|dnsmasq|haproxy|keepalived)-.*|dhcp_dnsmasq|dhcp_haproxy|l3_keepalived|l3_haproxy|l3_dibbler|l3_radvd)"); do + echo "Cleaning up side-car container $container" + podman stop $container + podman rm -f $container + done + # cleanup Neutron ml2/ovs namespaces + for netns in $(ip netns | awk '/^(snat|fip|qdhcp|qrouter)-/{ print $1 }'); do + echo "Cleaning up namespace $netns" + ip netns delete $netns + done