diff mbox series

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

Message ID 29b88bbb01831f897df2d67b9d60b5ece9d54663.1598016740.git.lorenzo.bianconi@redhat.com
State Accepted
Headers show
Series [ovs-dev,v3,ovn] ovn-ctl: introduce ovsdb-{n, s}b-wrapper options | expand

Commit Message

Lorenzo Bianconi Aug. 21, 2020, 1:40 p.m. UTC
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

Tested-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
Changes since v2:
- fix nice configuration for ovn-northd

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    | 49 ++++++++++++++++++++++++-----------------
 3 files changed, 43 insertions(+), 26 deletions(-)

Comments

Dumitru Ceara Aug. 28, 2020, 1:46 p.m. UTC | #1
On 8/21/20 3:40 PM, Lorenzo Bianconi wrote:
> 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
> 
> Tested-by: Dumitru Ceara <dceara@redhat.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
> ---

Looks good to me, thanks!

Acked-by: Dumitru Ceara <dceara@redhat.com>
diff mbox series

Patch

diff --git a/utilities/ovn-ctl b/utilities/ovn-ctl
index 8afe68a0a..af095ea1b 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..016815626 100644
--- a/utilities/ovn-lib.in
+++ b/utilities/ovn-lib.in
@@ -59,27 +59,12 @@  ovn_install_dir () {
     fi
 }
 
-start_ovn_daemon () {
-    priority=$1
-    wrapper=$2
-    shift; shift
-    daemon=$1
+start_wrapped_daemon() {
+    wrapper=$1
+    daemon=$2
+    priority=$3
     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 ; shift ;
 
     # wrapper
     case $wrapper in
@@ -127,6 +112,30 @@  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
+
+    start_wrapped_daemon "$wrapper" $daemon "$priority" "$@"
+}
+
 stop_ovn_daemon () {
     if test -e "$ovn_rundir/$1.pid"; then
         if pid=`cat "$ovn_rundir/$1.pid"`; then