From 81265737187f32eef2b654a901ed74818873eb88 Mon Sep 17 00:00:00 2001 From: beagles Date: Tue, 7 Aug 2018 10:41:04 -0230 Subject: [PATCH] Add cleanup service for neutron ovs bridges Neutron used to run a neutron-ovs-cleanup service on startup and shutdown to ensure clean configuration. Container specific version of the cleanup service is needed as we are no longer installing neutron packages in the overcloud image and the ordering dependencies of the legacy services are not suitable for containerized neutron deployments. Closes-Bug: #1786311 Change-Id: Iddd191f06b0a7cadb463abec7ef152c89fddb3cd --- docker/services/neutron-ovs-agent.yaml | 22 ++++++++++++++++++- docker/services/neutron/neutron-cleanup | 21 ++++++++++++++++++ .../services/neutron/neutron-cleanup.service | 12 ++++++++++ ...ron-cleanup-services-3a8579cd03fac953.yaml | 4 ++++ 4 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 docker/services/neutron/neutron-cleanup create mode 100644 docker/services/neutron/neutron-cleanup.service create mode 100644 releasenotes/notes/neutron-cleanup-services-3a8579cd03fac953.yaml 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.