From patchwork Mon Jul 29 17:20:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1138552 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 45y63s559xz9s3l for ; Tue, 30 Jul 2019 03:23:53 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id A7F341B99; Mon, 29 Jul 2019 17:23:49 +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 6B8B71B89 for ; Mon, 29 Jul 2019 17:21:12 +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 159DF604 for ; Mon, 29 Jul 2019 17:21:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7A2BDBDF9 for ; Mon, 29 Jul 2019 17:21:11 +0000 (UTC) Received: from nusiddiq.mac (unknown [10.74.10.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47E6A60BE5 for ; Mon, 29 Jul 2019 17:21:08 +0000 (UTC) From: nusiddiq@redhat.com To: dev@openvswitch.org Date: Mon, 29 Jul 2019 22:50:51 +0530 Message-Id: <20190729172051.4917-1-nusiddiq@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 29 Jul 2019 17:21:11 +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 ovn] Fix the chassis row recreation issue 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 From: Numan Siddique Before the commit [1], ovn-controller would always recreate its chassis row if deleted externally. After this commit, it no longer recreates it. This is regression and needs to be fixed. [1] - 242f1799fc22("ovn-controller: Refactor chassis.c to abstract the string parsing") Fixes: 242f1799fc22("ovn-controller: Refactor chassis.c to abstract the string parsing") Acked-by: Dumitru Ceara Acked-by: Han Zhou Signed-off-by: Numan Siddique --- controller/chassis.c | 4 ++++ tests/ovn-controller.at | 29 +++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/controller/chassis.c b/controller/chassis.c index 8d9f7c8d0..937c5574b 100644 --- a/controller/chassis.c +++ b/controller/chassis.c @@ -486,6 +486,10 @@ chassis_get_record(struct ovsdb_idl_txn *ovnsb_idl_txn, if (!chassis_rec) { VLOG_WARN("Could not find Chassis : 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); + } } } else { chassis_rec = diff --git a/tests/ovn-controller.at b/tests/ovn-controller.at index 343c2abed..63b2581c0 100644 --- a/tests/ovn-controller.at +++ b/tests/ovn-controller.at @@ -292,3 +292,32 @@ as ovn-sb OVS_APP_EXIT_AND_WAIT([ovsdb-server]) AT_CLEANUP + +# Checks that ovn-controller recreates its chassis record when deleted externally. +AT_SETUP([ovn-controller - Chassis self record]) +AT_KEYWORDS([ovn]) +ovn_init_db ovn-sb + +net_add n1 +sim_add hv +as hv +ovs-vsctl \ + -- add-br br-phys \ + -- add-br br-eth0 \ + -- add-br br-eth1 \ + -- add-br br-eth2 +ovn_attach n1 br-phys 192.168.0.1 + +OVS_WAIT_UNTIL([test xhv = x`ovn-sbctl --columns name --bare find chassis`]) +# Delete the chassis "hv" +ovn-sbctl chassis-del hv +# ovn-controller should recreate its chassis row. +OVS_WAIT_UNTIL([test xhv = x`ovn-sbctl --columns name --bare find chassis`]) + +# Gracefully terminate daemons +OVN_CLEANUP_SBOX([hv]) +OVN_CLEANUP_VSWITCH([main]) +as ovn-sb +OVS_APP_EXIT_AND_WAIT([ovsdb-server]) + +AT_CLEANUP