From patchwork Wed Apr 10 01:21:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 1083054 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=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="kJX9WvVJ"; dkim-atps=neutral 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 44f5yK14Bsz9sSR for ; Wed, 10 Apr 2019 11:23:20 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 0B2A3117C; Wed, 10 Apr 2019 01:22:04 +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 8C9081152 for ; Wed, 10 Apr 2019 01:21:42 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 7013C174 for ; Wed, 10 Apr 2019 01:21:41 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id w23so317725ply.4 for ; Tue, 09 Apr 2019 18:21:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3P/EPLQGysGr7T+GsJD5L6ZQup+48EUGje2hdWU3FhY=; b=kJX9WvVJg0WvsRrBooLESKH31AaEp3fozRZDePnUSAuYXZvaF8JpbKTwzwEvUghxUK JuHTBz/h+h3qH8Y/tODvzoHRvdP6Znebiqbj4tFeE2VLbRkoT9tillip59/JpcIpEK3q sDB9ZUdqJxV/FPpLbjCb6JH6fNL+N7eVItKce7E1HbeUOJlweqh64I6gqxWiAiyXShnv VwBgn595LF2dvtUgr6oAshki8WFcMvhLgqpMYrzmCaRmN1bsJzXHdB43/CW0TidV9ofa k1YZW1AYkBnzTYmfcr0oMU5J2sjEIbwjdjYwIxXQu0UIwo+7G5riZJ75MCGPELZIe7Bo DEYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3P/EPLQGysGr7T+GsJD5L6ZQup+48EUGje2hdWU3FhY=; b=ZVfggC2Tci8ysWMmCxH0IpV8VcFpFHfNv/VG9lghAOdPUoUxgSt+yXRyrUA3tORbpn 98Okd3O/3xToTzHzIhQQJYeWOZsv+Q4KrZ0zIoNONqt70DBZ26wQvNbBm0s2OlpUEESW cTn51OhCUaanKeuF9OC3JcQe5GjFtrv0UKWpL2Rsn8EZ8HlTFVBl4b8dm/idMM6Vhe/e mHWe0C390k8kdd/YgXQTeLJr8op0lzdO0jHZYqhPH+6HJlja6HX3IxF36doinjvJRS3f kEkzDAzdUb3J0Fc0In31hcmx1tFS39fUlVJk7fMfKsILRtjLfDcHFK49RixvxfPI4fLo 8xUQ== X-Gm-Message-State: APjAAAVcYivxlRORyM1TWCgF0LyeW1BMi5SFZFetVWCuu0gQIDlGxkVb tYDfLdZcDcMI6uuJsbexc0QIe6Th X-Google-Smtp-Source: APXvYqx9YR3ktbHdZ5tsAulV3vTUWo5rHmBV83L8q9eJUnmJusUIB2f264qV2fTItO1gBepvH5pRrg== X-Received: by 2002:a17:902:2c01:: with SMTP id m1mr30867094plb.186.1554859300735; Tue, 09 Apr 2019 18:21:40 -0700 (PDT) Received: from localhost.localdomain.localdomain ([216.113.160.71]) by smtp.gmail.com with ESMTPSA id u63sm17068802pgd.16.2019.04.09.18.21.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Apr 2019 18:21:40 -0700 (PDT) From: Han Zhou X-Google-Original-From: Han Zhou To: dev@openvswitch.org Date: Tue, 9 Apr 2019 18:21:19 -0700 Message-Id: <1554859282-15144-4-git-send-email-hzhou8@ebay.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1554859282-15144-1-git-send-email-hzhou8@ebay.com> References: <1554859282-15144-1-git-send-email-hzhou8@ebay.com> X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE 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 4/7] ovn-nbctl: Support --no-shuffle-remotes. 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: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org From: Han Zhou Support --no-shuffle-remotes option for ovn-nbctl, which is mainly for testing purpose, so that we can specify the order that client will failover when the connected node is down, to have more predictability in the test cases. Signed-off-by: Han Zhou --- ovn/utilities/ovn-nbctl.8.xml | 17 +++++++++++++++++ ovn/utilities/ovn-nbctl.c | 26 ++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/ovn/utilities/ovn-nbctl.8.xml b/ovn/utilities/ovn-nbctl.8.xml index a7a9c27..55c92f7 100644 --- a/ovn/utilities/ovn-nbctl.8.xml +++ b/ovn/utilities/ovn-nbctl.8.xml @@ -1142,6 +1142,23 @@ Understanding Cluster Consistency in ovsdb(7) for more information. + +
--shuffle-remotes
+
--no-shuffle-remotes
+
+ By default, or with --shuffle-remotes, when there are + multiple remotes specified in the OVSDB connection string specified by + --db or the OVN_NB_DB environment variable, + the order of the remotes will be shuffled before the client tries to + connect. The remotes will be shuffled only once to a new order before + the first connection attempt. The following retries, if any, will + follow the same new order. The default behavior is to make sure + clients of a clustered database can distribute evenly to all memembers + of the cluster. With --no-shuffle-remotes, + ovn-nbctl will use the original order specified in the + connection string to connect. This allows user to specify the + preferred order, which is particularly useful for testing. +

