[ovs-dev] [PATCH] Dynamically reconnect ovn-controller if ovn-remote value changes

Ryan Moats rmoats at us.ibm.com
Mon Mar 14 20:35:55 UTC 2016


From: RYAN D. MOATS <rmoats at us.ibm.com>

Allows for auto detection and reconnect if the ovn-remote needs
to change.  ovn-controller test case updated to include testing
this code

Signed-off-by: RYAN D. MOATS <rmoats at us.ibm.com>
---
 ovn/controller/ovn-controller.c |   12 ++++++++++++
 tests/ovn-controller.at         |   16 ++++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c
index 5852e35..2d94342 100644
--- a/ovn/controller/ovn-controller.c
+++ b/ovn/controller/ovn-controller.c
@@ -342,6 +342,18 @@ main(int argc, char *argv[])
         if (should_service_stop()) {
             exiting = true;
         }
+        /* Check OVN SB database. */
+        char *new_ovnsb_remote = get_ovnsb_remote(ovs_idl_loop.idl);
+        if (strcmp(ovnsb_remote, new_ovnsb_remote)) {
+            free (ovnsb_remote);
+            ovnsb_remote = new_ovnsb_remote;
+            ovsdb_idl_restroy(ovnsb_idl_loop.idl);
+            ovnsb_idl_loop = OVSDB_IDL_LOOP_INITIALIZER(
+                ovsdb_idl_create(ovnsb_remote, &sbrec_idl_class, true, true));
+            ovsdb_idl_get_initial_snapshot(ovnsb_idl_loop.idl);
+        } else {
+            free (new_ovnsb_remote);
+        }
     }
 
     /* It's time to exit.  Clean up the databases. */
diff --git a/tests/ovn-controller.at b/tests/ovn-controller.at
index 2ff56af..bb1fe7e 100644
--- a/tests/ovn-controller.at
+++ b/tests/ovn-controller.at
@@ -107,6 +107,21 @@ check_patches \
     'br-int patch-quux-to-baz patch-baz-to-quux' \
     'br-int patch-baz-to-quux patch-quux-to-baz'
 
+# Create an empty database, serve it and switch to it
+# and verify that the OVS patch ports disappear
+# then put it back and verify that they reappear
+ovsdb-tool create $ovs_base/ovn-sb/ovn-sb1.db "$abs_top_srcdir"/ovn/ovn-sb.ovsschema
+as ovn-sb ovsdb-server --detach --pidfile=$ovs_base/ovn-sb/ovsdb-server-2.pid --remote=punix:$ovs_base/ovn-sb/ovn-sb1.sock $ovs_base/ovn-sb/ovn-sb1.db
+ovs-vsctl -- set Open_vSwitch . external-ids:ovn-remote=unix:$ovs_base/ovn-sb/ovn-sb1.sock
+sleep 1
+check_patches
+ovs-vsctl -- set Open_vSwitch . external-ids:ovn-remote=unix:$ovs_base/ovn-sb/ovn-sb.sock
+sleep 1
+check_patches \
+    'br-int patch-quux-to-baz patch-baz-to-quux' \
+    'br-int patch-baz-to-quux patch-quux-to-baz'
+
+
 # Change the logical patch ports to VIFs and verify that the OVS patch
 # ports disappear.
 AT_CHECK([ovn-sbctl \
@@ -115,5 +130,6 @@ AT_CHECK([ovn-sbctl \
 check_patches
 
 # Gracefully terminate ovn-controller
+kill `cat $ovs_base/ovn-sb/ovsdb-server-2.pid`
 ovs-appctl -t ovn-controller exit
 AT_CLEANUP
-- 
1.7.1




More information about the dev mailing list