From patchwork Fri Nov 15 19:51:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frode Nordahl X-Patchwork-Id: 1195823 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=canonical.com 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 47F8BB37M1z9sPF for ; Sat, 16 Nov 2019 06:51:46 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 167B286940; Fri, 15 Nov 2019 19:51:44 +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 q48YGsIaRTBF; Fri, 15 Nov 2019 19:51:43 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by fraxinus.osuosl.org (Postfix) with ESMTP id 613FF85C4B; Fri, 15 Nov 2019 19:51:43 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 45BB2C1DD3; Fri, 15 Nov 2019 19:51:43 +0000 (UTC) X-Original-To: ovs-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 631D2C0878 for ; Fri, 15 Nov 2019 19:51:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 4F20A89402 for ; Fri, 15 Nov 2019 19:51:42 +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 MmqeZfDWqd4j for ; Fri, 15 Nov 2019 19:51:41 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by hemlock.osuosl.org (Postfix) with ESMTPS id 59BAE893FF for ; Fri, 15 Nov 2019 19:51:41 +0000 (UTC) Received: from mail-wr1-f72.google.com ([209.85.221.72]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1iVhd5-0002oV-ES for ovs-dev@openvswitch.org; Fri, 15 Nov 2019 19:51:39 +0000 Received: by mail-wr1-f72.google.com with SMTP id h7so8574852wrb.2 for ; Fri, 15 Nov 2019 11:51:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=9tcDDkVNpSZVLFjB5xK+IDEx2hAZdMZF69b5GADhIw4=; b=o1QHZ5n6J0pzw8b+wkADdFgs2q1oePEKzou7O0UX9tJnnNNjsRMZoYvHLHNvAaZqpQ UnKNV1TuwPxEOzMSyuyZ7IIYzpsaQn7Gj2Ev2R0JN02bG4ywuxkKsPAWucEE93nam1i/ KC8RFp6oLiepv5+ca96q9sOE0cs9eRJiusPpcT4l4lC04/fqG2e7WX+voDiv3aCSRfZK ToVWBjg9kc+JSN9LoGs86XzxdfY81iovkycqX+OnSMhqrDgMe9i3n7h+dNFGkMiJiSZz /XYBlKpyKmatt5RdQz6xwXs70DLmaDlMfMtjTGfF7PRI4go3YL11GJAqrJFVlt/sLw3l iO6A== X-Gm-Message-State: APjAAAWqFYNh078ZdanjcoAjYLFdQKtXeEBm7X5AneRRxNFiaf24gWJe jffV3AagE78L8pnwOy1ZOgEhCvDXSmziQnH5Mifa9spCCJYyTXgHJ1c79ndY5UZjUV73N5q3qSQ 8q85NMvPP+fLhtx/EOYG3GrFNRfyjncvkndp1HlaW1w7mHSLJRGg= X-Received: by 2002:a1c:e3d4:: with SMTP id a203mr15512724wmh.173.1573847498914; Fri, 15 Nov 2019 11:51:38 -0800 (PST) X-Google-Smtp-Source: APXvYqyzIxmfRs6CvcgDMzqVPFNyJsCNU85KDtPMtD3fNQ0WWVxrxLjclB3/vkcO4pqdGqp9vKLuk6HpldbDyhXWKmk= X-Received: by 2002:a1c:e3d4:: with SMTP id a203mr15512696wmh.173.1573847498561; Fri, 15 Nov 2019 11:51:38 -0800 (PST) MIME-Version: 1.0 From: Frode Nordahl Date: Fri, 15 Nov 2019 20:51:26 +0100 Message-ID: To: ovs-dev@openvswitch.org X-Content-Filtered-By: Mailman/MimeDel 2.1.15 Subject: [ovs-dev] [PATCH ovn] northd: Add `is-active` management 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" When ovn-northd is connected to clustered OVN DB servers a OVSDB locking feature is used to ensure only one ovn-northd process is active at a time. This patch adds a `is-active` management command that allows the operator to query whether a ovn-northd process is currently active or not. At present this information is only available in the log. Signed-off-by: Frode Nordahl --- northd/ovn-northd.8.xml | 19 +++++++++++++++++++ northd/ovn-northd.c | 18 +++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) @@ -10636,11 +10640,11 @@ main(int argc, char *argv[]) * acquiring a lock called "ovn_northd" on the southbound database * and then only performing DB transactions if the lock is held. */ ovsdb_idl_set_lock(ovnsb_idl_loop.idl, "ovn_northd"); - bool had_lock = false; /* Main loop. */ exiting = false; paused = false; + had_lock = false; while (!exiting) { if (!paused) { struct northd_context ctx = { @@ -10748,3 +10752,15 @@ ovn_northd_is_paused(struct unixctl_conn *conn, int argc OVS_UNUSED, unixctl_command_reply(conn, "false"); } } + +static void +ovn_northd_is_active(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, void *had_lock_) +{ + bool *had_lock = had_lock_; + if (*had_lock) { + unixctl_command_reply(conn, "true"); + } else { + unixctl_command_reply(conn, "false"); + } +} diff --git a/northd/ovn-northd.8.xml b/northd/ovn-northd.8.xml index 344cc0dbf..e712000f3 100644 --- a/northd/ovn-northd.8.xml +++ b/northd/ovn-northd.8.xml @@ -87,6 +87,12 @@
Returns "true" if ovn-northd is currently paused, "false" otherwise.
+ +
is-active
+
+ When ovn-northd is connected to clustered OVN DB servers, this returns + "true" if ovn-northd is currently active, "false" otherwise. +

@@ -130,6 +136,19 @@ DB changes.

+

Active-Standby with clustered OVN DB servers

+

+ When ovn-northd is connected to clustered OVN DB servers a + OVSDB locking feature will be used to ensure only one + ovn-northd process is active at a time. +

+ +

+ The ovn-northd daemon will write an entry in its log when + it becomes active. You may query the active status at any time with + the is-active management command. +

+

Logical Flow Table Structure

diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c index 6742bc002..b38688069 100644 --- a/northd/ovn-northd.c +++ b/northd/ovn-northd.c @@ -55,6 +55,7 @@ static unixctl_cb_func ovn_northd_exit; static unixctl_cb_func ovn_northd_pause; static unixctl_cb_func ovn_northd_resume; static unixctl_cb_func ovn_northd_is_paused; +static unixctl_cb_func ovn_northd_is_active; struct northd_context { struct ovsdb_idl *ovnnb_idl; @@ -10425,6 +10426,7 @@ main(int argc, char *argv[]) int retval; bool exiting; bool paused; + bool had_lock; fatal_ignore_sigpipe(); ovs_cmdl_proctitle_init(argc, argv); @@ -10450,6 +10452,8 @@ main(int argc, char *argv[]) unixctl_command_register("resume", "", 0, 0, ovn_northd_resume, &paused); unixctl_command_register("is-paused", "", 0, 0, ovn_northd_is_paused, &paused); + unixctl_command_register("is-active", "", 0, 0, ovn_northd_is_active, + &had_lock); daemonize_complete();