[ovs-dev] [PATCH v3] ovs-ctl: add option to delete transient ports

Thadeu Lima de Souza Cascardo cascardo at redhat.com
Tue Sep 1 20:56:09 UTC 2015


When using virtualization, new ports are created and removed all the time. These
ports do not persist after a system reboot, for example. They may be created
again by the virtualization manager, but that will happen after the vswitch is
already running, and the virtualization manager will add them again to the
bridge.

If a reboot happens without properly deleting such ports, all kinds of errors
will happen. The absence of the ports will be logged as errors, and adding those
ports again to the database will fail.

Deleting all bridges may not be an option, if the system cannot persist other
information outside of OVSDB.

This patch introduces the notion of transient ports. Ports may be added as
transient, as a boolean in other_config smap. When openvswitch is started by
using --delete-transient-ports ovs-ctl option, all transient ports will be
removed.

Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo at redhat.com>
---
 utilities/ovs-ctl.8  | 11 ++++++++++-
 utilities/ovs-ctl.in | 10 ++++++++++
 vswitchd/vswitch.xml |  8 ++++++++
 3 files changed, 28 insertions(+), 1 deletion(-)

diff --git a/utilities/ovs-ctl.8 b/utilities/ovs-ctl.8
index c08c7db..9728d0d 100644
--- a/utilities/ovs-ctl.8
+++ b/utilities/ovs-ctl.8
@@ -90,10 +90,14 @@ Initializes a few values inside the database.
 If the \fB\-\-delete\-bridges\fR option was used, deletes all of the
 bridges from the database.
 .
+.IP 6.
+If the \fB\-\-delete\-transient\-ports\fR option was used, deletes all ports
+that have other_config:transient set to true.
+.
 .PP
 The \fBstart\fR command skips the following step if
 \fBovs\-vswitchd\fR is already running:
-.IP 6.
+.IP 7.
 Starts \fBovs\-vswitchd\fR.
 .
 .SS "Options"
@@ -148,6 +152,11 @@ on every boot.  This option supports that, by deleting all Open
 vSwitch bridges after starting \fBovsdb\-server\fR but before starting
 \fBovs\-vswitchd\fR.
 .
+.IP "\fB\-\-delete\-transient\-ports\fR"
+Deletes all ports that have the other_config:transient value set to true. This
+is important on certain environments where some ports are going to be recreated
+after reboot, but other ports need to be persisted in the database.
+.
 .PP
 The following options are less important:
 .
diff --git a/utilities/ovs-ctl.in b/utilities/ovs-ctl.in
index 9bbbe0d..bca8c56 100755
--- a/utilities/ovs-ctl.in
+++ b/utilities/ovs-ctl.in
@@ -177,6 +177,12 @@ check_force_cores () {
     fi
 }
 
+del_transient_ports () {
+    for port in `ovs-vsctl --bare -- --columns=name find port other_config:transient=true`; do
+        ovs_vsctl -- del-port "$port"
+    done
+}
+
 start_ovsdb () {
     check_force_cores
 
@@ -219,6 +225,9 @@ start_ovsdb () {
                 ovs_vsctl del-br $bridge
             done
         fi
+        if test X"$DELETE_TRANSIENT_PORTS" = Xyes; then
+            del_transient_ports
+        fi
     fi
 }
 
@@ -536,6 +545,7 @@ set_defaults () {
     SYSTEM_ID=
 
     DELETE_BRIDGES=no
+    DELETE_TRANSIENT_PORTS=no
 
     DAEMON_CWD=/
     FORCE_COREFILES=yes
diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index 457f34a..0ab4a9a 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -1659,6 +1659,14 @@
         <code>fake-bridge-</code>,
         e.g. <code>fake-bridge-xs-network-uuids</code>.
       </column>
+
+      <column name="other_config" key="transient"
+              type='{"type": "boolean"}'>
+        <p>
+          If set to <code>true</code>, the port will be removed when
+          <code>ovs-ctl start --delete-transient-ports</code> is used.
+        </p>
+      </column>
     </group>
 
     <column name="bond_active_slave">
-- 
2.4.3




More information about the dev mailing list