Skip to content

Commit

Permalink
reduce ovs-ovn restart downtime (#1516)
Browse files Browse the repository at this point in the history
1. start ovsdb  without vswitchd
2. set flow-restore-wait to true to prevent vswitchd flush the flow
3. start ovn-controller and wait ${FLOW_WAIT} seconds to compute init flow
4. set flow-restore-wait to false to indicate vswitchd to process

(cherry picked from commit d7ef43b)
  • Loading branch information
oilbeater committed May 11, 2022
1 parent e4d6cc2 commit 9e5b2b2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,12 @@ kind-reload:
kubectl delete pod -n kube-system -l app=kube-ovn-controller
kubectl delete pod -n kube-system -l app=kube-ovn-cni
kubectl delete pod -n kube-system -l app=kube-ovn-pinger
kubectl delete pod -n kube-system -l app=ovs

.PHONY: kind-reload-ovs
kind-reload-ovs:
kind load docker-image --name kube-ovn $(REGISTRY)/kube-ovn:$(RELEASE_TAG)
kubectl delete pod -n kube-system -l app=ovs

.PHONY: kind-clean
kind-clean:
Expand Down
16 changes: 14 additions & 2 deletions dist/images/start-ovs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ HW_OFFLOAD=${HW_OFFLOAD:-false}
ENABLE_SSL=${ENABLE_SSL:-false}
OVN_DB_IPS=${OVN_DB_IPS:-}
TUNNEL_TYPE=${TUNNEL_TYPE:-geneve}
FLOW_WAIT=${FLOW_WAIT:-5}

# Check required kernel module
modinfo openvswitch
Expand Down Expand Up @@ -51,14 +52,19 @@ if [[ `nproc` -gt 12 ]]; then
ovs-vsctl --no-wait set Open_vSwitch . other_config:n-handler-threads=10
fi

# When ovs-vswitchd starts with this value set as true, it will neither flush or
# expire previously set datapath flows nor will it send and receive any
# packets to or from the datapath. Please check ovs-vswitchd.conf.db.5.txt
ovs-vsctl --no-wait set open_vswitch . other_config:flow-restore-wait="true"

if [ "$HW_OFFLOAD" = "true" ]; then
ovs-vsctl --no-wait set open_vswitch . other_config:hw-offload=true
else
ovs-vsctl --no-wait set open_vswitch . other_config:hw-offload=false
fi

# Start vswitchd
/usr/share/openvswitch/scripts/ovs-ctl restart --no-ovsdb-server --system-id=random
# Start vswitchd. restart will automatically set/unset flow-restore-wait which is not what we want
/usr/share/openvswitch/scripts/ovs-ctl start --no-ovsdb-server --system-id=random
/usr/share/openvswitch/scripts/ovs-ctl --protocol=udp --dport=6081 enable-protocol

sleep 1
Expand Down Expand Up @@ -161,5 +167,11 @@ if [[ "$ENABLE_SSL" == "false" ]]; then
else
/usr/share/ovn/scripts/ovn-ctl --ovn-controller-ssl-key=/var/run/tls/key --ovn-controller-ssl-cert=/var/run/tls/cert --ovn-controller-ssl-ca-cert=/var/run/tls/cacert restart_controller
fi

# Wait ovn-controller finish init flow compute and update it to vswitchd,
# then update flow-restore-wait to indicate vswitchd to process flows
sleep ${FLOW_WAIT}
ovs-vsctl --no-wait set open_vswitch . other_config:flow-restore-wait="false"

chmod 600 /etc/openvswitch/*
tail -f /var/log/ovn/ovn-controller.log

0 comments on commit 9e5b2b2

Please sign in to comment.