From patchwork Thu Apr 30 13:14:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dumitru Ceara X-Patchwork-Id: 1280397 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=Ol/y1Iw4; 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 49CbT62QHZz9sSd for ; Thu, 30 Apr 2020 23:14:50 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id C70A287EFD; Thu, 30 Apr 2020 13:14:48 +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 BjWL-Nu3cW6N; Thu, 30 Apr 2020 13:14:47 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by whitealder.osuosl.org (Postfix) with ESMTP id 19FB8878F4; Thu, 30 Apr 2020 13:14:47 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id F2739C088E; Thu, 30 Apr 2020 13:14:46 +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 4E4C8C0889 for ; Thu, 30 Apr 2020 13:14:45 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 3CCD287EF6 for ; Thu, 30 Apr 2020 13:14:45 +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 ZB5xljrTC0Bw for ; Thu, 30 Apr 2020 13:14:40 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by whitealder.osuosl.org (Postfix) with ESMTPS id AAF3287EFD for ; Thu, 30 Apr 2020 13:14:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588252479; 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=xdIkAxNB9+FkbHpgE1ykLbRObmfsSivhni0buvaL6po=; b=Ol/y1Iw4kqrV3HE5yUw2PUX5KGilXpjSx7npSR7kO9FPY2T8cdNwF8Z6aFbPSqynlRnDqf I7LGk+YC9+DrljJCR+CjpVI1Pbf1VVkEawNKndR4hcBtWi3UUcseoqebB1LraNHSsS3cmS YVClMB2ABYJbK79Hp1JRLquVtCav7fc= 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-36-DNo16LjBPXGhP8l-cfQlJA-1; Thu, 30 Apr 2020 09:14:37 -0400 X-MC-Unique: DNo16LjBPXGhP8l-cfQlJA-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 02AEA107B26F for ; Thu, 30 Apr 2020 13:14:37 +0000 (UTC) Received: from dceara.remote.csb (ovpn-115-51.ams2.redhat.com [10.36.115.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A8225C1B0 for ; Thu, 30 Apr 2020 13:14:36 +0000 (UTC) From: Dumitru Ceara To: dev@openvswitch.org Date: Thu, 30 Apr 2020 15:14:33 +0200 Message-Id: <20200430131430.27397.3645.stgit@dceara.remote.csb> In-Reply-To: <20200430131340.27397.50407.stgit@dceara.remote.csb> References: <20200430131340.27397.50407.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 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [ovs-dev] [PATCH v2 ovn 3/3] ovn-northd: Remove Port_Binding stale references to HA_Chassis_Group. 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" If a logical switch port of type "external" that has ha_chassis_group set is deleted from a logical switch and a port with the same name is added to a different logical switch in the same transaction, the SB Port_Binding record corresponding to the logical port is reused but the ha_chassis_group field is not cleared. One way to reproduce the issue is: $ ovn-nbctl ls-add ls1 $ ovn-nbctl ls-add ls2 $ ovn-nbctl lsp-add ls1 lsp1 $ ovn-nbctl lsp-add ls2 lsp2 $ ovn-nbctl lsp-set-type lsp2 external $ ovn-nbctl ha-chassis-group-add chg1 $ ovn-nbctl ha-chassis-group-add-chassis chg1 chassis-1 30 $ chg1_uuid=$(ovn-nbctl --bare --columns _uuid list ha_Chassis_Group .) $ ovn-nbctl set logical_switch_port lsp2 ha_chassis_group=${chg1_uuid} $ ovn-nbctl lsp-del lsp2 -- lsp-add ls1 lsp2 To avoid that, we now clear the Port_Binding ha_chassis_group field when the logical port corresponding to the port binding is not of type "external" anymore. Reported-by: Numan Siddique Signed-off-by: Dumitru Ceara --- northd/ovn-northd.c | 18 ++++++++---------- tests/ovn-northd.at | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 10 deletions(-) diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index dad6a45..c75a80b 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -2934,16 +2934,14 @@ ovn_port_update_sbrec(struct northd_context *ctx, sbrec_port_binding_set_nat_addresses(op->sb, NULL, 0); - if (!strcmp(op->nbsp->type, "external")) { - if (op->nbsp->ha_chassis_group) { - sync_ha_chassis_group_for_sbpb( - ctx, op->nbsp->ha_chassis_group, - sbrec_chassis_by_name, op->sb); - sset_add(active_ha_chassis_grps, - op->nbsp->ha_chassis_group->name); - } else { - sbrec_port_binding_set_ha_chassis_group(op->sb, NULL); - } + if (!strcmp(op->nbsp->type, "external") && + op->nbsp->ha_chassis_group) { + sync_ha_chassis_group_for_sbpb(ctx, op->nbsp->ha_chassis_group, + sbrec_chassis_by_name, op->sb); + sset_add(active_ha_chassis_grps, + op->nbsp->ha_chassis_group->name); + } else { + sbrec_port_binding_set_ha_chassis_group(op->sb, NULL); } } else { const char *chassis = NULL; diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at index 4823d14..0f10689 100644 --- a/tests/ovn-northd.at +++ b/tests/ovn-northd.at @@ -1444,3 +1444,29 @@ logical_port=lsp2) AT_CHECK([test ${pb1_key} != ${pb2_key}]) AT_CLEANUP + +AT_SETUP([ovn -- check reconcile stale Ha_Chassis_Group]) +ovn_start + +ovn-nbctl ls-add ls1 +ovn-nbctl ls-add ls2 +ovn-nbctl lsp-add ls1 lsp1 +ovn-nbctl lsp-add ls2 lsp2 + +ovn-nbctl lsp-set-type lsp2 external + +ovn-nbctl ha-chassis-group-add chg1 +ovn-nbctl ha-chassis-group-add-chassis chg1 chassis-1 30 + +chg1_uuid=$(ovn-nbctl --bare --columns _uuid list Ha_Chassis_Group .) +ovn-nbctl set logical_switch_port lsp2 ha_chassis_group=${chg1_uuid} +AT_CHECK([ovn-nbctl --wait=sb sync], [0]) + +# Move lsp2 from ls2 to ls1. This should also remove the SB HA_Chassis_Group +# record. +ovn-nbctl lsp-del lsp2 -- lsp-add ls1 lsp2 +AT_CHECK([ovn-nbctl --wait=sb sync], [0]) + +AT_CHECK([test 0 = $(ovn-sbctl list Ha_Chassis_Group | wc -l)]) + +AT_CLEANUP