diff mbox

[ovs-dev,v2] ovn: Initialize the databases.

Message ID 1474282375-20507-1-git-send-email-guru@ovn.org
State Accepted
Headers show

Commit Message

Gurucharan Shetty Sept. 19, 2016, 10:52 a.m. UTC
Without initializing the databases, commands of the form
'ovn-nbctl --wait=sb ls-add ls0' will simply hang.

Signed-off-by: Gurucharan Shetty <guru@ovn.org>
---
 ovn/northd/ovn-northd.c | 10 +++++++---
 ovn/utilities/ovn-ctl   |  2 ++
 2 files changed, 9 insertions(+), 3 deletions(-)

Comments

Ben Pfaff Sept. 22, 2016, 4:54 p.m. UTC | #1
On Mon, Sep 19, 2016 at 03:52:55AM -0700, Gurucharan Shetty wrote:
> Without initializing the databases, commands of the form
> 'ovn-nbctl --wait=sb ls-add ls0' will simply hang.
> 
> Signed-off-by: Gurucharan Shetty <guru@ovn.org>

Thanks!

Acked-by: Ben Pfaff <blp@ovn.org>
Gurucharan Shetty Sept. 23, 2016, 6:41 p.m. UTC | #2
On 22 September 2016 at 09:54, Ben Pfaff <blp@ovn.org> wrote:

> On Mon, Sep 19, 2016 at 03:52:55AM -0700, Gurucharan Shetty wrote:
> > Without initializing the databases, commands of the form
> > 'ovn-nbctl --wait=sb ls-add ls0' will simply hang.
> >
> > Signed-off-by: Gurucharan Shetty <guru@ovn.org>
>
> Thanks!
>
> Acked-by: Ben Pfaff <blp@ovn.org>
>

Thanks, I applied this to master and 2.6
diff mbox

Patch

diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index a91e1f8..a30b4b4 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -4263,11 +4263,15 @@  ovnnb_db_run(struct northd_context *ctx, struct ovsdb_idl_loop *sb_loop)
      *
      * Also set up to update sb_cfg once our southbound transaction commits. */
     const struct nbrec_nb_global *nb = nbrec_nb_global_first(ctx->ovnnb_idl);
+    if (!nb) {
+        nb = nbrec_nb_global_insert(ctx->ovnnb_txn);
+    }
     const struct sbrec_sb_global *sb = sbrec_sb_global_first(ctx->ovnsb_idl);
-    if (nb && sb) {
-        sbrec_sb_global_set_nb_cfg(sb, nb->nb_cfg);
-        sb_loop->next_cfg = nb->nb_cfg;
+    if (!sb) {
+        sb = sbrec_sb_global_insert(ctx->ovnsb_txn);
     }
+    sbrec_sb_global_set_nb_cfg(sb, nb->nb_cfg);
+    sb_loop->next_cfg = nb->nb_cfg;
 
     cleanup_macam(&macam);
 }
diff --git a/ovn/utilities/ovn-ctl b/ovn/utilities/ovn-ctl
index 07bff8a..8544d14 100755
--- a/ovn/utilities/ovn-ctl
+++ b/ovn/utilities/ovn-ctl
@@ -55,6 +55,7 @@  start_ovsdb () {
         set "$@" --detach --monitor $OVN_NB_LOG --log-file=$OVN_NB_LOGFILE --remote=punix:$DB_NB_SOCK --remote=ptcp:$DB_NB_PORT:$DB_NB_ADDR --pidfile=$DB_NB_PID --unixctl=ovnnb_db.ctl
 
         $@ $DB_NB_FILE
+        ovn-nbctl init
     fi
 
     # Check and eventually start ovsdb-server for Southbound DB
@@ -65,6 +66,7 @@  start_ovsdb () {
 
         set "$@" --detach --monitor $OVN_SB_LOG --log-file=$OVN_SB_LOGFILE --remote=punix:$DB_SB_SOCK --remote=ptcp:$DB_SB_PORT:$DB_SB_ADDR --pidfile=$DB_SB_PID --unixctl=ovnsb_db.ctl
         $@ $DB_SB_FILE
+        ovn-sbctl init
     fi
 }