diff -Nru openvswitch-2.12.1~git20191107.7accd1302/debian/changelog openvswitch-2.12.1~git20191107.7accd1302/debian/changelog --- openvswitch-2.12.1~git20191107.7accd1302/debian/changelog 2019-11-12 22:43:03.000000000 +0000 +++ openvswitch-2.12.1~git20191107.7accd1302/debian/changelog 2019-11-21 07:29:06.000000000 +0000 @@ -1,3 +1,9 @@ +openvswitch (2.12.1~git20191107.7accd1302-0ubuntu2) focal; urgency=medium + + * d/p/northd-status.patch: Add `status` management command + + -- Frode Nordahl Thu, 21 Nov 2019 07:29:06 +0000 + openvswitch (2.12.1~git20191107.7accd1302-0ubuntu1) focal; urgency=medium * New upstream snapshot. diff -Nru openvswitch-2.12.1~git20191107.7accd1302/debian/patches/northd-status.patch openvswitch-2.12.1~git20191107.7accd1302/debian/patches/northd-status.patch --- openvswitch-2.12.1~git20191107.7accd1302/debian/patches/northd-status.patch 1970-01-01 00:00:00.000000000 +0000 +++ openvswitch-2.12.1~git20191107.7accd1302/debian/patches/northd-status.patch 2019-11-21 07:28:57.000000000 +0000 @@ -0,0 +1,125 @@ +From 695df0efe1fadf10cb9b6d10c84cb7a54ba65351 Mon Sep 17 00:00:00 2001 +From: Frode Nordahl +Date: Fri, 15 Nov 2019 20:51:26 +0100 +Subject: [PATCH] northd: Add `status` management command +Applied-Upstream: https://github.com/ovn-org/ovn/commit/695df0efe1fadf10cb9b6d10c84cb7a54ba65351 + +Allow the operator to query whether a ovn-northd process is +currently active for the standalone and clustered DB use case. + +At present this information is only available in the log. + +Signed-off-by: Frode Nordahl +Signed-off-by: Numan Siddique +--- + ovn/northd/ovn-northd.8.xml | 9 ++++++++- + ovn/northd/ovn-northd.c | 20 +++++++++++++++++++- + tests/ovn-northd.at | 9 +++++++++ + 3 files changed, 36 insertions(+), 2 deletions(-) + +diff --git a/ovn/northd/ovn-northd.8.xml b/ovn/northd/ovn-northd.8.xml +index 956a10362..9734e79e6 100644 +--- a/ovn/northd/ovn-northd.8.xml ++++ b/ovn/northd/ovn-northd.8.xml +@@ -87,13 +87,20 @@ +
+ Returns "true" if ovn-northd is currently paused, "false" otherwise. +
++ ++
status
++
++ Prints this server's status. Status will be "active" if ovn-northd has ++ acquired OVSDB lock on NB DB, "standby" otherwise. ++
+ +

+ +

Active-Standby for High Availability

+

+ You may run ovn-northd more than once in an OVN deployment. +- OVN will automatically ensure that only one of them is active at a time. ++ When connected to a standalone or clustered DB setup, OVN will ++ automatically ensure that only one of them is active at a time. + If multiple instances of ovn-northd are running and the + active ovn-northd fails, one of the hot standby instances + of ovn-northd will automatically take over. +diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c +index a5e711e69..a943e1037 100644 +--- a/ovn/northd/ovn-northd.c ++++ b/ovn/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_status; + + struct northd_context { + struct ovsdb_idl *ovnnb_idl; +@@ -10843,6 +10844,7 @@ main(int argc, char *argv[]) + int retval; + bool exiting; + bool paused; ++ bool had_lock; + + fatal_ignore_sigpipe(); + ovs_cmdl_proctitle_init(argc, argv); +@@ -10868,6 +10870,7 @@ 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("status", "", 0, 0, ovn_northd_status, &had_lock); + + daemonize_complete(); + +@@ -11073,11 +11076,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 = { +@@ -11185,3 +11188,18 @@ ovn_northd_is_paused(struct unixctl_conn *conn, int argc OVS_UNUSED, + unixctl_command_reply(conn, "false"); + } + } ++ ++static void ++ovn_northd_status(struct unixctl_conn *conn, int argc OVS_UNUSED, ++ const char *argv[] OVS_UNUSED, void *had_lock_) ++{ ++ bool *had_lock = had_lock_; ++ /* ++ * Use a labelled formatted output so we can add more to the status command ++ * later without breaking any consuming scripts ++ */ ++ struct ds s = DS_EMPTY_INITIALIZER; ++ ds_put_format(&s, "Status: %s\n", *had_lock ? "active" : "standby"); ++ unixctl_command_reply(conn, ds_cstr(&s)); ++ ds_destroy(&s); ++} +diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at +index da566f900..c73fd9003 100644 +--- a/tests/ovn-northd.at ++++ b/tests/ovn-northd.at +@@ -899,6 +899,15 @@ OVS_APP_EXIT_AND_WAIT([ovn-northd]) + + AT_CLEANUP + ++AT_SETUP([ovn -- ovn-northd status]) ++AT_SKIP_IF([test $HAVE_PYTHON = no]) ++ovn_start ++ ++AT_CHECK([as northd ovs-appctl -t ovn-northd status], [0], [Status: active ++]) ++ ++AT_CLEANUP ++ + AT_SETUP([ovn -- ovn-northd pause and resume]) + AT_SKIP_IF([test $HAVE_PYTHON = no]) + ovn_start diff -Nru openvswitch-2.12.1~git20191107.7accd1302/debian/patches/series openvswitch-2.12.1~git20191107.7accd1302/debian/patches/series --- openvswitch-2.12.1~git20191107.7accd1302/debian/patches/series 2019-08-28 08:33:10.000000000 +0000 +++ openvswitch-2.12.1~git20191107.7accd1302/debian/patches/series 2019-11-21 07:28:57.000000000 +0000 @@ -1 +1,2 @@ py3-compat.patch +northd-status.patch