ovs-ctl.in: Don't stop forwarding while restarting the database.
authorJustin Pettit <jpettit@nicira.com>
Thu, 26 Jul 2012 16:41:24 +0000 (09:41 -0700)
committerJustin Pettit <jpettit@nicira.com>
Mon, 30 Jul 2012 22:47:43 +0000 (15:47 -0700)
Previously, the force-reload-kmod command would stop forwarding, stop
the database, restart the database, and then restart forwarding.  If the
database is large, it can take a while to be read (we've seen as much as
10 seconds), which means the switch is not forwarding traffic during
that time.

This change stops and starts the database before restarting the
forwarding path.  This means that ovs-vswitchd will lose its
connectivity to the database during a force-reload-kmod, but while it
will complain a little in the logs, it will continue to operate
properly.

Signed-off-by: Justin Pettit <jpettit@nicira.com>
Feature #12643

utilities/ovs-ctl.in

index cb41cc0..dbb629a 100755 (executable)
@@ -172,12 +172,14 @@ set_system_ids () {
     action "Configuring Open vSwitch system IDs" "$@" $extra_ids
 }
 
-start () {
+check_force_cores () {
     if test X"$FORCE_COREFILES" = Xyes; then
         ulimit -Sc 67108864
     fi
+}
 
-    insert_mod_if_required || return 1
+start_ovsdb () {
+    check_force_cores
 
     if daemon_is_running ovsdb-server; then
         log_success_msg "ovsdb-server is already running"
@@ -206,6 +208,12 @@ start () {
             done
         fi
     fi
+}
+
+start_forwarding () {
+    check_force_cores
+
+    insert_mod_if_required || return 1
 
     if daemon_is_running ovs-vswitchd; then
         log_success_msg "ovs-vswitchd is already running"
@@ -237,10 +245,13 @@ start () {
 ## stop ##
 ## ---- ##
 
-stop () {
+stop_ovsdb () {
+    stop_daemon ovsdb-server
+}
+
+stop_forwarding () {
     stop_daemon ovs-brcompatd
     stop_daemon ovs-vswitchd
-    stop_daemon ovsdb-server
 }
 
 ## ----------------- ##
@@ -276,7 +287,12 @@ force_reload_kmod () {
     ifaces=`internal_interfaces`
     action "Detected internal interfaces: $ifaces" true
 
-    stop
+    # Restart the database first, since a large database may take a
+    # while to load, and we want to minimize forwarding disruption.
+    stop_ovsdb
+    start_ovsdb
+
+    stop_forwarding
 
     script=`mktemp`
     trap 'rm -f "$script"' 0 1 2 13 15
@@ -284,7 +300,7 @@ force_reload_kmod () {
         :
     else
         log_warning_msg "Failed to save configuration, not replacing kernel module"
-        start
+        start_forwarding
         exit 1
     fi
     chmod +x "$script"
@@ -305,7 +321,7 @@ force_reload_kmod () {
         action "Removing openvswitch module" rmmod openvswitch
     fi
 
-    start
+    start_forwarding
 
     action "Restoring interface configuration" "$script"
     rc=$?
@@ -567,10 +583,12 @@ do
 done
 case $command in
     start)
-        start
+        start_ovsdb
+        start_forwarding
         ;;
     stop)
-        stop
+        stop_forwarding
+        stop_ovsdb
         ;;
     status)
         rc=0