diff mbox series

[ovs-dev,v2,branch-2.11] ovsdb-server: drop all connections on read/write status change

Message ID 20190805154355.68724-1-dalvarez@redhat.com
State New
Headers show
Series [ovs-dev,v2,branch-2.11] ovsdb-server: drop all connections on read/write status change | expand

Commit Message

Daniel Alvarez Sanchez Aug. 5, 2019, 3:43 p.m. UTC
Prior to this patch, only db change aware connections were dropped
on a read/write status change. However, current schema in OVN does
not allow clients to monitor whether a particular DB changes this
status. In order to accomplish this, we'd need to change the schema
and adapting ovsdb-server and existing clients.

Before tackling that, this patch is changing ovsdb-server to drop
*all* the existing connections upon a read/write status change. This
will force clients to reconnect and honor the change.

Signed-off-by: Daniel Alvarez <dalvarez@redhat.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
 ovsdb/jsonrpc-server.c |  2 +-
 tests/ovn.at           | 21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

2.21.0 (Apple Git-120)


0-day Robot Aug. 5, 2019, 4:08 p.m. UTC | #1
Bleep bloop.  Greetings Daniel Alvarez, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.

WARNING: Unexpected sign-offs from developers who are not authors or co-authors or committers: Ben Pfaff <blp@ovn.org>
Lines checked: 69, Warnings: 1, Errors: 0

Please check this out.  If you feel there has been an error, please email aconole@bytheb.org

0-day Robot
diff mbox series


diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c
index 7c7a277f0..739e0e72e 100644
--- a/ovsdb/jsonrpc-server.c
+++ b/ovsdb/jsonrpc-server.c
@@ -365,7 +365,7 @@  ovsdb_jsonrpc_server_set_read_only(struct ovsdb_jsonrpc_server *svr,
     if (svr->read_only != read_only) {
         svr->read_only = read_only;
-        ovsdb_jsonrpc_server_reconnect(svr, false,
+        ovsdb_jsonrpc_server_reconnect(svr, true,
                                                ? "making server read-only"
                                                : "making server read/write"));
diff --git a/tests/ovn.at b/tests/ovn.at
index 4b14720f3..291330b3b 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -12090,3 +12090,24 @@  ovn-nbctl list logical_switch_port
 ovn-nbctl list logical_router_port

+# Run ovn-nbctl in daemon mode, change to a backup database and verify that
+# an insert operation is not allowed.
+AT_SETUP([ovn -- can't write to a backup database server instance])
+on_exit 'kill $(cat ovn-nbctl.pid)'
+export OVN_NB_DAEMON=$(ovn-nbctl --pidfile --detach)
+AT_CHECK([ovn-nbctl ls-add sw0])
+as ovn-nb
+AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/sync-status | grep active | wc -l], [0], [1
+ovs-appctl -t ovsdb-server ovsdb-server/set-active-ovsdb-server tcp:
+ovs-appctl -t ovsdb-server ovsdb-server/connect-active-ovsdb-server
+AT_CHECK([ovs-appctl -t ovsdb-server ovsdb-server/sync-status | grep -c backup], [0], [1
+AT_CHECK([ovn-nbctl ls-add sw1], [1], [ignore],
+[ovn-nbctl: transaction error: {"details":"insert operation not allowed when database server is in read only mode","error":"not allowed"}