diff --git a/docker/services/neutron-ovs-agent.yaml b/docker/services/neutron-ovs-agent.yaml index 4d0df182ee..803bbf494b 100644 --- a/docker/services/neutron-ovs-agent.yaml +++ b/docker/services/neutron-ovs-agent.yaml @@ -180,7 +180,27 @@ outputs: - KOLLA_CONFIG_STRATEGY=COPY_ALWAYS metadata_settings: get_attr: [NeutronOvsAgentBase, role_data, metadata_settings] - host_prep_tasks: {get_attr: [NeutronLogging, host_prep_tasks]} + host_prep_tasks: + list_concat: + - {get_attr: [NeutronLogging, host_prep_tasks]} + - + - block: + - name: Copy in cleanup script + copy: + content: {get_file: ./neutron/neutron-cleanup} + dest: '/usr/libexec/neutron-cleanup' + force: yes + mode: '0755' + - name: Copy in cleanup service + copy: + content: {get_file: ./neutron/neutron-cleanup.service} + dest: '/usr/lib/systemd/system/neutron-cleanup.service' + force: yes + - name: Enabling the cleanup service + service: + name: neutron-cleanup + enabled: yes + upgrade_tasks: list_concat: - get_attr: [NeutronOvsAgentBase, role_data, ovs_upgrade_tasks] diff --git a/docker/services/neutron/neutron-cleanup b/docker/services/neutron/neutron-cleanup new file mode 100644 index 0000000000..31ecf70214 --- /dev/null +++ b/docker/services/neutron/neutron-cleanup @@ -0,0 +1,21 @@ +#!/bin/bash +# Cleanup neutron OVS bridges. To be called on startup to avoid +# "difficult-to-debug" issues with partially configured resources. + +NEUTRON_OVS_CONF=/var/lib/config-data/puppet-generated/neutron/etc/neutron/plugins/ml2/openvswitch_agent.ini + +if [ -e ${NEUTRON_OVS_CONF} ]; +then + INT_BRIDGE=`crudini --get ${NEUTRON_OVS_CONF} ovs integration_bridge` + TUN_BRIDGE=`crudini --get ${NEUTRON_OVS_CONF} ovs tunnel_bridge` +fi + +for br in ${INT_BRIDGE:-"br-int"} ${TUN_BRIDGE:-"br-tun"}; +do + ovs-vsctl --if-exists del-br $br +done + +# Clean up trunk port bridges +for br in $(ovs-vsctl list-br | egrep 'tbr-[0-9a-f\-]+'); do + ovs-vsctl --if-exists del-br $br +done diff --git a/docker/services/neutron/neutron-cleanup.service b/docker/services/neutron/neutron-cleanup.service new file mode 100644 index 0000000000..53db312157 --- /dev/null +++ b/docker/services/neutron/neutron-cleanup.service @@ -0,0 +1,12 @@ +[Unit] +Description=Neutron cleanup on startup +After=openvswitch.service network.target +Before=docker.service +RefuseManualStop=yes + +[Service] +Type=oneshot +ExecStart=/usr/libexec/neutron-cleanup + +[Install] +WantedBy=multi-user.target diff --git a/releasenotes/notes/neutron-cleanup-services-3a8579cd03fac953.yaml b/releasenotes/notes/neutron-cleanup-services-3a8579cd03fac953.yaml new file mode 100644 index 0000000000..a624e04a92 --- /dev/null +++ b/releasenotes/notes/neutron-cleanup-services-3a8579cd03fac953.yaml @@ -0,0 +1,4 @@ +--- +features: + - | + Add cleanup services for neutron bridges that work with container based deployments.