From 6e2e4aba8d1053adb6dcfc598c5c3d78c3195c94 Mon Sep 17 00:00:00 2001 From: chengli3 <cheng1.li@intel.com> Date: Mon, 25 Feb 2019 20:15:53 +0800 Subject: [PATCH] Support per-host overrides of auto_bridge_add .Values.network.auto_bridge_add is a global config. So in multi nodes deployment, it requires that all hosts have the same nic names. This is a strict limit. This patch is to support per-host auto_bridge_add, so that we can define different auto_bridge_add for hosts. Also, this patch move .network.auto_bridge_add to .conf.auto_bridge_add Change-Id: I4a4d6efbbfe073d035bc5c03700fbe998e708d0f Story: 2005059 Task: 29601 --- doc/source/devref/networking.rst | 2 +- .../_neutron-linuxbridge-agent-init.sh.tpl | 28 ++++++++------- .../_neutron-openvswitch-agent-init.sh.tpl | 18 ++++++---- neutron/templates/configmap-etc.yaml | 1 + neutron/templates/daemonset-lb-agent.yaml | 4 +++ neutron/templates/daemonset-ovs-agent.yaml | 4 +++ neutron/values.yaml | 34 +++++++++---------- 7 files changed, 53 insertions(+), 38 deletions(-) diff --git a/doc/source/devref/networking.rst b/doc/source/devref/networking.rst index e10a045488..7b1afd7c67 100644 --- a/doc/source/devref/networking.rst +++ b/doc/source/devref/networking.rst @@ -272,7 +272,7 @@ init container and main container with :code:`neutron-ovs-agent` via file Configuration of OVS bridges can be done via `neutron/templates/bin/_neutron-openvswitch-agent-init.sh.tpl`. The script is configuring the external network bridge and sets up any -bridge mappings defined in :code:`network.auto_bridge_add`. These +bridge mappings defined in :code:`conf.auto_bridge_add`. These values should align with :code:`conf.plugins.openvswitch_agent.ovs.bridge_mappings`. diff --git a/neutron/templates/bin/_neutron-linuxbridge-agent-init.sh.tpl b/neutron/templates/bin/_neutron-linuxbridge-agent-init.sh.tpl index e89765a3ed..71a2b6bf29 100644 --- a/neutron/templates/bin/_neutron-linuxbridge-agent-init.sh.tpl +++ b/neutron/templates/bin/_neutron-linuxbridge-agent-init.sh.tpl @@ -19,19 +19,21 @@ limitations under the License. set -ex # configure all bridge mappings defined in config -{{- range $br, $phys := .Values.network.auto_bridge_add }} -if [ -n "{{- $br -}}" ] ; then - # adding existing bridge would break out the script when -e is set - set +e - ip link add name {{ $br }} type bridge - set -e - ip link set dev {{ $br }} up - if [ -n "{{- $phys -}}" ] ; then - ip link set dev {{ $phys }} master {{ $br }} - fi -fi -{{- end }} - +# /tmp/auto_bridge_add is one line json file: {"br-ex1":"eth1","br-ex2":"eth2"} +for bmap in `sed 's/[{}"]//g' /tmp/auto_bridge_add | tr "," "\n"` +do + bridge=${bmap%:*} + iface=${bmap#*:} + # adding existing bridge would break out the script when -e is set + set +e + ip link add name $bridge type bridge + set -e + ip link set dev $bridge up + if [ -n "$iface" ] && [ "$iface" != "null" ] + then + ip link set dev $iface master $bridge + fi +done tunnel_interface="{{- .Values.network.interface.tunnel -}}" if [ -z "${tunnel_interface}" ] ; then diff --git a/neutron/templates/bin/_neutron-openvswitch-agent-init.sh.tpl b/neutron/templates/bin/_neutron-openvswitch-agent-init.sh.tpl index 08c82e0503..84f5e4b2e2 100644 --- a/neutron/templates/bin/_neutron-openvswitch-agent-init.sh.tpl +++ b/neutron/templates/bin/_neutron-openvswitch-agent-init.sh.tpl @@ -36,13 +36,17 @@ if neutron-sanity-check --version >/dev/null 2>/dev/null; then fi # handle any bridge mappings -{{- range $bridge, $port := .Values.network.auto_bridge_add }} -ovs-vsctl --no-wait --may-exist add-br {{ $bridge }} -{{ if $port }} -ovs-vsctl --no-wait --may-exist add-port {{ $bridge }} {{ $port }} -ip link set dev {{ $port }} up -{{ end }} -{{- end }} +# /tmp/auto_bridge_add is one line json file: {"br-ex1":"eth1","br-ex2":"eth2"} +for bmap in `sed 's/[{}"]//g' /tmp/auto_bridge_add | tr "," "\n"` +do + bridge=${bmap%:*} + iface=${bmap#*:} + ovs-vsctl --no-wait --may-exist add-br $bridge + if [ -n "$iface" ] && [ "$iface" != "null" ] + then + ovs-vsctl --no-wait --may-exist add-port $bridge $iface + fi +done tunnel_interface="{{- .Values.network.interface.tunnel -}}" if [ -z "${tunnel_interface}" ] ; then diff --git a/neutron/templates/configmap-etc.yaml b/neutron/templates/configmap-etc.yaml index 027602bbff..4ee577498d 100644 --- a/neutron/templates/configmap-etc.yaml +++ b/neutron/templates/configmap-etc.yaml @@ -196,6 +196,7 @@ data: dnsmasq.conf: "" neutron_sudoers: {{ $envAll.Values.conf.neutron_sudoers | b64enc }} rootwrap.conf: {{ $envAll.Values.conf.rootwrap | b64enc }} + auto_bridge_add: {{ toJson $envAll.Values.conf.auto_bridge_add | b64enc }} {{- range $key, $value := $envAll.Values.conf.rootwrap_filters }} {{- $filePrefix := replace "_" "-" $key }} {{ printf "%s.filters" $filePrefix }}: {{ $value.content | b64enc }} diff --git a/neutron/templates/daemonset-lb-agent.yaml b/neutron/templates/daemonset-lb-agent.yaml index 1c7da46ef5..c2b432f799 100644 --- a/neutron/templates/daemonset-lb-agent.yaml +++ b/neutron/templates/daemonset-lb-agent.yaml @@ -111,6 +111,10 @@ spec: mountPath: /etc/sudoers.d/kolla_neutron_sudoers subPath: neutron_sudoers readOnly: true + - name: neutron-etc + mountPath: /tmp/auto_bridge_add + subPath: auto_bridge_add + readOnly: true - name: neutron-etc mountPath: /etc/neutron/rootwrap.conf subPath: rootwrap.conf diff --git a/neutron/templates/daemonset-ovs-agent.yaml b/neutron/templates/daemonset-ovs-agent.yaml index e17693f5b3..2e66844076 100644 --- a/neutron/templates/daemonset-ovs-agent.yaml +++ b/neutron/templates/daemonset-ovs-agent.yaml @@ -121,6 +121,10 @@ spec: mountPath: /etc/sudoers.d/kolla_neutron_sudoers subPath: neutron_sudoers readOnly: true + - name: neutron-etc + mountPath: /tmp/auto_bridge_add + subPath: auto_bridge_add + readOnly: true - name: neutron-etc mountPath: /etc/neutron/rootwrap.conf subPath: rootwrap.conf diff --git a/neutron/values.yaml b/neutron/values.yaml index a366dee793..cf56ac57f5 100644 --- a/neutron/values.yaml +++ b/neutron/values.yaml @@ -90,18 +90,6 @@ network: # allowing agents to be restarted without packet loss and simpler # debugging. This feature requires mount propagation support. share_namespaces: true - # auto_bridge_add is a table of "bridge: interface" pairs - # To automatically add a physical interfaces to a specific bridges, - # for example eth3 to bridge br-physnet1, if0 to br0 and iface_two - # to br1 do something like: - # - # auto_bridge_add: - # br-physnet1: eth3 - # br0: if0 - # br1: iface_two - # br-ex will be added by default - auto_bridge_add: - br-ex: null interface: # Tunnel interface will be used for VXLAN tunneling. If null # (default) there is a fallback mechanism to search for interface @@ -1632,13 +1620,25 @@ conf: priority: 0 apply-to: all pattern: '(notifications)\.' + ## NOTE: "besteffort" is meant for dev env with mixed compute type only. + ## This helps prevent sriov init script from failing due to mis-matched NIC + ## For prod env, target NIC should match and init script should fail otherwise. + ## sriov_init: + ## - besteffort sriov_init: - - ## NOTE: "besteffort" is meant for dev env with mixed compute type only. - ## This helps prevent sriov init script from failing due to mis-matched NIC - ## For prod env, target NIC should match and init script should fail otherwise. - ## sriov_init: - ## - besteffort + # auto_bridge_add is a table of "bridge: interface" pairs + # To automatically add a physical interfaces to a specific bridges, + # for example eth3 to bridge br-physnet1, if0 to br0 and iface_two + # to br1 do something like: + # + # auto_bridge_add: + # br-physnet1: eth3 + # br0: if0 + # br1: iface_two + # br-ex will be added by default + auto_bridge_add: + br-ex: null # Names of secrets used by bootstrap and environmental checks secrets: