ovs-vsctl: Remove default timeout.
authorBen Pfaff <blp@nicira.com>
Fri, 17 Sep 2010 21:37:51 +0000 (14:37 -0700)
committerBen Pfaff <blp@nicira.com>
Fri, 17 Sep 2010 21:37:51 +0000 (14:37 -0700)
On overloaded XenServers the current default timeout of 5 seconds can
occasionally be reached, which causes VM startup to fail.  This commit
fixes the problem by removing the default timeout and changing each
invocation of ovs-vsctl within the tree to specify its own timeout,
if appropriate.

Bug #3573.

debian/openvswitch-switch.init
utilities/ovs-vsctl.8.in
utilities/ovs-vsctl.c
xenserver/etc_init.d_openvswitch
xenserver/etc_xapi.d_plugins_openvswitch-cfg-update
xenserver/etc_xensource_scripts_vif
xenserver/usr_lib_xsconsole_plugins-base_XSFeatureVSwitch.py
xenserver/usr_sbin_brctl
xenserver/usr_share_openvswitch_scripts_monitor-external-ids

index d860630378d10fc1c2758553996f9efac58e445f..34b5604dc7bf0a154b364a8090e526ffe76cfef1 100755 (executable)
@@ -257,7 +257,7 @@ case "$1" in
             echo " ERROR."
         fi
 
-        ovs-vsctl --no-wait init
+        ovs-vsctl --no-wait --timeout=5 init
 
         # Start ovs-vswitchd.
         set --
index 7476777a813131a64eca9ce89a2f0d6991102f1b..ef080bb419e7fbe486cb68f892cd957392e75e78 100644 (file)
@@ -118,11 +118,12 @@ Prevents \fBovs\-vsctl\fR from actually modifying the database.
 .
 .IP "\fB\-t \fIsecs\fR"
 .IQ "\fB\-\-timeout=\fIsecs\fR"
-Limits runtime to approximately \fIsecs\fR seconds.  A value of 
-zero will cause \fBovs\-vsctl\fR to wait forever.  If the timeout expires, 
-\fBovs\-vsctl\fR will exit with a \fBSIGALRM\fR signal.  If this option is
-not used, \fBovs\-vsctl\fR uses a timeout of five seconds.
-(A timeout would normally happen only if the database cannot be contacted.)
+By default, or with a \fIsecs\fR of \fB0\fR, \fBovs\-vsctl\fR waits
+forever for a response from the database.  This option limits runtime
+to approximately \fIsecs\fR seconds.  If the timeout expires,
+\fBovs\-vsctl\fR will exit with a \fBSIGALRM\fR signal.  (A timeout
+would normally happen only if the database cannot be contacted, or if
+the system is overloaded.)
 .
 .SS "Public Key Infrastructure Options"
 .so lib/ssl.man
index 4d50194aaa33a4fb8eef0d40e05cb968269aee27..043530280365450075297a4dfe4db735560ab382 100644 (file)
@@ -85,7 +85,7 @@ static bool dry_run;
 static bool wait_for_reload = true;
 
 /* --timeout: Time to wait for a connection to 'db'. */
-static int timeout = 5;
+static int timeout;
 
 /* All supported commands. */
 static const struct vsctl_command_syntax all_commands[];
index 050844570b878019b5b7c4040495b14563ec97ee..68079fcf524d1f20409d8d058002a0c36247882d 100755 (executable)
@@ -293,7 +293,7 @@ EOF
 function set_system_ids {
     if [ -f /etc/xensource-inventory ]; then
         action "Configuring Open vSwitch system IDs" true
-        $vsctl --no-wait set Open_vSwitch . \
+        $vsctl --no-wait --timeout=5 set Open_vSwitch . \
             external-ids:system-type="$PRODUCT_BRAND" \
             external-ids:system-version="$PRODUCT_VERSION-$BUILD_NUMBER" \
             external-ids:system-id="$INSTALLATION_UUID" \
@@ -329,11 +329,11 @@ function start {
     fi
 
     start_ovsdb_server
-    $vsctl --no-wait init
+    $vsctl --no-wait --timeout=5 init
     if [ ! -e /var/run/openvswitch.booted ]; then
         touch /var/run/openvswitch.booted
         for bridge in $($vsctl list-br); do
-            $vsctl --no-wait del-br $bridge
+            $vsctl --no-wait --timeout=5 del-br $bridge
         done
     fi
 
index 6da86d5cda7ebf98a4b3f7f1f0844db1118520ba..7333018687347a620e81573953e0cab979e108c7 100755 (executable)
@@ -111,7 +111,7 @@ def setControllerCfg(controller):
                    'managers="ssl:' + controller + ':6632"'])
 
 def vswitchCfgQuery(action_args):
