diff mbox series

[ovs-dev] ovn-ctl: Provide the option to detach the OVN db servers or not when starting

Message ID 20171102112514.27542-1-nusiddiq@redhat.com
State Changes Requested
Headers show
Series [ovs-dev] ovn-ctl: Provide the option to detach the OVN db servers or not when starting | expand

Commit Message

Numan Siddique Nov. 2, 2017, 11:25 a.m. UTC
From: Numan Siddique <nusiddiq@redhat.com>

Presently if the user wants to start OVN db servers as separate containers, 'ovn-ctl'
script is not useful as '--detach' option is passed when ovsdb-servers are started.
If the container command is 'ovn-ctl start_nb_ovsdb', the  container exits as soon as
ovn-ctl exits.

This patch adds 2 new options to the 'ovn-ctl' script - '--db-nb-detach' and
'--db-sb-detach' which can take 'yes/no'. This will be really useful for the above
mentioned requirement. The user can start NB ovsdb-server with the command
'ovn-ctl start_nb_ovsdb --db-nb-detach=no'.

Without this option, the user may have to first generate the db by running 'ovsdb-tool'
and then start the container with the command 'ovsdb-server ovnnb_db.db ....' and this
is very inconvenient. This option will be useful only if the OVN db servers are started
in separate containers.

This patch also updates the missing documentation in ovn-ctl.8.xml.

Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
---
 ovn/utilities/ovn-ctl       | 15 +++++++++++++--
 ovn/utilities/ovn-ctl.8.xml |  9 +++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)

Comments

Ben Pfaff Nov. 2, 2017, 5:45 p.m. UTC | #1
On Thu, Nov 02, 2017 at 04:55:14PM +0530, nusiddiq@redhat.com wrote:
> From: Numan Siddique <nusiddiq@redhat.com>
> 
> Presently if the user wants to start OVN db servers as separate containers, 'ovn-ctl'
> script is not useful as '--detach' option is passed when ovsdb-servers are started.
> If the container command is 'ovn-ctl start_nb_ovsdb', the  container exits as soon as
> ovn-ctl exits.
> 
> This patch adds 2 new options to the 'ovn-ctl' script - '--db-nb-detach' and
> '--db-sb-detach' which can take 'yes/no'. This will be really useful for the above
> mentioned requirement. The user can start NB ovsdb-server with the command
> 'ovn-ctl start_nb_ovsdb --db-nb-detach=no'.
> 
> Without this option, the user may have to first generate the db by running 'ovsdb-tool'
> and then start the container with the command 'ovsdb-server ovnnb_db.db ....' and this
> is very inconvenient. This option will be useful only if the OVN db servers are started
> in separate containers.
> 
> This patch also updates the missing documentation in ovn-ctl.8.xml.
> 
> Signed-off-by: Numan Siddique <nusiddiq@redhat.com>

Despite the small patch, this is a major change in actual functionality,
since, with this option, ovn-ctl changes from a fast-running script that
just starts or stops a daemon, to a long-running script that waits for
the daemon to exit.

I wonder whether this would warrant new commands, e.g. run_nb_ovsdb and
run_sb_ovsdb.  These could be implemented internally by just adding the
option, I guess.

Another way might be to add a command to wait for a service to exit.

The "ovn-[sn]bctl init" commands won't run, in this case.  Maybe that is
not too important.

--detach and --monitor are independent.  Is there a reason to remove
--monitor when removing --detach?
Numan Siddique Nov. 2, 2017, 6:11 p.m. UTC | #2
On Thu, Nov 2, 2017 at 11:15 PM, Ben Pfaff <blp@ovn.org> wrote:

