diff mbox series

[ovs-dev,21/30] ovn-nbctl: Don't die in nbctl_lr_add().

Message ID 20180707111004.8320-22-jkbs@redhat.com
State Accepted
Headers show
Series Get rid of ctl_fatal() calls in ovn-nbctl (part 1) | expand

Commit Message

Jakub Sitnicki July 7, 2018, 11:09 a.m. UTC
Propagate the error via the context instead.

Signed-off-by: Jakub Sitnicki <jkbs@redhat.com>
---
 ovn/utilities/ovn-nbctl.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index 989633120..f97bfbb3e 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -2566,7 +2566,9 @@  nbctl_lr_add(struct ctl_context *ctx)
     bool may_exist = shash_find(&ctx->options, "--may-exist") != NULL;
     bool add_duplicate = shash_find(&ctx->options, "--add-duplicate") != NULL;
     if (may_exist && add_duplicate) {
-        ctl_fatal("--may-exist and --add-duplicate may not be used together");
+        ctl_error(ctx, "--may-exist and --add-duplicate may not be used "
+                  "together");
+        return;
     }
 
     if (lr_name) {
@@ -2577,15 +2579,18 @@  nbctl_lr_add(struct ctl_context *ctx)
                     if (may_exist) {
                         return;
                     }
-                    ctl_fatal("%s: a router with this name already exists",
-                              lr_name);
+                    ctl_error(ctx, "%s: a router with this name already "
+                              "exists", lr_name);
+                    return;
                 }
             }
         }
     } else if (may_exist) {
-        ctl_fatal("--may-exist requires specifying a name");
+        ctl_error(ctx, "--may-exist requires specifying a name");
+        return;
     } else if (add_duplicate) {
-        ctl_fatal("--add-duplicate requires specifying a name");
+        ctl_error(ctx, "--add-duplicate requires specifying a name");
+        return;
     }
 
     struct nbrec_logical_router *lr;