-    cmd = [vsctl, "-vANY:console:emer"] + action_args
+    cmd = [vsctl, "--timeout=5", "-vANY:console:emer"] + action_args
     output = subprocess.Popen(cmd, stdout=subprocess.PIPE).communicate()
     if len(output) == 0 or output[0] == None:
         output = ""
@@ -120,14 +120,14 @@ def vswitchCfgQuery(action_args):
     return output
 
 def vswitchCfgMod(action_args):
-    cmd = [vsctl, "-vANY:console:emer"] + action_args
+    cmd = [vsctl, "--timeout=5", "-vANY:console:emer"] + action_args
     exitcode = subprocess.call(cmd)
     if exitcode != 0:
         raise XenAPIPlugin.Failure("VSWITCH_CONFIG_MOD_FAILURE",
                                    [ str(exitcode) , str(action_args) ])
 
 def emergency_reset(session, args):
-    cmd = [vsctl, "emer-reset"]
+    cmd = [vsctl, "--timeout=5", "emer-reset"]
     exitcode = subprocess.call(cmd)
     if exitcode != 0:
         raise XenAPIPlugin.Failure("VSWITCH_EMER_RESET_FAILURE",
index f27ff5b407c0154ecf84f177c9b2f9b269dcf4bb..88006e2c4901104c5874e21d435590e062b33f25 100755 (executable)
@@ -165,7 +165,7 @@ add_to_bridge()
             local vif_details=$(handle_vswitch_vif_details $bridge)
         fi
 
-        $vsctl -- --if-exists del-port $dev -- add-port $bridge $dev $vif_details
+        $vsctl --timeout=30 -- --if-exists del-port $dev -- add-port $bridge $dev $vif_details
         ;;
     esac
         
@@ -182,7 +182,7 @@ remove_from_bridge()
         # If ovs-brcompatd is running, it might already have deleted the
         # port.  Use --if-exists to suppress the error that would otherwise
         # arise in that case.
-        $vsctl -- --if-exists del-port $dev
+        $vsctl --timeout=30 -- --if-exists del-port $dev
         ;;
     esac
 }
index 6ee4138b2838d8e9ed22f1a9a59803f36bdd363e..d2f6a6a3c7afa6760df33698a5cfa4ed847e3ef7 100644 (file)
@@ -79,7 +79,7 @@ class VSwitchConfig:
     @staticmethod
     def Get(action):
         try:
-            arg = [vsctl, "-vANY:console:emer"] + action.split()
+            arg = [vsctl, "--timeout=30", "-vANY:console:emer"] + action.split()
             output = ShellPipe(arg).Stdout()
         except StandardError, e:
             XSLogError("config retrieval error: " + str(e))
index 7fecc56480390c14219d9aaba28ee4db94a249b7..5cf0b88ac7f6b61c8c4b4dc53f2c3c28e16a7cef 100755 (executable)
@@ -35,7 +35,7 @@ def delegate():
 
 def call_vsctl(cmd, arg=""):
     database = '--db=' + OVSDB_SERVER
-    command = [VSCTL, database, cmd]
+    command = [VSCTL, '--timeout=30', database, cmd]
     if (arg):
         command.append(arg)
     return subprocess.Popen(command, stdout=subprocess.PIPE).communicate()[0].split()
index f91801d22ebf534221796215d28b7b0c097bdbc7..a28ce6090b5362ee8d546f05d1245b05db3fc517 100755 (executable)
@@ -98,7 +98,7 @@ def get_iface_id(if_name, default=None):
 
 def set_external_id(table, record, key, value):
     col = 'external-ids:"' + key + '"="' + value + '"'
-    cmd = [vsctl, "-vANY:console:emer", "set", table, record, col]
+    cmd = [vsctl, "--timeout=30", "-vANY:console:emer", "set", table, record, col]
     exitcode = subprocess.call(cmd)
     if exitcode != 0:
         syslog.syslog(syslog.LOG_WARNING,