diff --git a/neutron/templates/bin/_neutron-openvswitch-agent-init.sh.tpl b/neutron/templates/bin/_neutron-openvswitch-agent-init.sh.tpl index bbc88321dd..60df78948f 100644 --- a/neutron/templates/bin/_neutron-openvswitch-agent-init.sh.tpl +++ b/neutron/templates/bin/_neutron-openvswitch-agent-init.sh.tpl @@ -21,6 +21,10 @@ set -ex OVS_SOCKET=/run/openvswitch/db.sock chown neutron: ${OVS_SOCKET} +# This enables the usage of 'ovs-appctl' from neutron pod. +OVS_PID=$(cat /run/openvswitch/ovs-vswitchd.pid) +OVS_CTL=/run/openvswitch/ovs-vswitchd.${OVS_PID}.ctl +chown neutron: ${OVS_CTL} function get_dpdk_config_value { values=$1 diff --git a/neutron/templates/bin/_neutron-openvswitch-agent-readiness.sh.tpl b/neutron/templates/bin/_neutron-openvswitch-agent-readiness.sh.tpl new file mode 100644 index 0000000000..d78ac5eb79 --- /dev/null +++ b/neutron/templates/bin/_neutron-openvswitch-agent-readiness.sh.tpl @@ -0,0 +1,52 @@ +#!/bin/bash + +{{/* +Copyright 2019 The Openstack-Helm Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/}} + +set -e + +OVS_PID=$(cat /run/openvswitch/ovs-vswitchd.pid) +OVS_CTL=/run/openvswitch/ovs-vswitchd.${OVS_PID}.ctl + +ovs-vsctl list-br | grep -q br-int + +[ -z "$(/usr/bin/ovs-vsctl show | grep error:)" ] + +{{ if .Values.conf.ovs_dpdk.enabled }} + + # Check if dpdk is initialized + [ "$(ovs-vsctl get Open_vSwitch . dpdk_initialized)" == true ] + + {{- if hasKey .Values.conf.ovs_dpdk "nics"}} + # Check if port(s) and bridge(s) are configured. + {{- range .Values.conf.ovs_dpdk.nics }} + ovs-vsctl list-br | grep -q {{ .bridge }} + ovs-vsctl list-ports {{ .bridge }} | grep -q {{ .name }} + {{- end }} + {{- end }} + + {{- if hasKey .Values.conf.ovs_dpdk "bonds"}} + # Check if bond(s) and slave(s) are configured. + {{- range .Values.conf.ovs_dpdk.bonds }} + bond={{ .name }} + ovs-appctl -t ${OVS_CTL} bond/list | grep -q ${bond} + {{- range .nics }} + ovs-appctl -t ${OVS_CTL} bond/show ${bond} | grep -q "slave {{ .name }}" + {{- end }} + {{- end }} + {{- end }} + +{{ end }} diff --git a/neutron/templates/configmap-bin.yaml b/neutron/templates/configmap-bin.yaml index 0ec16557d0..20baba9813 100644 --- a/neutron/templates/configmap-bin.yaml +++ b/neutron/templates/configmap-bin.yaml @@ -67,6 +67,8 @@ data: {{ tuple "bin/_neutron-openvswitch-agent-init.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} neutron-openvswitch-agent-init-modules.sh: | {{ tuple "bin/_neutron-openvswitch-agent-init-modules.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} + neutron-openvswitch-agent-readiness.sh: | +{{ tuple "bin/_neutron-openvswitch-agent-readiness.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} neutron-sriov-agent.sh: | {{ tuple "bin/_neutron-sriov-agent.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} neutron-sriov-agent-init.sh: | diff --git a/neutron/templates/daemonset-ovs-agent.yaml b/neutron/templates/daemonset-ovs-agent.yaml index 8a97288b92..9c815faa73 100644 --- a/neutron/templates/daemonset-ovs-agent.yaml +++ b/neutron/templates/daemonset-ovs-agent.yaml @@ -15,13 +15,9 @@ limitations under the License. */}} {{- define "ovsAgentReadinessProbeTemplate" }} -# ensures this container can can see a br-int -# bridge before its marked as ready exec: command: - - bash - - -c - - 'ovs-vsctl list-br | grep -q br-int' + - /tmp/neutron-openvswitch-agent-readiness.sh {{- end }} {{- define "ovsAgentLivenessProbeTemplate" }} exec: @@ -204,6 +200,10 @@ spec: mountPath: /tmp/neutron-openvswitch-agent.sh subPath: neutron-openvswitch-agent.sh readOnly: true + - name: neutron-bin + mountPath: /tmp/neutron-openvswitch-agent-readiness.sh + subPath: neutron-openvswitch-agent-readiness.sh + readOnly: true - name: neutron-bin mountPath: /tmp/health-probe.py subPath: health-probe.py