diff mbox series

[ovs-dev,07/15] ovn-nbctl: Propagate the error from do_nbctl().

Message ID 20180711192717.21409-8-jkbs@redhat.com
State Superseded
Headers show
Series Daemon mode for ovn-nbctl | expand

Commit Message

Jakub Sitnicki July 11, 2018, 7:27 p.m. UTC
Instead of terminating the process, return the error to the caller.

This will allow us to reuse the main loop in daemon mode.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
---
 ovn/utilities/ovn-nbctl.c | 46 ++++++++++++++++++++++++++++++++--------------
 1 file changed, 32 insertions(+), 14 deletions(-)

Comments

0-day Robot July 11, 2018, 8 p.m. UTC | #1
Bleep bloop.  Greetings Jakub Sitnicki, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


build:
depbase=`echo utilities/ovs-dpctl.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc -std=gnu99 -DHAVE_CONFIG_H -I.    -I ./include -I ./include -I ./lib -I ./lib    -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wshadow    -Werror -MT utilities/ovs-dpctl.o -MD -MP -MF $depbase.Tpo -c -o utilities/ovs-dpctl.o utilities/ovs-dpctl.c &&\
mv -f $depbase.Tpo $depbase.Po
/bin/sh ./libtool  --tag=CC   --mode=link gcc -std=gnu99 -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wshadow    -Werror     -o utilities/ovs-dpctl utilities/ovs-dpctl.o lib/libopenvswitch.la -lpthread -lrt -lm  -lunbound
libtool: link: gcc -std=gnu99 -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wshadow -Werror -o utilities/ovs-dpctl utilities/ovs-dpctl.o  lib/.libs/libopenvswitch.a -lssl -lcrypto -lcap-ng -lpthread -lrt -lm -lunbound
depbase=`echo utilities/ovs-ofctl.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc -std=gnu99 -DHAVE_CONFIG_H -I.    -I ./include -I ./include -I ./lib -I ./lib    -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wshadow    -Werror -MT utilities/ovs-ofctl.o -MD -MP -MF $depbase.Tpo -c -o utilities/ovs-ofctl.o utilities/ovs-ofctl.c &&\
mv -f $depbase.Tpo $depbase.Po
/bin/sh ./libtool  --tag=CC   --mode=link gcc -std=gnu99 -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wshadow    -Werror     -o utilities/ovs-ofctl utilities/ovs-ofctl.o ofproto/libofproto.la lib/libopenvswitch.la -lpthread -lrt -lm  -lunbound
libtool: link: gcc -std=gnu99 -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wshadow -Werror -o utilities/ovs-ofctl utilities/ovs-ofctl.o  ofproto/.libs/libofproto.a /var/lib/jenkins/jobs/upstream_build_from_pw/workspace/lib/.libs/libsflow.a lib/.libs/libopenvswitch.a -lssl -lcrypto -lcap-ng -lpthread -lrt -lm -lunbound
depbase=`echo utilities/ovs-vsctl.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
gcc -std=gnu99 -DHAVE_CONFIG_H -I.    -I ./include -I ./include -I ./lib -I ./lib    -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wshadow    -Werror -MT utilities/ovs-vsctl.o -MD -MP -MF $depbase.Tpo -c -o utilities/ovs-vsctl.o utilities/ovs-vsctl.c &&\
mv -f $depbase.Tpo $depbase.Po
In file included from utilities/ovs-vsctl.c:49:0:
./lib/table.h:86:13: error: initializer element is not constant
     (struct table_style) { TF_LIST, CF_STRING, true, JSSF_SORT, 0 }
             ^
utilities/ovs-vsctl.c:85:41: note: in expansion of macro ‘TABLE_STYLE_DEFAULT’
 static struct table_style table_style = TABLE_STYLE_DEFAULT;
                                         ^
make[2]: *** [utilities/ovs-vsctl.o] Error 1
make[2]: Leaving directory `/var/lib/jenkins/jobs/upstream_build_from_pw/workspace'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/var/lib/jenkins/jobs/upstream_build_from_pw/workspace'
make: *** [all] Error 2


Please check this out.  If you feel there has been an error, please email aconole@bytheb.org

Thanks,
0-day Robot
diff mbox series

Patch

diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index 360b25a89..6e136e1d0 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -84,8 +84,9 @@  OVS_NO_RETURN static void usage(void);
 static void parse_options(int argc, char *argv[], struct shash *local_options);
 static void run_prerequisites(struct ctl_command[], size_t n_commands,
                               struct ovsdb_idl *);
