log/rpc: Add logs with more information about rpc error.

Now if rpc fails ambiguous logs are printed.
Use more descriptive errors.

Change-Id: I0c2abff2f0264ca110e3cd37e39aa710f29d973b
Signed-off-by: Pawel Kaminski <pawelx.kaminski@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/462595
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Vitaliy Mysak <vitaliy.mysak@intel.com>
Reviewed-by: Karol Latecki <karol.latecki@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Pawel Kaminski 2019-07-19 04:26:45 -04:00 committed by Jim Harris
parent b8919745c5
commit 0140c62b1e

View File

@ -109,12 +109,16 @@ spdk_rpc_set_log_print_level(struct spdk_jsonrpc_request *request,
if (spdk_json_decode_object(params, rpc_log_level_decoders,
SPDK_COUNTOF(rpc_log_level_decoders), &req)) {
SPDK_DEBUGLOG(SPDK_LOG_LOG, "spdk_json_decode_object failed\n");
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
"spdk_json_decode_object failed");
goto invalid;
}
level = _parse_log_level(req.level);
if (level == -1) {
SPDK_DEBUGLOG(SPDK_LOG_LOG, "try to set invalid log level\n");
SPDK_DEBUGLOG(SPDK_LOG_LOG, "tried to set invalid log level\n");
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
"invalid log level");
goto invalid;
}
@ -127,7 +131,6 @@ spdk_rpc_set_log_print_level(struct spdk_jsonrpc_request *request,
return;
invalid:
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
free_rpc_log_level(&req);
}
SPDK_RPC_REGISTER("set_log_print_level", spdk_rpc_set_log_print_level,
@ -151,7 +154,7 @@ spdk_rpc_get_log_print_level(struct spdk_jsonrpc_request *request,
name = _get_log_level_name(level);
if (name == NULL) {
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
"Internal error");
"invalid log level");
return;
}
@ -174,12 +177,16 @@ spdk_rpc_set_log_level(struct spdk_jsonrpc_request *request,
if (spdk_json_decode_object(params, rpc_log_level_decoders,
SPDK_COUNTOF(rpc_log_level_decoders), &req)) {
SPDK_DEBUGLOG(SPDK_LOG_LOG, "spdk_json_decode_object failed\n");
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
"spdk_json_decode_object failed");
goto invalid;
}
level = _parse_log_level(req.level);
if (level == -1) {
SPDK_DEBUGLOG(SPDK_LOG_LOG, "try to set invalid log level\n");
SPDK_DEBUGLOG(SPDK_LOG_LOG, "tried to set invalid log level\n");
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
"invalid log level");
goto invalid;
}
@ -193,7 +200,6 @@ spdk_rpc_set_log_level(struct spdk_jsonrpc_request *request,
return;
invalid:
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
free_rpc_log_level(&req);
}
SPDK_RPC_REGISTER("set_log_level", spdk_rpc_set_log_level, SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)
@ -216,7 +222,7 @@ spdk_rpc_get_log_level(struct spdk_jsonrpc_request *request,
name = _get_log_level_name(level);
if (name == NULL) {
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
"Internal error");
"invalid log level");
return;
}
@ -237,11 +243,15 @@ spdk_rpc_set_log_flag(struct spdk_jsonrpc_request *request,
if (spdk_json_decode_object(params, rpc_log_flag_decoders,
SPDK_COUNTOF(rpc_log_flag_decoders), &req)) {
SPDK_DEBUGLOG(SPDK_LOG_LOG, "spdk_json_decode_object failed\n");
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
"spdk_json_decode_object failed");
goto invalid;
}
if (req.flag == 0) {
SPDK_DEBUGLOG(SPDK_LOG_LOG, "flag was 0\n");
SPDK_DEBUGLOG(SPDK_LOG_LOG, "invalid flag 0\n");
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
"invalid flag 0");
goto invalid;
}
@ -254,7 +264,6 @@ spdk_rpc_set_log_flag(struct spdk_jsonrpc_request *request,
return;
invalid:
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
free_rpc_log_flag(&req);
}
SPDK_RPC_REGISTER("set_log_flag", spdk_rpc_set_log_flag, SPDK_RPC_STARTUP | SPDK_RPC_RUNTIME)
@ -270,11 +279,15 @@ spdk_rpc_clear_log_flag(struct spdk_jsonrpc_request *request,
if (spdk_json_decode_object(params, rpc_log_flag_decoders,
SPDK_COUNTOF(rpc_log_flag_decoders), &req)) {
SPDK_DEBUGLOG(SPDK_LOG_LOG, "spdk_json_decode_object failed\n");
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
"spdk_json_decode_object failed");
goto invalid;
}
if (req.flag == 0) {
SPDK_DEBUGLOG(SPDK_LOG_LOG, "flag was 0\n");
SPDK_DEBUGLOG(SPDK_LOG_LOG, "Invalid flag 0\n");
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
"invalid flag 0");
goto invalid;
}
@ -287,7 +300,6 @@ spdk_rpc_clear_log_flag(struct spdk_jsonrpc_request *request,
return;
invalid:
spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS, "Invalid parameters");
free_rpc_log_flag(&req);
}
SPDK_RPC_REGISTER("clear_log_flag", spdk_rpc_clear_log_flag,