From patchwork Tue Nov 5 18:09:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Numan Siddique X-Patchwork-Id: 1189868 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.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org 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 476yPk1HN9z9sP4 for ; Wed, 6 Nov 2019 05:10:18 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 7BC32ED3; Tue, 5 Nov 2019 18:10:15 +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 8A954ECE for ; Tue, 5 Nov 2019 18:10:14 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 71B42189 for ; Tue, 5 Nov 2019 18:10:12 +0000 (UTC) X-Originating-IP: 116.75.70.98 Received: from nummac.local (unknown [116.75.70.98]) (Authenticated sender: numans@ovn.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 7E97060008; Tue, 5 Nov 2019 18:10:09 +0000 (UTC) From: numans@ovn.org To: dev@openvswitch.org Date: Tue, 5 Nov 2019 23:39:59 +0530 Message-Id: <20191105180959.165223-1-numans@ovn.org> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW 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 ha chassis failover issues for stale ha chassis entries 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 If ha chassis rows of an HA chassis group become stale i.e the HA_Chassis.chassis column is empty (because ovn-controller is not running in that chassis) except one row and when ha_chassis_group_is_active() is called on that ovn-controller, then it returns false. Ideally it should become active since its the only active chassis. This patch fixes this issue. Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1762777 Reported-by: Daniel Alvarez Signed-off-by: Numan Siddique --- controller/ha-chassis.c | 22 ++++++++++++++++++++++ tests/ovn.at | 20 +++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/controller/ha-chassis.c b/controller/ha-chassis.c index 6d9426a5c..46d5b50fc 100644 --- a/controller/ha-chassis.c +++ b/controller/ha-chassis.c @@ -142,6 +142,20 @@ ha_chassis_destroy_ordered(struct ha_chassis_ordered *ordered_ha_ch) } } +/* Returns the number of ha_chassis whose chassis column is + * set. */ +static size_t +get_active_ha_chassis(const struct sbrec_ha_chassis_group *ha_ch_grp) +{ + size_t n_active_ha_chassis = 0; + for (size_t i = 0; i < ha_ch_grp->n_ha_chassis; i++) { + if (ha_ch_grp->ha_chassis[i]->chassis) { + n_active_ha_chassis++; + } + } + + return n_active_ha_chassis; +} /* Returns true if the local_chassis is the master of * the HA chassis group, false otherwise. */ @@ -159,6 +173,14 @@ ha_chassis_group_is_active( return (ha_ch_grp->ha_chassis[0]->chassis == local_chassis); } + if (get_active_ha_chassis(ha_ch_grp) == 1) { + /* Only 1 ha_chassis of this chassis group has the 'chasss' + * column set, which can only be true for this 'local_chassis'. + * So return true - as the local_chassis can be the master of + * this HA chassis group. */ + return true; + } + if (sset_is_empty(active_tunnels)) { /* If active tunnel sset is empty, it means it has lost * connectivity with other chassis. */ diff --git a/tests/ovn.at b/tests/ovn.at index 410f4b514..cb7903db8 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -13413,7 +13413,25 @@ OVS_WAIT_UNTIL( logical_port=ls1-lp_ext1` test "$chassis" = "$hv1_uuid"]) -OVN_CLEANUP([hv1],[hv2],[hv3]) +# Stop ovn-controllers on hv1 and hv3. +as hv1 ovn-appctl -t ovn-controller exit +as hv3 ovn-appctl -t ovn-controller exit + +# hv2 should be master and claim ls1-lp_ext1 +OVS_WAIT_UNTIL( + [chassis=`ovn-sbctl --bare --columns chassis find port_binding \ +logical_port=ls1-lp_ext1` + test "$chassis" = "$hv2_uuid"]) + +as hv1 +OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) +OVS_APP_EXIT_AND_WAIT([ovsdb-server]) + +as hv3 +OVS_APP_EXIT_AND_WAIT([ovs-vswitchd]) +OVS_APP_EXIT_AND_WAIT([ovsdb-server]) + +OVN_CLEANUP([hv2]) AT_CLEANUP AT_SETUP([ovn -- Address Set Incremental Processing])