[ovs-dev] [RFC] ovsdb-idl: improved error handling for non-existent db

Russell Bryant russell at ovn.org
Wed Jan 27 20:02:11 UTC 2016


On 01/27/2016 02:46 PM, Lance Richardson wrote:
> A common error scenario with OVN is to attempt to use ovn-nbctl when
> the OVN databases have not been created:
>    1. ovn-nbctl sends "get_schema" request for OVN db to ovsdb-server.
>    2. ovsdb-server fails to lookup requested db, sends error response
>       to ovn-nbctl.
>    3. ovn-nbctl received the error response in ovsdb_idl_run(), but
>       takes no specific action in this case.
>    4. ovn-nbctl hangs forever in IDL_S_SCHEMA_REQUESTED state (assuming
>       a timeout wasn't requested on the command line).
> 
> Here is an RFC patch to start the discussion about how handling of this
> particular error can be improved.
> 
> Signed-off-by: Lance Richardson <lrichard at redhat.com>
> ---
>  lib/ovsdb-idl.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
> index 7e84138..3f4be51 100644
> --- a/lib/ovsdb-idl.c
> +++ b/lib/ovsdb-idl.c
> @@ -453,6 +453,16 @@ ovsdb_idl_run(struct ovsdb_idl *idl)
>                  ovsdb_idl_send_monitor_request(idl);
>                  idl->state = IDL_S_MONITOR_REQUESTED;
>              }
> +        } else if (msg->type == JSONRPC_ERROR
> +                   && idl->state == IDL_S_SCHEMA_REQUESTED
> +                   && idl->request_id
> +                   && json_equal(idl->request_id, msg->id)) {
> +                json_destroy(idl->request_id);
> +                idl->request_id = NULL;
> +                VLOG_ERR("%s: requested schema not found",
> +                         jsonrpc_session_get_name(idl->session));
> +                ovsdb_idl_destroy(idl);
> +                exit(EXIT_FAILURE);
>          } else if ((msg->type == JSONRPC_ERROR
>                      || msg->type == JSONRPC_REPLY)
>                     && ovsdb_idl_txn_process_reply(idl, msg)) {
> 

ovsdb_idl_run() doesn't currently return anything.  Maybe it should
return an error in this case?  or is there a better way to know we're in
this state?

My main thought is that the user of the ovsdb_idl API should decide how
to handle this condition.  ovn-nbctl/ovn-sbctl for example can decide
that logging an error and exiting is what makes the most sense, but that
may not always be the case.

-- 
Russell Bryant



More information about the dev mailing list