From patchwork Wed Dec 20 14:31:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammad Heib X-Patchwork-Id: 1878556 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=OBfuhVot; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [IPv6:2605:bc80:3010::138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SwGJG440jz20Gb for ; Thu, 21 Dec 2023 01:33:18 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 462CF835D9; Wed, 20 Dec 2023 14:33:16 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 462CF835D9 Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=OBfuhVot X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HjaAf6HK4vbJ; Wed, 20 Dec 2023 14:33:15 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 1E4B2834F1; Wed, 20 Dec 2023 14:33:14 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 1E4B2834F1 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id BBCA2C0077; Wed, 20 Dec 2023 14:33:13 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id B0C87C0037 for ; Wed, 20 Dec 2023 14:33:12 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 7EBC5414CC for ; Wed, 20 Dec 2023 14:33:12 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 7EBC5414CC Authentication-Results: smtp4.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=OBfuhVot X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id w_qGwaqF7phb for ; Wed, 20 Dec 2023 14:33:11 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp4.osuosl.org (Postfix) with ESMTPS id 7B4B540907 for ; Wed, 20 Dec 2023 14:33:11 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 7B4B540907 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1703082790; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AzM2hZMQBmDf3TgexyBOf7oM+tF1EEIrvCfpBJtU8x8=; b=OBfuhVotxBtgYdpSAPW0OgcsGElhtExztdf8u/eQ2eaAkMAUXXMTsfMbglfUiGfQGuANNh utqUO0qpxQQDwDcib5tg6kpBF634QPNcgkL4MtLp1HgnEtTwF3v1rAFrerzBlbHUbEgJvY 7N1+LHF12R1e7PfisN3NxP+JxFjlsbQ= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-169-zWDlLy19MryoON7iu-mZlw-1; Wed, 20 Dec 2023 09:31:12 -0500 X-MC-Unique: zWDlLy19MryoON7iu-mZlw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D7C423C32641 for ; Wed, 20 Dec 2023 14:31:11 +0000 (UTC) Received: from mheiblap.localdomain (unknown [10.47.238.119]) by smtp.corp.redhat.com (Postfix) with ESMTP id 38245492BE6; Wed, 20 Dec 2023 14:31:11 +0000 (UTC) From: Mohammad Heib To: dev@openvswitch.org Date: Wed, 20 Dec 2023 16:31:04 +0200 Message-Id: <20231220143105.916908-3-mheib@redhat.com> In-Reply-To: <20231220143105.916908-2-mheib@redhat.com> References: <20231220143105.916908-1-mheib@redhat.com> <20231220143105.916908-2-mheib@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn 3/4] IC: Make it possible for CMS to detect when the ISB is up-to-date. X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" Until now, there has been no reliable for the CMS to detect when changes made to the INB configuration have been passed through to the ISB, This commit adds this feature to the system, by adding sequence numbers to the INB and ISB and adding code in ovn-ic-nbctl, ovn-ic to keep those sequence numbers up-to-date. The biggest user-visible change from this commit is a new option '--wait' and new command 'sync' to ovn-ic-nbctl. With --wait=sb, ovn-ic-nbctl now waits for ovn-ics to update the ISB database. Signed-off-by: Mohammad Heib --- utilities/ovn-ic-nbctl.8.xml | 46 ++++++++++++++++++++++ utilities/ovn-ic-nbctl.c | 76 +++++++++++++++++++++++++++++++++++- 2 files changed, 120 insertions(+), 2 deletions(-) diff --git a/utilities/ovn-ic-nbctl.8.xml b/utilities/ovn-ic-nbctl.8.xml index 4a70994b8..ccfacfaff 100644 --- a/utilities/ovn-ic-nbctl.8.xml +++ b/utilities/ovn-ic-nbctl.8.xml @@ -123,9 +123,55 @@ +

Synchronization Commands

+ +
+
sync
+
+ Ordinarily, --wait=sb only waits for changes by the current + ovn-ic-nbctl invocation to take effect. + This means that, if none of the commands supplied to + ovn-ic-nbctl change the database, then the command does not + wait at all. With the sync command, however, + ovn-ic-nbctl waits even for earlier changes to the database + to propagate down to the southbound database, according to the argument of --wait. +
+
+

Options

+
--no-wait | --wait=none
+
--wait=sb
+ +
+

+ These options control whether and how ovn-ic-nbctl waits + for the OVN system to become up-to-date with changes made in an + ovn-ic-nbctl invocation. +

+ +

+ By default, or if --no-wait or --wait=none, + ovn-ic-nbctl exits immediately after confirming that + changes have been committed to the Interconnect northbound database, + without waiting. +

+ +

+ With --wait=sb, before ovn-ic-nbctl exits, it + waits for ovn-ics to bring the Interconnect southbound database + up-to-date with the Interconnect northbound database updates. +

+ +

+ Ordinarily, --wait=sb only waits for changes by the current + ovn-ic-nbctl invocation to take effect. + This means that, if none of the commands supplied to ovn-ic-nbctl + change the database, then the command does not wait at all. + Use the sync command to override this behavior. +

