From patchwork Fri Jul 12 14:17:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Alvarez Sanchez X-Patchwork-Id: 1131407 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45lZtS0381z9sDB for ; Sat, 13 Jul 2019 00:24:14 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 0344E5966; Fri, 12 Jul 2019 14:24:00 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id C0EFA590A for ; Fri, 12 Jul 2019 14:17:18 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 1DC7688E for ; Fri, 12 Jul 2019 14:17:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7722283F44 for ; Fri, 12 Jul 2019 14:17:17 +0000 (UTC) Received: from MacBook-Pro-de-Daniel.telefonica.net (unknown [10.36.118.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id ABBA75DC19; Fri, 12 Jul 2019 14:17:16 +0000 (UTC) From: Daniel Alvarez To: dev@openvswitch.org Date: Fri, 12 Jul 2019 16:17:15 +0200 Message-Id: <20190712141715.19877-1-dalvarez@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 12 Jul 2019 14:17:17 +0000 (UTC) X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH branch2.11] ovsdb-server: drop all connections on read/write status change X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 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. Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2019-July/048981.html Signed-off-by: Daniel Alvarez Signed-off-by: Ben Pfaff --- ovsdb/jsonrpc-server.c | 2 +- tests/ovn.at | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) -- 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, xstrdup(read_only ? "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 AT_CLEANUP + +# 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]) +ovn_start +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:192.0.2.2:6641 +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"} +]) + +AT_CLEANUP