Daemon Options

diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c index 2727b41..e185b9d 100644 --- a/ovn/utilities/ovn-nbctl.c +++ b/ovn/utilities/ovn-nbctl.c @@ -83,6 +83,10 @@ OVS_NO_RETURN static void nbctl_exit(int status); /* --leader-only, --no-leader-only: Only accept the leader in a cluster. */ static int leader_only = true; +/* --shuffle-remotes, --no-shuffle-remotes: Shuffle the order of remotes that + * are specified in the connetion method string. */ +static int shuffle_remotes = true; + /* --unixctl-path: Path to use for unixctl server, for "monitor" and "snoop" commands. */ static char *unixctl_path; @@ -182,8 +186,11 @@ main(int argc, char *argv[]) } daemon_mode = true; } - /* Initialize IDL. "retry" is true iff in daemon mode. */ - idl = the_idl = ovsdb_idl_create(db, &nbrec_idl_class, true, daemon_mode); + /* Initialize IDL. */ + idl = the_idl = ovsdb_idl_create_unconnected(&nbrec_idl_class, true); + ovsdb_idl_set_shuffle_remotes(idl, shuffle_remotes); + /* "retry" is true iff in daemon mode. */ + ovsdb_idl_set_remote(idl, db, daemon_mode); ovsdb_idl_set_leader_only(idl, leader_only); if (daemon_mode) { @@ -304,6 +311,8 @@ enum { OPT_OPTIONS, OPT_LEADER_ONLY, OPT_NO_LEADER_ONLY, + OPT_SHUFFLE_REMOTES, + OPT_NO_SHUFFLE_REMOTES, OPT_BOOTSTRAP_CA_CERT, MAIN_LOOP_OPTION_ENUMS, DAEMON_OPTION_ENUMS, @@ -405,6 +414,8 @@ get_all_options(void) {"options", no_argument, NULL, OPT_OPTIONS}, {"leader-only", no_argument, NULL, OPT_LEADER_ONLY}, {"no-leader-only", no_argument, NULL, OPT_NO_LEADER_ONLY}, + {"shuffle-remotes", no_argument, NULL, OPT_SHUFFLE_REMOTES}, + {"no-shuffle-remotes", no_argument, NULL, OPT_NO_SHUFFLE_REMOTES}, {"version", no_argument, NULL, 'V'}, MAIN_LOOP_LONG_OPTIONS, DAEMON_LONG_OPTIONS, @@ -509,6 +520,14 @@ apply_options_direct(const struct ovs_cmdl_parsed_option *parsed_options, leader_only = false; break; + case OPT_SHUFFLE_REMOTES: + shuffle_remotes = true; + break; + + case OPT_NO_SHUFFLE_REMOTES: + shuffle_remotes = false; + break; + case 'V': ovs_print_version(0, 0); printf("DB Schema %s\n", nbrec_get_db_version()); @@ -705,6 +724,7 @@ Options:\n\ (default: %s)\n\ --no-wait, --wait=none do not wait for OVN reconfiguration (default)\n\ --no-leader-only accept any cluster member, not just the leader\n\ + --no-shuffle-remotes do not shuffle the order of remotes\n\ --wait=sb wait for southbound database update\n\ --wait=hv wait for all chassis to catch up\n\ -t, --timeout=SECS wait at most SECS seconds\n\ @@ -5532,6 +5552,8 @@ nbctl_client(const char *socket_name, case OPT_LEADER_ONLY: case OPT_NO_LEADER_ONLY: + case OPT_SHUFFLE_REMOTES: + case OPT_NO_SHUFFLE_REMOTES: case OPT_BOOTSTRAP_CA_CERT: STREAM_SSL_CASES DAEMON_OPTION_CASES