> On Thu, Nov 02, 2017 at 04:55:14PM +0530, nusiddiq@redhat.com wrote:
> > From: Numan Siddique <nusiddiq@redhat.com>
> >
> > Presently if the user wants to start OVN db servers as separate
> containers, 'ovn-ctl'
> > script is not useful as '--detach' option is passed when ovsdb-servers
> are started.
> > If the container command is 'ovn-ctl start_nb_ovsdb', the  container
> exits as soon as
> > ovn-ctl exits.
> >
> > This patch adds 2 new options to the 'ovn-ctl' script - '--db-nb-detach'
> and
> > '--db-sb-detach' which can take 'yes/no'. This will be really useful for
> the above
> > mentioned requirement. The user can start NB ovsdb-server with the
> command
> > 'ovn-ctl start_nb_ovsdb --db-nb-detach=no'.
> >
> > Without this option, the user may have to first generate the db by
> running 'ovsdb-tool'
> > and then start the container with the command 'ovsdb-server ovnnb_db.db
> ....' and this
> > is very inconvenient. This option will be useful only if the OVN db
> servers are started
> > in separate containers.
> >
> > This patch also updates the missing documentation in ovn-ctl.8.xml.
> >
> > Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
>
> Despite the small patch, this is a major change in actual functionality,
> since, with this option, ovn-ctl changes from a fast-running script that
> just starts or stops a daemon, to a long-running script that waits for
> the daemon to exit.
>
> I wonder whether this would warrant new commands, e.g. run_nb_ovsdb and
> run_sb_ovsdb.  These could be implemented internally by just adding the
> option, I guess.
>
> Another way might be to add a command to wait for a service to exit.
>
> The "ovn-[sn]bctl init" commands won't run, in this case.  Maybe that is
> not too important.
>
> --detach and --monitor are independent.  Is there a reason to remove
> --monitor when removing --detach?
>

Thanks Ben. I agree. I will work based on your suggestions.
In the case of containers, I thnk monitor is not required. The life of the
container in the case of ovsdb-server would be till it runs.
In case the ovsdb-server exits unexpectedly, the container
management service (like docker) can restart the container if "restart"
flag is set when starting the container.
Please let me know if this doesn't sound fine.

Thanks
Numan
Ben Pfaff Nov. 2, 2017, 6:18 p.m. UTC | #3
On Thu, Nov 02, 2017 at 11:41:17PM +0530, Numan Siddique wrote:
> On Thu, Nov 2, 2017 at 11:15 PM, Ben Pfaff <blp@ovn.org> wrote:
> 
> > On Thu, Nov 02, 2017 at 04:55:14PM +0530, nusiddiq@redhat.com wrote:
> > > From: Numan Siddique <nusiddiq@redhat.com>
> > >
> > > Presently if the user wants to start OVN db servers as separate
> > containers, 'ovn-ctl'
> > > script is not useful as '--detach' option is passed when ovsdb-servers
> > are started.
> > > If the container command is 'ovn-ctl start_nb_ovsdb', the  container
> > exits as soon as
> > > ovn-ctl exits.
> > >
> > > This patch adds 2 new options to the 'ovn-ctl' script - '--db-nb-detach'
> > and
> > > '--db-sb-detach' which can take 'yes/no'. This will be really useful for
> > the above
> > > mentioned requirement. The user can start NB ovsdb-server with the
> > command
> > > 'ovn-ctl start_nb_ovsdb --db-nb-detach=no'.
> > >
> > > Without this option, the user may have to first generate the db by
> > running 'ovsdb-tool'
> > > and then start the container with the command 'ovsdb-server ovnnb_db.db
> > ....' and this
> > > is very inconvenient. This option will be useful only if the OVN db
> > servers are started
> > > in separate containers.
> > >
> > > This patch also updates the missing documentation in ovn-ctl.8.xml.
> > >
> > > Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
> >
> > Despite the small patch, this is a major change in actual functionality,
> > since, with this option, ovn-ctl changes from a fast-running script that
> > just starts or stops a daemon, to a long-running script that waits for
> > the daemon to exit.
> >
> > I wonder whether this would warrant new commands, e.g. run_nb_ovsdb and
> > run_sb_ovsdb.  These could be implemented internally by just adding the
> > option, I guess.
> >
> > Another way might be to add a command to wait for a service to exit.
> >
> > The "ovn-[sn]bctl init" commands won't run, in this case.  Maybe that is
> > not too important.
> >
> > --detach and --monitor are independent.  Is there a reason to remove
> > --monitor when removing --detach?
> >
> 
> Thanks Ben. I agree. I will work based on your suggestions.
> In the case of containers, I thnk monitor is not required. The life of the
> container in the case of ovsdb-server would be till it runs.
> In case the ovsdb-server exits unexpectedly, the container
> management service (like docker) can restart the container if "restart"
> flag is set when starting the container.
> Please let me know if this doesn't sound fine.