-static void do_nbctl(const char *args, struct ctl_command *, size_t n,
-                     struct ovsdb_idl *, bool *retry);
+static char * OVS_WARN_UNUSED_RESULT do_nbctl(const char *args,
+                                              struct ctl_command *, size_t n,
+                                              struct ovsdb_idl *, bool *retry);
 static const struct nbrec_dhcp_options *dhcp_options_get(
     struct ctl_context *ctx, const char *id, bool must_exist);
 static void main_loop(const char *args, struct ctl_command *commands,
@@ -166,7 +167,10 @@  main_loop(const char *args, struct ctl_command *commands, size_t n_commands,
             seqno = ovsdb_idl_get_seqno(idl);
 
             bool retry;
-            do_nbctl(args, commands, n_commands, idl, &retry);
+            char *error = do_nbctl(args, commands, n_commands, idl, &retry);
+            if (error) {
+                ctl_fatal("%s", error);
+            }
             if (!retry) {
                 return;
             }
@@ -4137,7 +4141,7 @@  run_prerequisites(struct ctl_command *commands, size_t n_commands,
     }
 }
 
-static void
+static char *
 do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands,
          struct ovsdb_idl *idl, bool *retry)
 {
@@ -4148,6 +4152,7 @@  do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands,
     struct ctl_command *c;
     struct shash_node *node;
     int64_t next_cfg = 0;
+    char *error = NULL;
 
     ovs_assert(retry);
 
@@ -4181,7 +4186,9 @@  do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands,
             (c->syntax->run)(&ctx);
         }
         if (ctx.error) {
-            ctl_fatal("%s", ctx.error);
+            error = xstrdup(ctx.error);
+            ctl_context_done(&ctx, c);
+            goto out_error;
         }
         ctl_context_done_command(&ctx, c);
 
@@ -4195,9 +4202,10 @@  do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands,
     SHASH_FOR_EACH (node, &symtab->sh) {
         struct ovsdb_symbol *symbol = node->data;
         if (!symbol->created) {
-            ctl_fatal("row id \"%s\" is referenced but never created (e.g. "
-                      "with \"-- --id=%s create ...\")",
-                      node->name, node->name);
+            error = xasprintf("row id \"%s\" is referenced but never created "
+                              "(e.g. with \"-- --id=%s create ...\")",
+                              node->name, node->name);
+            goto out_error;
         }
         if (!symbol->strong_ref) {
             if (!symbol->weak_ref) {
@@ -4222,7 +4230,9 @@  do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands,
                 ctl_context_init(&ctx, c, idl, txn, symtab, NULL);
                 (c->syntax->postprocess)(&ctx);
                 if (ctx.error) {
-                    ctl_fatal("%s", ctx.error);
+                    error = xstrdup(ctx.error);
+                    ctl_context_done(&ctx, c);
+                    goto out_error;
                 }
                 ctl_context_done(&ctx, c);
             }
@@ -4236,7 +4246,8 @@  do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands,
 
     case TXN_ABORTED:
         /* Should not happen--we never call ovsdb_idl_txn_abort(). */
-        ctl_fatal("transaction aborted");
+        error = xstrdup("transaction aborted");
+        goto out_error;
 
     case TXN_UNCHANGED:
     case TXN_SUCCESS:
@@ -4246,11 +4257,14 @@  do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands,
         goto try_again;
 
     case TXN_ERROR:
-        ctl_fatal("transaction error: %s", ovsdb_idl_txn_get_error(txn));
+        error = xasprintf("transaction error: %s",
+                          ovsdb_idl_txn_get_error(txn));
+        goto out_error;
 
     case TXN_NOT_LOCKED:
         /* Should not happen--we never call ovsdb_idl_set_lock(). */
-        ctl_fatal("database not locked");
+        error = xstrdup("database not locked");
+        goto out_error;
 
     default:
         OVS_NOT_REACHED();
@@ -4309,11 +4323,14 @@  do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands,
     ovsdb_idl_txn_destroy(txn);
 
     *retry = false;
-    return;
+    return NULL;
 
 try_again:
     /* Our transaction needs to be rerun, or a prerequisite was not met.  Free
      * resources and return so that the caller can try again. */
+    *retry = true;
+
+out_error:
     ovsdb_idl_txn_abort(txn);
     ovsdb_idl_txn_destroy(txn);
     the_idl_txn = NULL;
@@ -4324,7 +4341,8 @@  do_nbctl(const char *args, struct ctl_command *commands, size_t n_commands,
         table_destroy(c->table);
         free(c->table);
     }
-    *retry = true;
+
+    return error;
 }
 
 /* Frees the current transaction and the underlying IDL and then calls