ovn-nbctl: Propagate errors from prerequisites runner.
Instead of terminating the process, return the error to the caller.
This will allow us to reuse the prerequisites runner in daemon mode.
@@ -82,7 +82,8 @@ static int leader_only = true;
static void nbctl_cmd_init(void);
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,
+static char * OVS_WARN_UNUSED_RESULT run_prerequisites(struct ctl_command[],
+ size_t n_commands,
struct ovsdb_idl *);
static char * OVS_WARN_UNUSED_RESULT do_nbctl(const char *args,
struct ctl_command *, size_t n,
@@ -129,7 +130,10 @@ main(int argc, char *argv[])
/* Initialize IDL. */
idl = the_idl = ovsdb_idl_create(db, &nbrec_idl_class, true, false);
ovsdb_idl_set_leader_only(idl, leader_only);
- run_prerequisites(commands, n_commands, idl);
+ error = run_prerequisites(commands, n_commands, idl);
+ if (error) {
+ ctl_fatal("%s", error);
+ }
error = main_loop(args, commands, n_commands, idl);
if (error) {
@@ -4271,7 +4275,7 @@ static const struct ctl_table_class tables[NBREC_N_TABLES] = {
[NBREC_TABLE_ACL].row_ids[0] = {&nbrec_acl_col_name, NULL, NULL},
};
-static void
+static char *
run_prerequisites(struct ctl_command *commands, size_t n_commands,
struct ovsdb_idl *idl)
{
@@ -4292,7 +4296,9 @@ run_prerequisites(struct ctl_command *commands, size_t n_commands,
ctl_context_init(&ctx, c, idl, NULL, NULL, NULL);
(c->syntax->prerequisites)(&ctx);
if (ctx.error) {
- ctl_fatal("%s", ctx.error);
+ char *error = xstrdup(ctx.error);
+ ctl_context_done(&ctx, c);
+ return error;
}
ctl_context_done(&ctx, c);
@@ -4300,6 +4306,8 @@ run_prerequisites(struct ctl_command *commands, size_t n_commands,
ovs_assert(!c->table);
}
}
+
+ return NULL;
}
static char *
