From patchwork Tue Jan 9 11:12:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammad Heib X-Patchwork-Id: 1884375 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=CT7J3Cgh; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (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 4T8Svj3Y3Nz1yPf for ; Tue, 9 Jan 2024 22:12:49 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 95ED041A65; Tue, 9 Jan 2024 11:12:46 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 95ED041A65 Authentication-Results: smtp2.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=CT7J3Cgh X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id moiz2iRRi6p6; Tue, 9 Jan 2024 11:12:45 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp2.osuosl.org (Postfix) with ESMTPS id E221F41A42; Tue, 9 Jan 2024 11:12:43 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org E221F41A42 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id C56FFC0DD2; Tue, 9 Jan 2024 11:12:42 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 868CFC0037 for ; Tue, 9 Jan 2024 11:12:41 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 4978960BE7 for ; Tue, 9 Jan 2024 11:12:41 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 4978960BE7 Authentication-Results: smtp3.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CT7J3Cgh X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vIgmDbvKyih3 for ; Tue, 9 Jan 2024 11:12:40 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id 70CEF60A9E for ; Tue, 9 Jan 2024 11:12:40 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 70CEF60A9E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704798759; 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=rZlk7At0nM4vftI0TDUrVQmomAhvFhoFdlzcDjqkTEI=; b=CT7J3CghWnAPCMLzs8ZD8boecqJkx9KWh9lmIMtvbb5K467Qf6SlmQ3/sM3p0ijCYp1bB5 ipxYoFkqu5C4yV9OnmgMtozGX75UhK8VJ2Cdb/Y3EPuJy4I03BjFERdJvXDBH+NGRiWcgU q+4ICAYvLU3nimRA9zCLUsRbUsCzYf8= 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-357-wlW6P88NPSOI7gbHN1o3tA-1; Tue, 09 Jan 2024 06:12:38 -0500 X-MC-Unique: wlW6P88NPSOI7gbHN1o3tA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 E4B681C05151 for ; Tue, 9 Jan 2024 11:12:37 +0000 (UTC) Received: from mheiblap.localdomain (unknown [10.47.238.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB2B440C6EB9; Tue, 9 Jan 2024 11:12:36 +0000 (UTC) From: Mohammad Heib To: dev@openvswitch.org Date: Tue, 9 Jan 2024 13:12:29 +0200 Message-Id: <20240109111232.539196-2-mheib@redhat.com> In-Reply-To: <20240109111232.539196-1-mheib@redhat.com> References: <20240109111232.539196-1-mheib@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn v3 1/4] OVN-IC: interconnect DBs add basic Information Flow columns 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" Add basic flow columns to interconnect northbound DB and interconnect Southbound DB. Those columns will be used by future patches to add basic support for Information Flow in OVN interconnect. Signed-off-by: Mohammad Heib Acked-by: Mark Michelson Acked-by: Ales Musil --- NEWS | 8 ++++++++ ovn-ic-nb.ovsschema | 6 ++++-- ovn-ic-nb.xml | 17 +++++++++++++++++ ovn-ic-sb.ovsschema | 8 +++++--- ovn-ic-sb.xml | 21 +++++++++++++++++++++ 5 files changed, 55 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 20df92cb7..23609957c 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,14 @@ Post v23.09.0 - Support CIDR based MAC binding aging threshold. See ovn-nb(5) for 'mac_binding_age_threshold' for more details. - ovn-northd-ddlog has been removed. + - OVN Interconnection: + * INB provides basic feedback to the CMS about the ISB changes + handling status. + * IC_NB_Global now have "nb_ic_cfg" and "sb_ic_cfg" columns for + for ISB informational status. + * IC_SB_Global now have "nb_ic_cfg" column for ISB informational status. + * Availability_Zone now have "nb_ic_cfg" column for local AZ + informational status. OVN v23.09.0 - 15 Sep 2023 -------------------------- diff --git a/ovn-ic-nb.ovsschema b/ovn-ic-nb.ovsschema index 894db8344..bee174357 100644 --- a/ovn-ic-nb.ovsschema +++ b/ovn-ic-nb.ovsschema @@ -1,10 +1,12 @@ { "name": "OVN_IC_Northbound", - "version": "1.0.0", - "cksum": "45589876 3383", + "version": "1.1.0", + "cksum": "3964083684 3501", "tables": { "IC_NB_Global": { "columns": { + "nb_ic_cfg": {"type": {"key": "integer"}}, + "sb_ic_cfg": {"type": {"key": "integer"}}, "external_ids": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}, diff --git a/ovn-ic-nb.xml b/ovn-ic-nb.xml index 8c53bec3b..2ae9bf6d5 100644 --- a/ovn-ic-nb.xml +++ b/ovn-ic-nb.xml @@ -36,6 +36,23 @@ one row.

+ + These columns allow a client to track the overall configuration state of + the system. + + + Sequence number for client to increment. When a client modifies the + interconnect northbound database configuration and wishes to wait for + OVN-ICs to handle this change and update the Interconnect + southbound database, it may increment this sequence number. + + + Sequence number that one OVN-IC sets to the value of + after waiting to all the OVN-ICs + finish applying their changes to interconnect southbound database. + + + See External IDs at the beginning of this document. diff --git a/ovn-ic-sb.ovsschema b/ovn-ic-sb.ovsschema index 1d60b36d1..5baf141cf 100644 --- a/ovn-ic-sb.ovsschema +++ b/ovn-ic-sb.ovsschema @@ -1,10 +1,11 @@ { "name": "OVN_IC_Southbound", - "version": "1.1.1", - "cksum": "3684563024 6914", + "version": "1.2.0", + "cksum": "1381014956 7032", "tables": { "IC_SB_Global": { "columns": { + "nb_ic_cfg": {"type": {"key": "integer"}}, "external_ids": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}, @@ -24,7 +25,8 @@ "isRoot": true}, "Availability_Zone": { "columns": { - "name": {"type": "string"}}, + "name": {"type": "string"}, + "nb_ic_cfg": {"type": {"key": "integer"}}}, "isRoot": true, "indexes": [["name"]]}, "Gateway": { diff --git a/ovn-ic-sb.xml b/ovn-ic-sb.xml index f7e17e113..c3e7d2173 100644 --- a/ovn-ic-sb.xml +++ b/ovn-ic-sb.xml @@ -69,6 +69,21 @@ one row.

+ + This column allow a client to track the overall configuration state of + the system. + + + Sequence number for the configuration. When a CMS or + ovn-ic-nbctl updates the Interconnect northbound database, + it increments the nb_ic_cfg column in the + NB_IC_Global table in the Interconnect northbound + database. when OVN-ICs updates the southbound database to + bring it up to date with these changes, one OVN-IC updates + this column to the same value. + + + See External IDs at the beginning of this document. @@ -102,6 +117,12 @@ A name that uniquely identifies the availability zone. + + + This column is used by the OVN-IC to inform + that this IC instance is aligned with the changes in INB + + From patchwork Tue Jan 9 11:12:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammad Heib X-Patchwork-Id: 1884376 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=bNe8uvuB; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (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 4T8Svm4pd6z1yPf for ; Tue, 9 Jan 2024 22:12:52 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 799E7423DA; Tue, 9 Jan 2024 11:12:48 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 799E7423DA Authentication-Results: smtp4.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=bNe8uvuB 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 eh-vbUMsxtFE; Tue, 9 Jan 2024 11:12:46 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 5FE194218B; Tue, 9 Jan 2024 11:12:45 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 5FE194218B Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7DB6FC0DDA; Tue, 9 Jan 2024 11:12:43 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 39213C0DD2 for ; Tue, 9 Jan 2024 11:12:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 156B660BE7 for ; Tue, 9 Jan 2024 11:12:42 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 156B660BE7 Authentication-Results: smtp3.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bNe8uvuB X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fHPqbX7ebDmI for ; Tue, 9 Jan 2024 11:12:41 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by smtp3.osuosl.org (Postfix) with ESMTPS id 32F1760B20 for ; Tue, 9 Jan 2024 11:12:41 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 32F1760B20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704798760; 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=J/F7wFwWn+Teq7ezw+gcEzM5rea2PFtLt93eSpRfIJ8=; b=bNe8uvuB46Yv4KfyBmwEOCpq8uqA3c0uwjdRaWgCPO/7XjYmRT7XzWCI3iFItjVfd6Aah+ xH7tH1NrIZccOlVrH6cwOMYoTw8dMQ6UjR6jQl60wUMDbL4yvuofFFOiQE/7nJkB2dpgkT 9TzfPZTlWNFh4AmJQycSikJJftf7sUY= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-610-Wb72OsgXNBCtoOw2PwM0TQ-1; Tue, 09 Jan 2024 06:12:39 -0500 X-MC-Unique: Wb72OsgXNBCtoOw2PwM0TQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 E4F31800074 for ; Tue, 9 Jan 2024 11:12:38 +0000 (UTC) Received: from mheiblap.localdomain (unknown [10.47.238.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42DE440C6EB9; Tue, 9 Jan 2024 11:12:38 +0000 (UTC) From: Mohammad Heib To: dev@openvswitch.org Date: Tue, 9 Jan 2024 13:12:30 +0200 Message-Id: <20240109111232.539196-3-mheib@redhat.com> In-Reply-To: <20240109111232.539196-2-mheib@redhat.com> References: <20240109111232.539196-1-mheib@redhat.com> <20240109111232.539196-2-mheib@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn v3 2/4] ovn-ic: implement basic INB change handling status 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" This patch implements a basic sequence number protocol that can be used by CMS to determine if the changes applied to INB are successfully propagated to ISB. The implementation of this patch relies on OVN-ICs instances to update the ISB by adding a per AZ a nb_ic_cfg counter that will be updated by the OVN-IC once it is done and commit all needed changes to the ISB, and according to this AZ:nb_ic_cfg the ISB and INB will be updating about the status of the changes. Signed-off-by: Mohammad Heib --- ic/ovn-ic.c | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 91 insertions(+), 5 deletions(-) diff --git a/ic/ovn-ic.c b/ic/ovn-ic.c index 8ceb34d7c..ba393e910 100644 --- a/ic/ovn-ic.c +++ b/ic/ovn-ic.c @@ -1782,16 +1782,96 @@ route_run(struct ic_context *ctx, hmap_destroy(&ic_lrs); } +/* + * This function implements a sequence number protocol that can be used by + * the INB end user to verify that ISB is synced with all the changes that + * are done be the user/AZs-controllers: + * + * Since we have multiple IC instances running in different regions + * we can't rely on one of them to update the ISB and sync that update + * to INB since other ICs can make changes in parallel. + * So to have a sequence number protocol working properly we must + * make sure that all the IC instances are synced with the ISB first + * and then update the INB. + * + * To guarantee that all instances are synced with ISB first, each IC + * will do the following steps: + * + * 1. when local ovn-ic sees that INB:nb_ic_cfg has updated we will set + * the ic_sb_loop->next_cfg to match the INB:nb_ic_cfg and increment + * the value of AZ:nb_ic_cfg and wait until we get confirmation from + * the server. + * + * 2. once this IC instance changes for ISB are committed successfully + * (next loop), the value of cur_cfg will be updated to match + * the INB:nb_ic_cfg that indicate that our local instance is up to date + * and no more changes need to be done for ISB. + * + * 3. validate that the AZ:nb_ic_cfg to match the INB:nb_ic_cfg. + * + * 4. Go through all the AZs and check if all have the same value of + * AZ:nb_ic_cfg that means all the AZs are done with ISB changes and ISB are + * up to date with INB, so we can set the values of ISB:nb_ic_cfg to + * INB:nb_ic_cfg and INB:sb_ic_cfg to INB:nb_ic_cfg. + */ static void -ovn_db_run(struct ic_context *ctx) +update_sequence_numbers(const struct icsbrec_availability_zone *az, + struct ic_context *ctx, + struct ovsdb_idl_loop *ic_sb_loop) { - const struct icsbrec_availability_zone *az = az_run(ctx); - VLOG_DBG("Availability zone: %s", az ? az->name : "not created yet."); + bool azs_cfg_equals = true; + if (!ctx->ovnisb_txn || !ctx->ovninb_txn) { + return; + } - if (!az) { + const struct icnbrec_ic_nb_global *ic_nb = icnbrec_ic_nb_global_first( + ctx->ovninb_idl); + if (!ic_nb) { + ic_nb = icnbrec_ic_nb_global_insert(ctx->ovninb_txn); + } + const struct icsbrec_ic_sb_global *ic_sb = icsbrec_ic_sb_global_first( + ctx->ovnisb_idl); + if (!ic_sb) { + ic_sb = icsbrec_ic_sb_global_insert(ctx->ovnisb_txn); + } + + if ((ic_nb->nb_ic_cfg != ic_sb->nb_ic_cfg) && + (ic_nb->nb_ic_cfg != az->nb_ic_cfg)) { + /* Deal with potential overflows. */ + if (az->nb_ic_cfg == LLONG_MAX) { + icsbrec_availability_zone_set_nb_ic_cfg(az, 0); + } + ic_sb_loop->next_cfg = ic_nb->nb_ic_cfg; + ovsdb_idl_txn_increment(ctx->ovnisb_txn, &az->header_, + &icsbrec_availability_zone_col_nb_ic_cfg, true); return; } + /* handle cases where accidentally AZ:ic_nb_cfg exceeds + * the INB:ic_nb_cfg. + */ + if (az->nb_ic_cfg != ic_sb_loop->cur_cfg) { + icsbrec_availability_zone_set_nb_ic_cfg(az, ic_sb_loop->cur_cfg); + return; + } + + const struct icsbrec_availability_zone *other_az; + ICSBREC_AVAILABILITY_ZONE_FOR_EACH (other_az, ctx->ovnisb_idl) { + if (other_az->nb_ic_cfg != az->nb_ic_cfg) { + azs_cfg_equals = false; + } + } + + if (azs_cfg_equals && (ic_nb->nb_ic_cfg != ic_sb->nb_ic_cfg)) { + icsbrec_ic_sb_global_set_nb_ic_cfg(ic_sb, az->nb_ic_cfg); + icnbrec_ic_nb_global_set_sb_ic_cfg(ic_nb, az->nb_ic_cfg); + } +} + +static void +ovn_db_run(struct ic_context *ctx, + const struct icsbrec_availability_zone *az) +{ ts_run(ctx); gateway_run(ctx, az); port_binding_run(ctx, az); @@ -2218,7 +2298,13 @@ main(int argc, char *argv[]) ovsdb_idl_has_ever_connected(ctx.ovnsb_idl) && ovsdb_idl_has_ever_connected(ctx.ovninb_idl) && ovsdb_idl_has_ever_connected(ctx.ovnisb_idl)) { - ovn_db_run(&ctx); + const struct icsbrec_availability_zone *az = az_run(&ctx); + VLOG_DBG("Availability zone: %s", az ? az->name : + "not created yet."); + if (az) { + ovn_db_run(&ctx, az); + update_sequence_numbers(az, &ctx, &ovnisb_idl_loop); + } } int rc1 = ovsdb_idl_loop_commit_and_wait(&ovnnb_idl_loop); From patchwork Tue Jan 9 11:12:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammad Heib X-Patchwork-Id: 1884378 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=INmjxGpV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (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 4T8Svq52f0z1yPf for ; Tue, 9 Jan 2024 22:12:55 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id D58E240123; Tue, 9 Jan 2024 11:12:50 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org D58E240123 Authentication-Results: smtp4.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=INmjxGpV 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 UD3lS0ndPMIu; Tue, 9 Jan 2024 11:12:48 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp4.osuosl.org (Postfix) with ESMTPS id 23D6242257; Tue, 9 Jan 2024 11:12:47 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 23D6242257 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 8E064C0DD2; Tue, 9 Jan 2024 11:12:45 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 478B5C0DD0 for ; Tue, 9 Jan 2024 11:12:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 0E64E41A4C for ; Tue, 9 Jan 2024 11:12:44 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 0E64E41A4C Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=INmjxGpV X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BixY5MuTp_Sv for ; Tue, 9 Jan 2024 11:12:42 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by smtp2.osuosl.org (Postfix) with ESMTPS id A025441A47 for ; Tue, 9 Jan 2024 11:12:42 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org A025441A47 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704798761; 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=qfQEwJegtvVp6/qjpD0tXOB8FAOH1gmpeMUmfUAevCQ=; b=INmjxGpVcIdiiWD3EdXh8ajH0QYCkomshGjfGiwtCY00uodvVR9bsFzkge0hLJYtbH4raG rNuuAdiHXAfvoc6v+grCgcNoXTjbTHLG2YLRvRXLNJ6ZvkWEXFUx9onlhCzikauH57leNK kmkcMiFGS5fmN6ksD6gqR/AwPwl29ko= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-391-plz9NwyEMD6Gc2edE5g_lA-1; Tue, 09 Jan 2024 06:12:40 -0500 X-MC-Unique: plz9NwyEMD6Gc2edE5g_lA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 1407B833AE1 for ; Tue, 9 Jan 2024 11:12:40 +0000 (UTC) Received: from mheiblap.localdomain (unknown [10.47.238.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3EC8F40C6EB9; Tue, 9 Jan 2024 11:12:39 +0000 (UTC) From: Mohammad Heib To: dev@openvswitch.org Date: Tue, 9 Jan 2024 13:12:31 +0200 Message-Id: <20240109111232.539196-4-mheib@redhat.com> In-Reply-To: <20240109111232.539196-3-mheib@redhat.com> References: <20240109111232.539196-1-mheib@redhat.com> <20240109111232.539196-2-mheib@redhat.com> <20240109111232.539196-3-mheib@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn v3 3/4] OVN-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 Acked-by: Mark Michelson Signed-off-by: Mohammad Heib --- utilities/ovn-ic-nbctl.8.xml | 49 +++++++++++++++++++++ utilities/ovn-ic-nbctl.c | 85 +++++++++++++++++++++++++++++++++++- 2 files changed, 132 insertions(+), 2 deletions(-) diff --git a/utilities/ovn-ic-nbctl.8.xml b/utilities/ovn-ic-nbctl.8.xml index 4a70994b8..5a1324d2d 100644 --- a/utilities/ovn-ic-nbctl.8.xml +++ b/utilities/ovn-ic-nbctl.8.xml @@ -123,9 +123,58 @@ +

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..81c1ea00f 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) { @@ -705,6 +739,32 @@ ic_nbctl_context_done_command(struct ic_nbctl_context *ic_nbctl_ctx, ctl_context_done_command(&ic_nbctl_ctx->base, command); } +static void +ic_nbctl_validate_sequence_numbers(int expected_cfg, + struct ovsdb_idl *idl) +{ + if (wait_type == NBCTL_WAIT_NONE) { + if (force_wait) { + VLOG_INFO("\"sync\" command has no effect without --wait"); + } + return; + } + + const struct icnbrec_ic_nb_global *inb = icnbrec_ic_nb_global_first(idl); + 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 >= expected_cfg) { + return; + } + } + ovsdb_idl_wait(idl); + poll_block(); + } +} + static void ic_nbctl_context_done(struct ic_nbctl_context *ic_nbctl_ctx, struct ctl_command *command) @@ -748,6 +808,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 +823,17 @@ 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 +879,10 @@ 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 +960,11 @@ do_ic_nbctl(const char *args, struct ctl_command *commands, size_t n_commands, shash_destroy_free_data(&c->options); } free(commands); + + if (status != TXN_UNCHANGED) { + ic_nbctl_validate_sequence_numbers(next_cfg, idl); + } + ovsdb_idl_txn_destroy(txn); ovsdb_idl_destroy(idl); @@ -924,7 +1005,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 }, From patchwork Tue Jan 9 11:12:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohammad Heib X-Patchwork-Id: 1884377 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=RPaJ2f61; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (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 4T8Svn6s48z1yPf for ; Tue, 9 Jan 2024 22:12:53 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id D34456114D; Tue, 9 Jan 2024 11:12:51 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org D34456114D Authentication-Results: smtp3.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=RPaJ2f61 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nBAUl5hG1elP; Tue, 9 Jan 2024 11:12:50 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp3.osuosl.org (Postfix) with ESMTPS id 2E19D61169; Tue, 9 Jan 2024 11:12:49 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 2E19D61169 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 35E0CC0DE2; Tue, 9 Jan 2024 11:12:46 +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 98D01C0DE0 for ; Tue, 9 Jan 2024 11:12:44 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 7296D42201 for ; Tue, 9 Jan 2024 11:12:44 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 7296D42201 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=RPaJ2f61 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 LNpuagfkdG2x for ; Tue, 9 Jan 2024 11:12:43 +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 9DB38421B9 for ; Tue, 9 Jan 2024 11:12:43 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 9DB38421B9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1704798762; 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=rDun1E7IAIjDiIS4+10j5OTF2BZcBd3eM3Kb8WdPOpY=; b=RPaJ2f61DasUGsIyR1bpGeb/KNF956GXaZU75t9SX4dDdbDU+c0LSXskoI8rBwtDvifAa5 voLMCtWPPeS2LHij9g8SET/6hODFA+3cXGNs7Bt7ctvceRq1zVI1mV34qxeWrkNGrjV1Ol 1ftvvE4Zh8Z+QrRNUpH4NSfSOhgx+ow= 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-39-NE2aGDSSNSeRRkcXrkgpcA-1; Tue, 09 Jan 2024 06:12:41 -0500 X-MC-Unique: NE2aGDSSNSeRRkcXrkgpcA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 0BF211C05151 for ; Tue, 9 Jan 2024 11:12:41 +0000 (UTC) Received: from mheiblap.localdomain (unknown [10.47.238.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F5AF40C6EBA; Tue, 9 Jan 2024 11:12:40 +0000 (UTC) From: Mohammad Heib To: dev@openvswitch.org Date: Tue, 9 Jan 2024 13:12:32 +0200 Message-Id: <20240109111232.539196-5-mheib@redhat.com> In-Reply-To: <20240109111232.539196-4-mheib@redhat.com> References: <20240109111232.539196-1-mheib@redhat.com> <20240109111232.539196-2-mheib@redhat.com> <20240109111232.539196-3-mheib@redhat.com> <20240109111232.539196-4-mheib@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH ovn v3 4/4] ic/tests: add unit test for ic sync command 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" add unit test that check validate that sync command sync ISB properly Signed-off-by: Mohammad Heib --- tests/ovn-ic.at | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tests/ovn-ic.at b/tests/ovn-ic.at index d4c436f84..f55ffa6cd 100644 --- a/tests/ovn-ic.at +++ b/tests/ovn-ic.at @@ -1274,3 +1274,50 @@ OVN_CLEANUP_IC([az1], [az2]) AT_CLEANUP ]) + +AT_SETUP([ovn-ic -- sync ISB status to INB]) +ovn_init_ic_db +net_add n1 + +ovn_start az1 +sim_add gw-az1 +as gw-az1 + +check ovs-vsctl add-br br-phys +ovn_az_attach az1 n1 br-phys 192.168.1.1 +check ovs-vsctl set open . external-ids:ovn-is-interconn=true +as az1 + +# pause ovn-ic instance +check ovn-appctl -t ic/ovn-ic pause + +# run sync command in the background this commands +# supposed to stuck since ovn-ic is paused. +$(ovn-ic-nbctl --wait=sb sync &) + +for i in {1..5}; do + set -- $(ovn-ic-nbctl get ic_nb_global . nb_ic_cfg sb_ic_cfg) + AS_VAR_SET([ic_nb_cfg], [$1]) + AS_VAR_SET([ic_sb_cfg], [$2]) + if test $ic_nb_cfg -gt $ic_sb_cfg; then + sleep 1 + else + break + fi +done + +# if ic_nb_cfg equal to ic_sb_cfg that mean both zero +# or both 1 which is a not correct and the test must fail. +AT_FAIL_IF([test $ic_nb_cfg == $ic_sb_cfg]) + +# resume ovn-ic instance +check ovn-appctl -t ic/ovn-ic resume +set -- $(ovn-ic-nbctl get ic_nb_global . nb_ic_cfg sb_ic_cfg) +AS_VAR_SET([ic_nb_cfg], [$1]) +AS_VAR_SET([ic_sb_cfg], [$2]) +AT_FAIL_IF([test $ic_nb_cfg != 1]) +AT_FAIL_IF([test $ic_nb_cfg != 1]) + +OVN_CLEANUP_IC([az1]) +AT_CLEANUP +])