[ovs-dev] [PATCH v2 ovn] ovn-ctl: introduce ovsdb-{n, s}b-wrapper options

Lorenzo Bianconi lorenzo.bianconi at redhat.com
Fri Aug 21 08:07:08 UTC 2020


ovn-ctl has the following options to run ovn-northd, ovn-controller or
ovn-ic under strace or valgrind wrappers.

  --ovn-northd-wrapper
  --ovn-controller-wrapper
  --ovn-ic-wrapper

Introduce --ovsdb-nb-wrapper and --ovsdb-sb-wrapper to do the same for
ovsdb processes for ovn-{nb,sb} dbs

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi at redhat.com>
---
Changes since v1:
- code refactoring to remove duplication between start_ovsdb__() and
  start_ovn_daemon()
---
 utilities/ovn-ctl       | 18 ++++++++-----
 utilities/ovn-ctl.8.xml |  2 ++
 utilities/ovn-lib.in    | 58 +++++++++++++++++++++++------------------
 3 files changed, 47 insertions(+), 31 deletions(-)

diff --git a/utilities/ovn-ctl b/utilities/ovn-ctl
index 8afe68a0a..48b2b5bce 100755
--- a/utilities/ovn-ctl
+++ b/utilities/ovn-ctl
@@ -145,7 +145,7 @@ promote_ic_sb() {
 }
 
 start_ovsdb__() {
-    local DB=$1 db=$2 schema_name=$3 table_name=$4
+    local DB=$1 db=$2 schema_name=$3 table_name=$4 wrapper=$5
     local db_pid_file
     local cluster_local_addr
     local cluster_local_port
@@ -288,7 +288,7 @@ $cluster_remote_port
         set "$@" --sync-from=`cat $active_conf_file`
     fi
 
-    "$@" "$file"
+    start_wrapped_daemon "$wrapper" ovsdb-$db "$@" "$file"
 
     # Initialize the database if it's NOT joining a cluster.
     if test -z "$cluster_remote_addr"; then
@@ -301,7 +301,7 @@ $cluster_remote_port
 }
 
 start_nb_ovsdb() {
-    start_ovsdb__ NB nb OVN_Northbound NB_Global
+    start_ovsdb__ NB nb OVN_Northbound NB_Global "$OVSDB_NB_WRAPPER"
 }
 
 start_sb_ovsdb() {
@@ -313,7 +313,7 @@ start_sb_ovsdb() {
         ulimit -n $MAXFD
     fi
 
-    start_ovsdb__ SB sb OVN_Southbound SB_Global
+    start_ovsdb__ SB sb OVN_Southbound SB_Global "$OVSDB_SB_WRAPPER"
 }
 
 start_ovsdb () {
@@ -322,11 +322,13 @@ start_ovsdb () {
 }
 
 start_ic_nb_ovsdb() {
-    start_ovsdb__ IC_NB ic_nb OVN_IC_Northbound IC_NB_Global
+    start_ovsdb__ IC_NB ic_nb OVN_IC_Northbound IC_NB_Global \
+                  "$OVSDB_NB_WRAPPER"
 }
 
 start_ic_sb_ovsdb() {
-    start_ovsdb__ IC_SB ic_sb OVN_IC_Southbound IC_SB_Global
+    start_ovsdb__ IC_SB ic_sb OVN_IC_Southbound IC_SB_Global \
+                  "$OVSDB_SB_WRAPPER"
 }
 
 start_ic_ovsdb () {
@@ -692,6 +694,8 @@ set_defaults () {
     OVN_IC_WRAPPER=
     OVN_CONTROLLER_PRIORITY=-10
     OVN_CONTROLLER_WRAPPER=
+    OVSDB_NB_WRAPPER=
+    OVSDB_SB_WRAPPER=
 
     OVN_USER=
 
@@ -908,6 +912,8 @@ Options:
   --ovn-ic-sb-db-ssl-ca-cert=CERT OVN IC Southbound DB SSL CA certificate file
   --ovn-user="user[:group]"      pass the --user flag to the ovn daemons
   --ovs-user="user[:group]"      pass the --user flag to ovs daemons
+  --ovsdb-nb-wrapper=WRAPPER     run with a wrapper like valgrind for debugging
+  --ovsdb-sb-wrapper=WRAPPER     run with a wrapper like valgrind for debugging
   -h, --help                     display this help message
 
 File location options:
diff --git a/utilities/ovn-ctl.8.xml b/utilities/ovn-ctl.8.xml
index f5b7f7aeb..a1d39b22b 100644
--- a/utilities/ovn-ctl.8.xml
+++ b/utilities/ovn-ctl.8.xml
@@ -64,6 +64,8 @@
     <p><code>--ovn-controller-wrapper=<var>WRAPPER</var></code></p>
     <p><code>--ovn-ic-priority=<var>NICE</var></code></p>
     <p><code>--ovn-ic-wrapper=<var>WRAPPER</var></code></p>
+    <p><code>--ovsdb-nb-wrapper=<var>WRAPPER</var></code></p>
+    <p><code>--ovsdb-sb-wrapper=<var>WRAPPER</var></code></p>
     <p><code>--ovn-user=<var>USER:GROUP</var></code></p>
     <p><code>--ovs-user=<var>USER:GROUP</var></code></p>
     <p><code>-h</code> | <code>--help</code></p>
diff --git a/utilities/ovn-lib.in b/utilities/ovn-lib.in
index af1b72edb..e2e1339c4 100644
--- a/utilities/ovn-lib.in
+++ b/utilities/ovn-lib.in
@@ -59,27 +59,11 @@ ovn_install_dir () {
     fi
 }
 
-start_ovn_daemon () {
-    priority=$1
-    wrapper=$2
-    shift; shift
-    daemon=$1
+start_wrapped_daemon() {
+    wrapper=$1
+    daemon=$2
     strace=""
-
-    # drop core files in a sensible place
-    ovn_install_dir "$DAEMON_CWD"
-    set "$@" --no-chdir
-    cd "$DAEMON_CWD"
-
-    # log file
-    ovn_install_dir "$ovn_logdir" "750"
-    set "$@" --log-file="$ovn_logdir/$daemon.log"
-
-    # pidfile and monitoring
-    ovn_install_dir "$ovn_rundir"
-    set "$@" --pidfile="$ovn_rundir/$daemon.pid"
-    set "$@" --detach
-    test X"$MONITOR" = Xno || set "$@" --monitor
+    shift ; shift ;
 
     # wrapper
     case $wrapper in
@@ -113,11 +97,6 @@ start_ovn_daemon () {
             ;;
     esac
 
-    # priority
-    if test X"$priority" != X; then
-        set nice -n "$priority" "$@"
-    fi
-
     action "Starting $daemon" "$@" || return 1
 
     if test X"$strace" != X; then
@@ -127,6 +106,35 @@ start_ovn_daemon () {
     fi
 }
 
+start_ovn_daemon () {
+    priority=$1
+    wrapper=$2
+    shift; shift
+    daemon=$1
+
+    # drop core files in a sensible place
+    ovn_install_dir "$DAEMON_CWD"
+    set "$@" --no-chdir
+    cd "$DAEMON_CWD"
+
+    # log file
+    ovn_install_dir "$ovn_logdir" "750"
+    set "$@" --log-file="$ovn_logdir/$daemon.log"
+
+    # pidfile and monitoring
+    ovn_install_dir "$ovn_rundir"
+    set "$@" --pidfile="$ovn_rundir/$daemon.pid"
+    set "$@" --detach
+    test X"$MONITOR" = Xno || set "$@" --monitor
+
+    # priority
+    if test X"$priority" != X; then
+        set nice -n "$priority" "$@"
+    fi
+
+    start_wrapped_daemon "$wrapper" $daemon "$@"
+}
+
 stop_ovn_daemon () {
     if test -e "$ovn_rundir/$1.pid"; then
         if pid=`cat "$ovn_rundir/$1.pid"`; then
-- 
2.26.2



More information about the dev mailing list