I think that's OK, then.

It would be good to explain what this does, and why, and when might want
to use it, in the ovn-ctl manpage.

Thanks,

Ben.
diff mbox series

Patch

diff --git a/ovn/utilities/ovn-ctl b/ovn/utilities/ovn-ctl
index 3e247a1c6..8261b82c7 100755
--- a/ovn/utilities/ovn-ctl
+++ b/ovn/utilities/ovn-ctl
@@ -100,7 +100,10 @@  start_nb_ovsdb() {
 
         set ovsdb-server
 
-        set "$@" --detach --monitor
+        if test X"$DB_NB_DETACH" = Xyes; then
+            set "$@" --detach --monitor
+        fi
+
         set "$@" $OVN_NB_LOG --log-file=$OVN_NB_LOGFILE
         set "$@" --remote=punix:$DB_NB_SOCK --pidfile=$DB_NB_PID
         set "$@" --remote=db:OVN_Northbound,NB_Global,connections
@@ -135,7 +138,10 @@  start_sb_ovsdb() {
 
         set ovsdb-server
 
-        set "$@" --detach --monitor
+        if test X"$DB_SB_DETACH" = Xyes; then
+            set "$@" --detach --monitor
+        fi
+
         set "$@" $OVN_SB_LOG --log-file=$OVN_SB_LOGFILE
         set "$@" --remote=punix:$DB_SB_SOCK --pidfile=$DB_SB_PID
         set "$@" --remote=db:OVN_Southbound,SB_Global,connections
@@ -383,6 +389,9 @@  set_defaults () {
     DB_NB_CREATE_INSECURE_REMOTE="no"
 
     MONITOR="yes"
+
+    DB_NB_DETACH="yes"
+    DB_SB_DETACH="yes"
 }
 
 set_option () {
@@ -469,6 +478,8 @@  File location options:
   --db-sb-sync-from-port=ADDR OVN Southbound active db tcp port (default: $DB_SB_SYNC_FROM_PORT)
   --db-sb-sync-from-proto=PROTO OVN Southbound active db transport (default: $DB_SB_SYNC_FROM_PROTO)
   --db-sb-create-insecure-remote=yes|no Create ptcp OVN Southbound remote (default: $DB_SB_CREATE_INSECURE_REMOTE)
+  --db-nb-detach=yes|no OVN_Northbound detach server (default: $DB_NB_DETACH)
+  --db-sb-detach=yes|no OVN_Southbound detach server (default: $DB_SB_DETACH)
 
 Default directories with "configure" option and environment variable override:
   logs: /usr/local/var/log/openvswitch (--with-logdir, OVS_LOGDIR)
diff --git a/ovn/utilities/ovn-ctl.8.xml b/ovn/utilities/ovn-ctl.8.xml
index 7b090aee4..457475c19 100644
--- a/ovn/utilities/ovn-ctl.8.xml
+++ b/ovn/utilities/ovn-ctl.8.xml
@@ -28,6 +28,13 @@ 
       <dt><code>demote_ovnsb</code></dt>
       <dt><code>status_ovnnb</code></dt>
       <dt><code>status_ovnsb</code></dt>
+      <dt><code>start_ovsdb</code></dt>
+      <dt><code>start_nb_ovsdb</code></dt>
+      <dt><code>start_sb_ovsdb</code></dt>
+      <dt><code>stop_ovsdb</code></dt>
+      <dt><code>stop_nb_ovsdb</code></dt>
+      <dt><code>stop_sb_ovsdb</code></dt>
+      <dt><code>restart_ovsdb</code></dt>
     </dl>
 
     <h1>Options</h1>
@@ -35,6 +42,8 @@ 
     <p><code>--ovn-northd-wrapper=<var>WRAPPER</var></code></p>
     <p><code>--ovn-controller-priority=<var>NICE</var></code></p>
     <p><code>--ovn-controller-wrapper=<var>WRAPPER</var></code></p>
+    <p><code>--db-nb-detach=<var>yes|no</var></code></p>
+    <p><code>--db-sb-detach=<var>yes|no</var></code></p>
     <p><code>-h</code> | <code>--help</code></p>
 
     <h1>File location options</h1>