diff mbox series

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

Message ID 20180707111004.8320-21-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 | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/ovn/utilities/ovn-nbctl.c b/ovn/utilities/ovn-nbctl.c
index 16788cc43..989633120 100644
--- a/ovn/utilities/ovn-nbctl.c
+++ b/ovn/utilities/ovn-nbctl.c
@@ -2324,11 +2324,13 @@  nbctl_lr_lb_add(struct ctl_context *ctx)
 
     char *error = lr_by_name_or_uuid(ctx, ctx->argv[1], true, &lr);
     if (error) {
-        ctl_fatal("%s", error);
+        ctx->error = error;
+        return;
     }
     error = lb_by_name_or_uuid(ctx, ctx->argv[2], true, &new_lb);
     if (error) {
-        ctl_fatal("%s", error);
+        ctx->error = error;
+        return;
     }
 
     bool may_exist = shash_find(&ctx->options, "--may-exist") != NULL;
@@ -2340,8 +2342,9 @@  nbctl_lr_lb_add(struct ctl_context *ctx)
             if (may_exist) {
                 return;
             }
-            ctl_fatal(UUID_FMT " : a load balancer with this UUID already "
-                    "exists", UUID_ARGS(&lb->header_.uuid));
+            ctl_error(ctx, UUID_FMT " : a load balancer with this UUID "
+                      "already exists", UUID_ARGS(&lb->header_.uuid));
+            return;
         }
     }