Message ID | 20180707111004.8320-2-jkbs@redhat.com |
---|---|
State | Accepted |
Headers | show |
Series | Get rid of ctl_fatal() calls in ovn-nbctl (part 1) | expand |
(Reposting the cover letter here while it awaits list moderator's approval. No idea what is triggering the filters.) This series is a follow-up to recent work done in db-ctl-base module [1]. The goal is to avoid using ctl_fatal() that terminates the process on error so that ovn-nbctl, or other db-ctl tools, can run as long-lived processes (such as servers or daemons). First couple of patches are fix-ups for bugs and oversights in the mentioned earlier series [1]. The rest of the patches convert selected helper functions and command handlers in ovn-nbctl to propagate the error instead of calling ctl_fatal(). There are still many more functions in ovn-nbctl left to convert [2]. This first batch targets ones that have their error paths covered by the ovn-nbct test suite (tests/ovn-nbctl.at). Having these functions converted will give us a good testing ground for nbctl daemon changes which I have in working shape [3] and am planning to post soon. Thanks, Jakub [1] https://mail.openvswitch.org/pipermail/ovs-dev/2018-July/348911.html [2] git grep -W ctl_fatal ovn/utilities/ovn-nbctl.c \ | grep 'ovn/utilities/ovn-nbctl.c=' \ | perl -n -e '/=([^(]+)\(/ and print $1, "\n";' [3] https://github.com/jsitnicki/ovs/commits/wip-nbctl-daemon Jakub Sitnicki (30): db-ctl-base: Don't die in cmd_add() on error. ovn-nbctl: Report the actual error from the command handler. ovn-nbctl: Don't die in ls_by_name_or_uuid(). ovn-nbctl: Don't die in lsp_by_name_or_uuid(). ovn-nbctl: Don't die in lb_by_name_or_uuid() ovn-nbctl: Don't die in lr_by_name_or_uuid(). ovn-nbctl: Don't die in lrp_by_name_or_uuid(). ovn-nbctl: Don't die in acl_cmd_get_pg_or_ls(). ovn-nbctl: Don't die in parse_enabled(). ovn-nbctl: Don't die in nbctl_ls_add(). ovn-nbctl: Don't die in nbctl_ls_del(). ovn-nbctl: Don't die in nbctl_lsp_add(). ovn-nbctl: Don't die in nbctl_acl(). ovn-nbctl: Don't die in nbctl_qos_add(). ovn-nbctl: Don't die in nbctl_lr_nat_add(). ovn-nbctl: Don't die in nbctl_lr_nat_del(). ovn-nbctl: Don't die in nbctl_lb_add(). ovn-nbctl: Don't die in nbctl_lb_del() ovn-nbctl: Don't die in nbctl_ls_lb_add(). ovn-nbctl: Don't die in nbctl_lr_lb_add(). ovn-nbctl: Don't die in nbctl_lr_add(). ovn-nbctl: Don't die in nbctl_lr_del(). ovn-nbctl: Don't die in nbctl_lrp_add(). ovn-nbctl: Don't die in nbctl_lrp_set_gateway_chassis(). ovn-nbctl: Don't die in nbctl_lrp_get_gateway_chassis(). ovn-nbctl: Don't die in nbctl_lrp_del_gateway_chassis(). ovn-nbctl: Don't die in nbctl_lrp_set_enabled(). ovn-nbctl: Don't die in nbctl_lr_route_add(). ovn-nbctl: Don't die in nbctl_lr_route_del(). ovn-nbctl: Don't die in nbctl_lsp_set_type(). lib/db-ctl-base.c | 3 +- ovn/utilities/ovn-nbctl.c | 731 +++++++++++++++++++++++++++++++++------------- 2 files changed, 525 insertions(+), 209 deletions(-)
diff --git a/lib/db-ctl-base.c b/lib/db-ctl-base.c index a59ac30c4..0aba5b6a3 100644 --- a/lib/db-ctl-base.c +++ b/lib/db-ctl-base.c @@ -1494,11 +1494,12 @@ cmd_add(struct ctl_context *ctx) ovsdb_datum_destroy(&add, type); } if (old.n > type->n_max) { - ctl_fatal("\"add\" operation would put %u %s in column %s of " + ctl_error(ctx, "\"add\" operation would put %u %s in column %s of " "table %s but the maximum number is %u", old.n, type->value.type == OVSDB_TYPE_VOID ? "values" : "pairs", column->name, table->name, type->n_max); + return; } ovsdb_idl_txn_verify(row, column); ovsdb_idl_txn_write(row, column, &old);
Return the error via the context instead of calling ctl_fatal() so that the caller can decide how to handle it. Signed-off-by: Jakub Sitnicki <jkbs@redhat.com> --- lib/db-ctl-base.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)