OvS: Implement cleaner shutdown and start logic
This PS adds cleaner shutdown and start logic to the OvS components. Change-Id: I5c7fb212163a19d7584b37c20e7c6c757b498856 Co-Authored-By: SamYaple <sam@yaple.net>
This commit is contained in:
parent
f5a6a5dedc
commit
cc81c5f558
@ -17,15 +17,32 @@ limitations under the License.
|
|||||||
*/}}
|
*/}}
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
COMMAND="${@:-start}"
|
||||||
|
|
||||||
mkdir -p "/run/openvswitch"
|
OVS_DB=/run/openvswitch/conf.db
|
||||||
if [[ ! -e "/run/openvswitch/conf.db" ]]; then
|
OVS_SOCKET=/run/openvswitch/db.sock
|
||||||
ovsdb-tool create "/run/openvswitch/conf.db"
|
OVS_SCHEMA=/usr/share/openvswitch/vswitch.ovsschema
|
||||||
fi
|
|
||||||
|
|
||||||
umask 000
|
function start () {
|
||||||
exec /usr/sbin/ovsdb-server /run/openvswitch/conf.db \
|
mkdir -p "$(dirname ${OVS_DB})"
|
||||||
|
if [[ ! -e "${OVS_DB}" ]]; then
|
||||||
|
ovsdb-tool create "${OVS_DB}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$(ovsdb-tool needs-conversion ${OVS_DB} ${OVS_SCHEMA})" == 'yes' ]]; then
|
||||||
|
ovsdb-tool convert ${OVS_DB} ${OVS_SCHEMA}
|
||||||
|
fi
|
||||||
|
|
||||||
|
umask 000
|
||||||
|
exec /usr/sbin/ovsdb-server ${OVS_DB} \
|
||||||
-vconsole:emer \
|
-vconsole:emer \
|
||||||
-vconsole:err \
|
-vconsole:err \
|
||||||
-vconsole:info \
|
-vconsole:info \
|
||||||
--remote=punix:/run/openvswitch/db.sock
|
--remote=punix:${OVS_SOCKET}
|
||||||
|
}
|
||||||
|
|
||||||
|
function stop () {
|
||||||
|
ovs-appctl -T1 -t /run/openvswitch/ovsdb-server.1.ctl exit
|
||||||
|
}
|
||||||
|
|
||||||
|
$COMMAND
|
||||||
|
@ -17,10 +17,13 @@ limitations under the License.
|
|||||||
*/}}
|
*/}}
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
COMMAND="${@:-start}"
|
||||||
|
|
||||||
sock="/var/run/openvswitch/db.sock"
|
OVS_SOCKET=/run/openvswitch/db.sock
|
||||||
t=0
|
|
||||||
while [ ! -e "${sock}" ] ; do
|
function start () {
|
||||||
|
t=0
|
||||||
|
while [ ! -e "${OVS_SOCKET}" ] ; do
|
||||||
echo "waiting for ovs socket $sock"
|
echo "waiting for ovs socket $sock"
|
||||||
sleep 1
|
sleep 1
|
||||||
t=$(($t+1))
|
t=$(($t+1))
|
||||||
@ -28,13 +31,13 @@ while [ ! -e "${sock}" ] ; do
|
|||||||
echo "no ovs socket, giving up"
|
echo "no ovs socket, giving up"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
ovs-vsctl --no-wait show
|
ovs-vsctl --no-wait show
|
||||||
|
|
||||||
external_bridge="{{- .Values.network.external_bridge -}}"
|
external_bridge="{{- .Values.network.external_bridge -}}"
|
||||||
external_interface="{{- .Values.network.interface.external -}}"
|
external_interface="{{- .Values.network.interface.external -}}"
|
||||||
if [ -n "${external_bridge}" ] ; then
|
if [ -n "${external_bridge}" ] ; then
|
||||||
# create bridge device
|
# create bridge device
|
||||||
ovs-vsctl --no-wait --may-exist add-br $external_bridge
|
ovs-vsctl --no-wait --may-exist add-br $external_bridge
|
||||||
if [ -n "$external_interface" ] ; then
|
if [ -n "$external_interface" ] ; then
|
||||||
@ -42,22 +45,29 @@ if [ -n "${external_bridge}" ] ; then
|
|||||||
ovs-vsctl --no-wait --may-exist add-port $external_bridge $external_interface
|
ovs-vsctl --no-wait --may-exist add-port $external_bridge $external_interface
|
||||||
ip link set dev $external_interface up
|
ip link set dev $external_interface up
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# handle any bridge mappings
|
# handle any bridge mappings
|
||||||
{{- range $br, $phys := .Values.network.auto_bridge_add }}
|
{{- range $br, $phys := .Values.network.auto_bridge_add }}
|
||||||
if [ -n "{{- $br -}}" ] ; then
|
if [ -n "{{- $br -}}" ] ; then
|
||||||
# create {{ $br }}{{ if $phys }} and add port {{ $phys }}{{ end }}
|
# create {{ $br }}{{ if $phys }} and add port {{ $phys }}{{ end }}
|
||||||
ovs-vsctl --no-wait --may-exist add-br "{{ $br }}"
|
ovs-vsctl --no-wait --may-exist add-br "{{ $br }}"
|
||||||
if [ -n "{{- $phys -}}" ] ; then
|
if [ -n "{{- $phys -}}" ] ; then
|
||||||
ovs-vsctl --no-wait --may-exist add-port "{{ $br }}" "{{ $phys }}"
|
ovs-vsctl --no-wait --may-exist add-port "{{ $br }}" "{{ $phys }}"
|
||||||
ip link set dev "{{ $phys }}" up
|
ip link set dev "{{ $phys }}" up
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
exec /usr/sbin/ovs-vswitchd unix:/run/openvswitch/db.sock \
|
exec /usr/sbin/ovs-vswitchd unix:${OVS_SOCKET} \
|
||||||
-vconsole:emer \
|
-vconsole:emer \
|
||||||
-vconsole:err \
|
-vconsole:err \
|
||||||
-vconsole:info \
|
-vconsole:info \
|
||||||
--mlockall
|
--mlockall
|
||||||
|
}
|
||||||
|
|
||||||
|
function stop () {
|
||||||
|
ovs-appctl -T1 -t /run/openvswitch/ovs-vswitchd.1.ctl exit
|
||||||
|
}
|
||||||
|
|
||||||
|
$COMMAND
|
||||||
|
@ -44,6 +44,13 @@ spec:
|
|||||||
privileged: true
|
privileged: true
|
||||||
command:
|
command:
|
||||||
- /tmp/openvswitch-db-server.sh
|
- /tmp/openvswitch-db-server.sh
|
||||||
|
- start
|
||||||
|
lifecycle:
|
||||||
|
preStop:
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- /tmp/openvswitch-db-server.sh
|
||||||
|
- stop
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: openvswitch-bin
|
- name: openvswitch-bin
|
||||||
mountPath: /tmp/openvswitch-db-server.sh
|
mountPath: /tmp/openvswitch-db-server.sh
|
||||||
|
@ -70,6 +70,13 @@ spec:
|
|||||||
- show
|
- show
|
||||||
command:
|
command:
|
||||||
- /tmp/openvswitch-vswitchd.sh
|
- /tmp/openvswitch-vswitchd.sh
|
||||||
|
- start
|
||||||
|
lifecycle:
|
||||||
|
preStop:
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- /tmp/openvswitch-db-server.sh
|
||||||
|
- stop
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: openvswitch-bin
|
- name: openvswitch-bin
|
||||||
mountPath: /tmp/openvswitch-vswitchd.sh
|
mountPath: /tmp/openvswitch-vswitchd.sh
|
||||||
|
Loading…
x
Reference in New Issue
Block a user