From patchwork Thu Sep 3 15:03:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1356661 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=whitealder.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: 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=SXGZIbpD; dkim-atps=neutral Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bj3wz0wxrz9sVk for ; Fri, 4 Sep 2020 01:04:02 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id B2BB686C32; Thu, 3 Sep 2020 15:04:00 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xC1Ci-6+DW63; Thu, 3 Sep 2020 15:03:59 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 9C812866AF; Thu, 3 Sep 2020 15:03:59 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 7D054C07FF; Thu, 3 Sep 2020 15:03:59 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 5CEDCC0051 for ; Thu, 3 Sep 2020 15:03:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 40540873DA for ; Thu, 3 Sep 2020 15:03:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1rcw+ayh7kbU for ; Thu, 3 Sep 2020 15:03:57 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by hemlock.osuosl.org (Postfix) with ESMTPS id 044CF873C1 for ; Thu, 3 Sep 2020 15:03:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599145435; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rWOWpf2NThvFrhIJGoVygcWJ4Z0SimzZasotXF/ajwM=; b=SXGZIbpDELqyzHgkzm4c//+YsUubp65jSo85UUuAtJ3g5pHfAozhO71umD7n9Yd0stA+Gt Y99Cbfl414KZiJ+cl3J6oV+S8RKlf6qZHcrQpn3NDpNKuXXWp3BrzFloCOzjUgZTdWEeNT 0+KKnwKLuRIQm+VNV48y7BQcGrKreM4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-28-yd9C579OP5myQuFPLPq_tw-1; Thu, 03 Sep 2020 11:03:53 -0400 X-MC-Unique: yd9C579OP5myQuFPLPq_tw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A0BFF18BA284 for ; Thu, 3 Sep 2020 15:03:52 +0000 (UTC) Received: from dceara.remote.csb (ovpn-113-142.ams2.redhat.com [10.36.113.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id 172705C1C2 for ; Thu, 3 Sep 2020 15:03:51 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Thu, 3 Sep 2020 17:03:45 +0200 Message-Id: <20200903150318.26775.68912.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v2 ovn 1/2] chassis: Fix the way encaps are updated for a chassis record. 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" ovn-controller always stores the last configured system-id/chassis-id in memory regardless if the connection to the SB is up or down. This is OK as long as the change can be committed successfully when the SB DB connection comes back up. Without this change, if the chassis-id changes while the SB connection is down, ovn-controller will fail to create the new record but nevertheless update its in-memory chassis-id. When the SB connection is restored ovn-controller tries to find the record corresponding to the chassis-id it stored in memory. This fails causing ovn-controller to try to insert a new record. But at this point a constraint violation is hit in the SB because the Encap records of the "stale" chassis still exist in the DB, along with the old chassis record. This commit changes the way we search for a "stale" chassis record in the SB to cover the above mentioned case. Also, in such cases there's no need to recreate the Encaps, it's sufficient to update the chassis_name field. Fixes: 5344f24ecb1a ("ovn-controller: Refactor chassis.c to abstract the string parsing") Signed-off-by: Dumitru Ceara --- v2: - reword the commit log as suggested by Numan. --- controller/chassis.c | 60 ++++++++++++++++++++++++++++++----------------- tests/ovn-controller.at | 17 +++++++++++++ 2 files changed, 55 insertions(+), 22 deletions(-) diff --git a/controller/chassis.c b/controller/chassis.c index d392d4f..97120a9 100644 --- a/controller/chassis.c +++ b/controller/chassis.c @@ -399,10 +399,7 @@ chassis_tunnels_changed(const struct sset *encap_type_set, { size_t encap_type_count = 0; - for (int i = 0; i < chassis_rec->n_encaps; i++) { - if (strcmp(chassis_rec->name, chassis_rec->encaps[i]->chassis_name)) { - return true; - } + for (size_t i = 0; i < chassis_rec->n_encaps; i++) { if (!sset_contains(encap_type_set, chassis_rec->encaps[i]->type)) { return true; @@ -475,6 +472,19 @@ chassis_build_encaps(struct ovsdb_idl_txn *ovnsb_idl_txn, } /* + * Updates encaps for a given chassis. This can happen when the chassis + * name has changed. Also, the only thing we support updating is the + * chassis_name. For other changes the encaps will be recreated. + */ +static void +chassis_update_encaps(const struct sbrec_chassis *chassis) +{ + for (size_t i = 0; i < chassis->n_encaps; i++) { + sbrec_encap_set_chassis_name(chassis->encaps[i], chassis->name); + } +} + +/* * Returns a pointer to a chassis record from 'chassis_table' that * matches at least one tunnel config. */ @@ -505,9 +515,10 @@ chassis_get_stale_record(const struct sbrec_chassis_table *chassis_table, /* If this is a chassis config update after we initialized the record once * then we should always be able to find it with the ID we saved in * chassis_state. - * Otherwise (i.e., first time we create the record) then we check if there's - * a stale record from a previous controller run that didn't end gracefully - * and reuse it. If not then we create a new record. + * Otherwise (i.e., first time we create the record or if the system-id + * changed) then we check if there's a stale record from a previous + * controller run that didn't end gracefully and reuse it. If not then we + * create a new record. * * Sets '*chassis_rec' to point to the local chassis record. * Returns true if this record was already in the database, false if it was @@ -521,28 +532,32 @@ chassis_get_record(struct ovsdb_idl_txn *ovnsb_idl_txn, const char *chassis_id, const struct sbrec_chassis **chassis_rec) { + const struct sbrec_chassis *chassis = NULL; + if (chassis_info_id_inited(&chassis_state)) { - *chassis_rec = chassis_lookup_by_name(sbrec_chassis_by_name, - chassis_info_id(&chassis_state)); - if (!(*chassis_rec)) { - VLOG_DBG("Could not find Chassis, will create it" - ": stored (%s) ovs (%s)", + chassis = chassis_lookup_by_name(sbrec_chassis_by_name, + chassis_info_id(&chassis_state)); + if (!chassis) { + VLOG_DBG("Could not find Chassis, will check if the id changed: " + "stored (%s) ovs (%s)", chassis_info_id(&chassis_state), chassis_id); - if (ovnsb_idl_txn) { - /* Recreate the chassis record. */ - *chassis_rec = sbrec_chassis_insert(ovnsb_idl_txn); - return false; - } } - } else { - *chassis_rec = - chassis_get_stale_record(chassis_table, ovs_cfg, chassis_id); + } - if (!(*chassis_rec) && ovnsb_idl_txn) { + if (!chassis) { + chassis = chassis_get_stale_record(chassis_table, ovs_cfg, chassis_id); + } + + if (!chassis) { + /* Recreate the chassis record. */ + VLOG_DBG("Could not find Chassis, will create it: %s", chassis_id); + if (ovnsb_idl_txn) { *chassis_rec = sbrec_chassis_insert(ovnsb_idl_txn); - return false; } + return false; } + + *chassis_rec = chassis; return true; } @@ -604,6 +619,7 @@ chassis_update(const struct sbrec_chassis *chassis_rec, &ovs_cfg->encap_ip_set, ovs_cfg->encap_csum, chassis_rec); if (!tunnels_changed) { + chassis_update_encaps(chassis_rec); return updated; } diff --git a/tests/ovn-controller.at b/tests/ovn-controller.at index 1b96934..f2faf1f 100644 --- a/tests/ovn-controller.at +++ b/tests/ovn-controller.at @@ -196,6 +196,23 @@ OVS_WAIT_UNTIL([ test "${sysid}" = "${chassis_id}" ]) +# Simulate system-id changing while ovn-controller is disconnected from the +# SB. +valid_remote=$(ovs-vsctl get Open_vSwitch . external_ids:ovn-remote) +invalid_remote=tcp:0.0.0.0:4242 +ovs-vsctl set Open_vSwitch . external_ids:ovn-remote=${invalid_remote} +expected_state="not connected" +OVS_WAIT_UNTIL([ + test "${expected_state}" = "$(ovn-appctl -t ovn-controller connection-status)" +]) +sysid=${sysid}-bar +ovs-vsctl set Open_vSwitch . external-ids:system-id="${sysid}" +ovs-vsctl set Open_vSwitch . external_ids:ovn-remote=${valid_remote} +OVS_WAIT_UNTIL([ + chassis_id=$(ovn-sbctl get Chassis "${sysid}" name) + test "${sysid}" = "${chassis_id}" +]) + # Gracefully terminate daemons OVN_CLEANUP_SBOX([hv]) OVN_CLEANUP_VSWITCH([main]) From patchwork Thu Sep 3 15:04:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1356663 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: 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=fgO1S0Gj; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Bj3xF749wz9sTR for ; Fri, 4 Sep 2020 01:04:17 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 8415C86D6C; Thu, 3 Sep 2020 15:04:16 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sPbZ4tszmJ0q; Thu, 3 Sep 2020 15:04:15 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 495D686D33; Thu, 3 Sep 2020 15:04:15 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 3B568C07FF; Thu, 3 Sep 2020 15:04:15 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 75991C0051 for ; Thu, 3 Sep 2020 15:04:14 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 6F557866AF for ; Thu, 3 Sep 2020 15:04:14 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1YcDA9XPXPeV for ; Thu, 3 Sep 2020 15:04:12 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by whitealder.osuosl.org (Postfix) with ESMTPS id 026BC86C23 for ; Thu, 3 Sep 2020 15:04:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599145450; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=65kiduN9skGsWmlXgrgZozExBDmRy/z6XmKk7slenk8=; b=fgO1S0GjUGxdriu0eRQQkAp98QWZuJOYZzORE58zfyIeChYqT9qfisacRP9VsFAED7ZQKG x32thX4+qUQN9dQp2TRtqx7Y7ffzpOE3vtPpJUFyG31satpySlobc4JcajdPG+nLiYghDo v1PqG4dK3NLxN2juNMEg6hxcFSVpoOA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-308-vqJn2xHXOY-FNKhdZd0Ghg-1; Thu, 03 Sep 2020 11:04:06 -0400 X-MC-Unique: vqJn2xHXOY-FNKhdZd0Ghg-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A8EAE1009445 for ; Thu, 3 Sep 2020 15:04:05 +0000 (UTC) Received: from dceara.remote.csb (ovpn-113-142.ams2.redhat.com [10.36.113.142]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB51E5D9DC for ; Thu, 3 Sep 2020 15:04:04 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Thu, 3 Sep 2020 17:04:01 +0200 Message-Id: <20200903150357.26775.17767.stgit@dceara.remote.csb> In-Reply-To: <20200903150318.26775.68912.stgit@dceara.remote.csb> References: <20200903150318.26775.68912.stgit@dceara.remote.csb> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dceara@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v2 ovn 2/2] chassis: Fix chassis_private record updates when the system-id changes. 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" Also: - Change conditional monitoring for Chassis_Private to use the chassis uuid instead of chassis name. Using the chassis->name field does not work because this is the old value of the field and would cause ovsdb-server to inform ovn-controller that the updated Chassis_Private record was "deleted" because it doesn't match the monitor condition anymore. - Allow ovn-sbctl to access Chassis_Private records by name. Reported-at: https://bugzilla.redhat.com/1873032 Reported-by: Ying Xu CC: Han Zhou Fixes: 4adc10f58127 ("Avoid nb_cfg update notification flooding") Signed-off-by: Dumitru Ceara --- v2: - Fix the monitor condition update reported by Numan. --- controller/chassis.c | 92 ++++++++++++++++++++++++++++++++++++++----- controller/chassis.h | 2 + controller/ovn-controller.c | 13 ++++-- tests/ovn-controller.at | 18 ++++++++ utilities/ovn-sbctl.c | 3 + 5 files changed, 112 insertions(+), 16 deletions(-) diff --git a/controller/chassis.c b/controller/chassis.c index 97120a9..45e018e 100644 --- a/controller/chassis.c +++ b/controller/chassis.c @@ -635,6 +635,77 @@ chassis_update(const struct sbrec_chassis *chassis_rec, return true; } +/* + * Returns a pointer to a chassis_private record from 'chassis_pvt_table' that + * matches the chassis record. + */ +static const struct sbrec_chassis_private * +chassis_private_get_stale_record( + const struct sbrec_chassis_private_table *chassis_pvt_table, + const struct sbrec_chassis *chassis) +{ + const struct sbrec_chassis_private *chassis_pvt_rec; + + SBREC_CHASSIS_PRIVATE_TABLE_FOR_EACH (chassis_pvt_rec, chassis_pvt_table) { + if (chassis_pvt_rec->chassis == chassis) { + return chassis_pvt_rec; + } + } + + return NULL; +} + +/* If this is a chassis_private config update after we initialized the record + * once then we should always be able to find it with the ID we saved in + * chassis_state. + * Otherwise (i.e., first time we created the chassis record or if the + * system-id changed) then we check if there's a stale record from a previous + * controller run that didn't end gracefully and reuse it. If not then we + * create a new record. + * + * Returns the local chassis record. + */ +static const struct sbrec_chassis_private * +chassis_private_get_record( + struct ovsdb_idl_txn *ovnsb_idl_txn, + struct ovsdb_idl_index *sbrec_chassis_pvt_by_name, + const struct sbrec_chassis_private_table *chassis_pvt_table, + const struct sbrec_chassis *chassis) +{ + const struct sbrec_chassis_private *chassis_p = NULL; + + if (chassis_info_id_inited(&chassis_state)) { + chassis_p = + chassis_private_lookup_by_name(sbrec_chassis_pvt_by_name, + chassis_info_id(&chassis_state)); + } + + if (!chassis_p) { + chassis_p = chassis_private_get_stale_record(chassis_pvt_table, + chassis); + } + + if (!chassis_p && ovnsb_idl_txn) { + return sbrec_chassis_private_insert(ovnsb_idl_txn); + } + + return chassis_p; +} + +static void +chassis_private_update(const struct sbrec_chassis_private *chassis_pvt, + const struct sbrec_chassis *chassis, + const char *chassis_id) +{ + if (!chassis_pvt->name || strcmp(chassis_pvt->name, chassis_id)) { + sbrec_chassis_private_set_name(chassis_pvt, chassis_id); + } + + if (chassis_pvt->chassis != chassis) { + sbrec_chassis_private_set_chassis(chassis_pvt, chassis); + } +} + /* Returns this chassis's Chassis record, if it is available. */ const struct sbrec_chassis * chassis_run(struct ovsdb_idl_txn *ovnsb_idl_txn, @@ -642,6 +713,7 @@ chassis_run(struct ovsdb_idl_txn *ovnsb_idl_txn, struct ovsdb_idl_index *sbrec_chassis_private_by_name, const struct ovsrec_open_vswitch_table *ovs_table, const struct sbrec_chassis_table *chassis_table, + const struct sbrec_chassis_private_table *chassis_pvt_table, const char *chassis_id, const struct ovsrec_bridge *br_int, const struct sset *transport_zones, @@ -670,7 +742,6 @@ chassis_run(struct ovsdb_idl_txn *ovnsb_idl_txn, bool updated = chassis_update(chassis_rec, ovnsb_idl_txn, &ovs_cfg, chassis_id, transport_zones); - chassis_info_set_id(&chassis_state, chassis_id); if (!existed || updated) { ovsdb_idl_txn_add_comment(ovnsb_idl_txn, "ovn-controller: %s chassis '%s'", @@ -678,17 +749,16 @@ chassis_run(struct ovsdb_idl_txn *ovnsb_idl_txn, chassis_id); } - const struct sbrec_chassis_private *chassis_private_rec = - chassis_private_lookup_by_name(sbrec_chassis_private_by_name, - chassis_id); - if (!chassis_private_rec && ovnsb_idl_txn) { - chassis_private_rec = sbrec_chassis_private_insert(ovnsb_idl_txn); - sbrec_chassis_private_set_name(chassis_private_rec, - chassis_id); - sbrec_chassis_private_set_chassis(chassis_private_rec, - chassis_rec); + *chassis_private = + chassis_private_get_record(ovnsb_idl_txn, + sbrec_chassis_private_by_name, + chassis_pvt_table, chassis_rec); + + if (*chassis_private) { + chassis_private_update(*chassis_private, chassis_rec, chassis_id); } - *chassis_private = chassis_private_rec; + + chassis_info_set_id(&chassis_state, chassis_id); } ovs_chassis_cfg_destroy(&ovs_cfg); diff --git a/controller/chassis.h b/controller/chassis.h index 81055b4..220f726 100644 --- a/controller/chassis.h +++ b/controller/chassis.h @@ -26,6 +26,7 @@ struct ovsrec_bridge; struct ovsrec_open_vswitch_table; struct sbrec_chassis; struct sbrec_chassis_table; +struct sbrec_chassis_private_table; struct sset; struct eth_addr; struct smap; @@ -37,6 +38,7 @@ const struct sbrec_chassis *chassis_run( struct ovsdb_idl_index *sbrec_chassis_private_by_name, const struct ovsrec_open_vswitch_table *, const struct sbrec_chassis_table *, + const struct sbrec_chassis_private_table *, const char *chassis_id, const struct ovsrec_bridge *br_int, const struct sset *transport_zones, const struct sbrec_chassis_private **chassis_private); diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 874087c..67e06f1 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -179,7 +179,7 @@ update_sb_monitors(struct ovsdb_idl *ovnsb_idl, * chassis */ sbrec_port_binding_add_clause_type(&pb, OVSDB_F_EQ, "chassisredirect"); sbrec_port_binding_add_clause_type(&pb, OVSDB_F_EQ, "external"); - if (chassis) { + if (chassis && !sbrec_chassis_is_new(chassis)) { /* This should be mostly redundant with the other clauses for port * bindings, but it allows us to catch any ports that are assigned to * us but should not be. That way, we can clear their chassis @@ -202,9 +202,9 @@ update_sb_monitors(struct ovsdb_idl *ovnsb_idl, sbrec_igmp_group_add_clause_chassis(&igmp, OVSDB_F_EQ, &chassis->header_.uuid); - /* Monitors Chassis_Private record for current chassis only */ - sbrec_chassis_private_add_clause_name(&chprv, OVSDB_F_EQ, - chassis->name); + /* Monitors Chassis_Private record for current chassis only. */ + sbrec_chassis_private_add_clause_chassis(&chprv, OVSDB_F_EQ, + &chassis->header_.uuid); } else { /* During initialization, we monitor all records in Chassis_Private so * that we don't try to recreate existing ones. */ @@ -2425,6 +2425,8 @@ main(int argc, char *argv[]) ovsrec_open_vswitch_table_get(ovs_idl_loop.idl); const struct sbrec_chassis_table *chassis_table = sbrec_chassis_table_get(ovnsb_idl_loop.idl); + const struct sbrec_chassis_private_table *chassis_pvt_table = + sbrec_chassis_private_table_get(ovnsb_idl_loop.idl); const struct ovsrec_bridge *br_int = process_br_int(ovs_idl_txn, bridge_table, ovs_table); const char *chassis_id = get_ovs_chassis_id(ovs_table); @@ -2433,7 +2435,8 @@ main(int argc, char *argv[]) if (chassis_id) { chassis = chassis_run(ovnsb_idl_txn, sbrec_chassis_by_name, sbrec_chassis_private_by_name, - ovs_table, chassis_table, chassis_id, + ovs_table, chassis_table, + chassis_pvt_table, chassis_id, br_int, &transport_zones, &chassis_private); } diff --git a/tests/ovn-controller.at b/tests/ovn-controller.at index f2faf1f..812946b 100644 --- a/tests/ovn-controller.at +++ b/tests/ovn-controller.at @@ -195,6 +195,15 @@ OVS_WAIT_UNTIL([ chassis_id=$(ovn-sbctl get Chassis "${sysid}" name) test "${sysid}" = "${chassis_id}" ]) +OVS_WAIT_UNTIL([ + chassis_id=$(ovn-sbctl get Chassis_Private "${sysid}" name) + test "${sysid}" = "${chassis_id}" +]) + +# Only one Chassis_Private record should exist. +OVS_WAIT_UNTIL([ + test $(ovn-sbctl --columns _uuid list chassis_private | wc -l) -eq 1 +]) # Simulate system-id changing while ovn-controller is disconnected from the # SB. @@ -212,6 +221,15 @@ OVS_WAIT_UNTIL([ chassis_id=$(ovn-sbctl get Chassis "${sysid}" name) test "${sysid}" = "${chassis_id}" ]) +OVS_WAIT_UNTIL([ + chassis_id=$(ovn-sbctl get Chassis_Private "${sysid}" name) + test "${sysid}" = "${chassis_id}" +]) + +# Only one Chassis_Private record should exist. +OVS_WAIT_UNTIL([ + test $(ovn-sbctl --columns _uuid list chassis_private | wc -l) -eq 1 +]) # Gracefully terminate daemons OVN_CLEANUP_SBOX([hv]) diff --git a/utilities/ovn-sbctl.c b/utilities/ovn-sbctl.c index 04e082c..d3eec91 100644 --- a/utilities/ovn-sbctl.c +++ b/utilities/ovn-sbctl.c @@ -1391,6 +1391,9 @@ cmd_set_ssl(struct ctl_context *ctx) static const struct ctl_table_class tables[SBREC_N_TABLES] = { [SBREC_TABLE_CHASSIS].row_ids[0] = {&sbrec_chassis_col_name, NULL, NULL}, + [SBREC_TABLE_CHASSIS_PRIVATE].row_ids[0] + = {&sbrec_chassis_private_col_name, NULL, NULL}, + [SBREC_TABLE_DATAPATH_BINDING].row_ids = {{&sbrec_datapath_binding_col_external_ids, "name", NULL}, {&sbrec_datapath_binding_col_external_ids, "name2", NULL},