+
--db database
The OVSDB database remote to contact. If the OVN_IC_NB_DB diff --git a/utilities/ovn-ic-nbctl.c b/utilities/ovn-ic-nbctl.c index 721dc4586..2061b0c67 100644 --- a/utilities/ovn-ic-nbctl.c +++ b/utilities/ovn-ic-nbctl.c @@ -58,6 +58,13 @@ static bool oneline; /* --dry-run: Do not commit any changes. */ static bool dry_run; +/* --wait=TYPE: Wait for configuration change to take effect? */ +static enum nbctl_wait_type wait_type = NBCTL_WAIT_NONE; + +/* Should we wait (if specified by 'wait_type') even if the commands don't + * change the database at all */ +static bool force_wait = false; + /* --timeout: Time to wait for a connection to 'db'. */ static unsigned int timeout; @@ -161,6 +168,8 @@ parse_options(int argc, char *argv[], struct shash *local_options) OPT_DB = UCHAR_MAX + 1, OPT_ONELINE, OPT_NO_SYSLOG, + OPT_NO_WAIT, + OPT_WAIT, OPT_DRY_RUN, OPT_LOCAL, OPT_COMMANDS, @@ -173,6 +182,8 @@ parse_options(int argc, char *argv[], struct shash *local_options) static const struct option global_long_options[] = { {"db", required_argument, NULL, OPT_DB}, {"no-syslog", no_argument, NULL, OPT_NO_SYSLOG}, + {"no-wait", no_argument, NULL, OPT_NO_WAIT}, + {"wait", required_argument, NULL, OPT_WAIT}, {"dry-run", no_argument, NULL, OPT_DRY_RUN}, {"oneline", no_argument, NULL, OPT_ONELINE}, {"timeout", required_argument, NULL, 't'}, @@ -234,7 +245,19 @@ parse_options(int argc, char *argv[], struct shash *local_options) case OPT_DRY_RUN: dry_run = true; break; - + case OPT_NO_WAIT: + wait_type = NBCTL_WAIT_NONE; + break; + case OPT_WAIT: + if (!strcmp(optarg, "none")) { + wait_type = NBCTL_WAIT_NONE; + } else if (!strcmp(optarg, "sb")) { + wait_type = NBCTL_WAIT_SB; + } else { + ctl_fatal("argument to --wait must be " + "\"none\", \"sb\" "); + } + break; case OPT_LOCAL: if (shash_find(local_options, options[idx].name)) { ctl_fatal("'%s' option specified multiple times", @@ -329,9 +352,14 @@ set the SSL configuration\n\ %s\ %s\ \n\ +Synchronization command (use with --wait=sb):\n\ + sync wait even for earlier changes to take effect\n\ +\n\ Options:\n\ --db=DATABASE connect to DATABASE\n\ (default: %s)\n\ + --no-wait, --wait=none do not wait for OVN reconfiguration (default)\n\ + --wait=sb wait for southbound database update\n\ --no-leader-only accept any cluster member, not just the leader\n\ -t, --timeout=SECS wait at most SECS seconds\n\ --dry-run do not commit changes to database\n\ @@ -380,6 +408,12 @@ ic_nbctl_init(struct ctl_context *ctx OVS_UNUSED) { } +static void +ic_nbctl_pre_sync(struct ctl_context *base OVS_UNUSED) +{ + force_wait = true; +} + static void ic_nbctl_ts_add(struct ctl_context *ctx) { @@ -748,6 +782,7 @@ do_ic_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, struct ic_nbctl_context ic_nbctl_ctx; struct ctl_command *c; struct shash_node *node; + int64_t next_cfg = 0; txn = the_idl_txn = ovsdb_idl_txn_create(idl); if (dry_run) { @@ -762,6 +797,16 @@ do_ic_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, icnbrec_ic_nb_global_insert(txn); } + if (wait_type != NBCTL_WAIT_NONE) { + + /* Deal with potential overflows. */ + if (inb->nb_ic_cfg == LLONG_MAX) { + icnbrec_ic_nb_global_set_nb_ic_cfg(inb, 0); + } + ovsdb_idl_txn_increment(txn, &inb->header_, + &icnbrec_ic_nb_global_col_nb_ic_cfg, force_wait); + } + symtab = ovsdb_symbol_table_create(); for (c = commands; c < &commands[n_commands]; c++) { ds_init(&c->output); @@ -807,6 +852,9 @@ do_ic_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, } status = ovsdb_idl_txn_commit_block(txn); + if (wait_type != NBCTL_WAIT_NONE && status == TXN_SUCCESS) { + next_cfg = ovsdb_idl_txn_get_increment_new_value(txn); + } if (status == TXN_UNCHANGED || status == TXN_SUCCESS) { for (c = commands; c < &commands[n_commands]; c++) { if (c->syntax->postprocess) { @@ -884,6 +932,30 @@ do_ic_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, shash_destroy_free_data(&c->options); } free(commands); + + if (wait_type == NBCTL_WAIT_NONE) { + if (force_wait) { + VLOG_INFO("\"sync\" command has no effect without --wait"); + } + goto done; + } + + if (wait_type != NBCTL_WAIT_NONE && status != TXN_UNCHANGED) { + ovsdb_idl_enable_reconnect(idl); + for (;;) { + ovsdb_idl_run(idl); + ICNBREC_IC_NB_GLOBAL_FOR_EACH (inb, idl) { + int64_t cur_cfg = inb->sb_ic_cfg; + if (cur_cfg >= next_cfg) { + goto done; + } + } + ovsdb_idl_wait(idl); + poll_block(); + } + done: ; + } + ovsdb_idl_txn_destroy(txn); ovsdb_idl_destroy(idl); @@ -924,7 +996,7 @@ ic_nbctl_exit(int status) static const struct ctl_command_syntax ic_nbctl_commands[] = { { "init", 0, 0, "", NULL, ic_nbctl_init, NULL, "", RW }, - + { "sync", 0, 0, "", ic_nbctl_pre_sync, NULL, NULL, "", RO }, /* transit switch commands. */ { "ts-add", 1, 1, "SWITCH", NULL, ic_nbctl_ts_add, NULL, "--may-exist", RW }, { "ts-del", 1, 1, "SWITCH", NULL, ic_nbctl_ts_del, NULL, "--if-exists", RW },