ovn: Fix some split db issues in ovn-ctl.
authorRussell Bryant <russell@ovn.org>
Thu, 24 Mar 2016 21:40:41 +0000 (17:40 -0400)
committerRussell Bryant <russell@ovn.org>
Thu, 24 Mar 2016 23:47:00 +0000 (19:47 -0400)
The default location for databases should be $dbdir, not $rundir.

The default location for log files comes from $logdir, not $OVS_LOGDIR.

Fix ovs-appctl commands.  The code assumed that passing
--unixctl=ovnnb_db was sufficient to allow an argument of "-t ovnnb_db"
to ovs-appctl.  Unfortunately, that's not the case.  This literally
results in a unix socket called "ovnnb_db" and ovs-appctl will look for
one in the form "onnb_db.PID.ctl".  For now, add ".ctl" to the name and
pass it by full path to ovs-appctl.  In the future, it would be even
better to have an option similar to --unixctl that specifies a prefix
for ".PID.ctl", as I believe that would give the behavior we want.

Reported-by: Gurucharan Shetty <guru@ovn.org>
Reported-at: http://openvswitch.org/pipermail/dev/2016-March/068498.html
Fixes: 60bdd01148e4 ("Separating OVN NB and SB database processes")
Signed-off-by: Russell Bryant <russell@ovn.org>
Acked-by: Gurucharan Shetty <guru@ovn.org>
ovn/utilities/ovn-ctl

index 4348d6e..deb78a5 100755 (executable)
@@ -37,11 +37,11 @@ pidfile_is_running () {
 
 stop_ovsdb () {
     if pidfile_is_running $DB_NB_PID; then
-        ovs-appctl -t ovnnb_db exit
+        ovs-appctl -t $rundir/ovnnb_db.ctl exit
     fi
 
     if pidfile_is_running $DB_SB_PID; then
-        ovs-appctl -t ovnsb_db exit
+        ovs-appctl -t $rundir/ovnsb_db.ctl exit
     fi
 }
 
@@ -52,7 +52,7 @@ start_ovsdb () {
 
         set ovsdb-server
 
-        set "$@" --detach $OVN_NB_LOG --log-file=$OVN_NB_LOGFILE --remote=punix:$DB_NB_SOCK --remote=ptcp:$DB_NB_PORT --pidfile=$DB_NB_PID --unixctl=ovnnb_db
+        set "$@" --detach $OVN_NB_LOG --log-file=$OVN_NB_LOGFILE --remote=punix:$DB_NB_SOCK --remote=ptcp:$DB_NB_PORT --pidfile=$DB_NB_PID --unixctl=ovnnb_db.ctl
 
         $@ $DB_NB_FILE
     fi
@@ -63,7 +63,7 @@ start_ovsdb () {
 
         set ovsdb-server
 
-        set "$@" --detach $OVN_SB_LOG --log-file=$OVN_SB_LOGFILE --remote=punix:$DB_SB_SOCK --remote=ptcp:$DB_SB_PORT --pidfile=$DB_SB_PID --unixctl=ovnsb_db
+        set "$@" --detach $OVN_SB_LOG --log-file=$OVN_SB_LOGFILE --remote=punix:$DB_SB_SOCK --remote=ptcp:$DB_SB_PORT --pidfile=$DB_SB_PID --unixctl=ovnsb_db.ctl
         $@ $DB_SB_FILE
     fi
 }
@@ -151,17 +151,16 @@ restart_ovsdb () {
 ## ---- ##
 
 set_defaults () {
-    OVN_DIR=$rundir
     OVN_MANAGE_OVSDB=yes
 
-    DB_NB_SOCK=$OVN_DIR/ovnnb_db.sock
-    DB_NB_PID=$OVN_DIR/ovnnb_db.pid
-    DB_NB_FILE=$OVN_DIR/ovnnb_db.db
+    DB_NB_SOCK=$rundir/ovnnb_db.sock
+    DB_NB_PID=$rundir/ovnnb_db.pid
+    DB_NB_FILE=$dbdir/ovnnb_db.db
     DB_NB_PORT=6641
 
-    DB_SB_SOCK=$OVN_DIR/ovnsb_db.sock
-    DB_SB_PID=$OVN_DIR/ovnsb_db.pid
-    DB_SB_FILE=$OVN_DIR/ovnsb_db.db
+    DB_SB_SOCK=$rundir/ovnsb_db.sock
+    DB_SB_PID=$rundir/ovnsb_db.pid
+    DB_SB_FILE=$dbdir/ovnsb_db.db
     DB_SB_PORT=6642
 
     DB_NB_SCHEMA=$datadir/ovn-nb.ovsschema
@@ -182,8 +181,8 @@ set_defaults () {
     OVN_NORTHD_LOG="-vconsole:emer -vsyslog:err -vfile:info"
     OVN_NB_LOG="-vconsole:off"
     OVN_SB_LOG="-vconsole:off"
-    OVN_NB_LOGFILE="$OVS_LOGDIR/ovsdb-server-nb.log"
-    OVN_SB_LOGFILE="$OVS_LOGDIR/ovsdb-server-sb.log"
+    OVN_NB_LOGFILE="$logdir/ovsdb-server-nb.log"
+    OVN_SB_LOGFILE="$logdir/ovsdb-server-sb.log"
 }
 
 set_option () {
@@ -244,9 +243,8 @@ File location options:
   --db-sb-schema=FILE  OVN_Southbound db file (default: $DB_SB_SCHEMA)
   --db-nb-port=PORT    OVN Northbound db ptcp port (default: $DB_NB_PORT)
   --db-sb-port=PORT    OVN Southbound db ptcp port (default: $DB_SB_PORT)
-  --ovn-dir=FILE       OVN Databases directory (default: $OVN_DIR)
-  --ovn-nb-logfile=FILE OVN Northbound log file (default: $OVS_LOGDIR/ovsdb-server-nb.log)
-  --ovn-sb-logfile=FILE OVN Southbound log file (default: $OVS_LOGDIR/ovsdb-server-sb.log)
+  --ovn-nb-logfile=FILE OVN Northbound log file (default: $OVN_NB_LOGFILE)
+  --ovn-sb-logfile=FILE OVN Southbound log file (default: $OVN_SB_LOGFILE)
 
 Default directories with "configure" option and environment variable override:
   logs: /usr/local/var/log/openvswitch (--with-logdir, OVS_LOGDIR)