From 244cd8fe214c2d77761942cbf2277e4939a8272d Mon Sep 17 00:00:00 2001 From: Pranith Kumar K Date: Sat, 24 Jun 2017 11:55:56 +0530 Subject: Show error message when response contains failure Change-Id: If7a232e4a1d550b3912402282c21d0d033aa00d2 Signed-off-by: Pranith Kumar K --- rpc/block_svc_routines.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/rpc/block_svc_routines.c b/rpc/block_svc_routines.c index ca39702..c26b2b3 100644 --- a/rpc/block_svc_routines.c +++ b/rpc/block_svc_routines.c @@ -508,6 +508,9 @@ glusterBlockCreateRemote(void *data) "host %s volume %s", strerror(errno), FAILED_REMOTE_CREATE, cobj.block_name, args->addr, args->volume); goto out; + } else if (args->reply) { + errMsg = args->reply; + args->reply = NULL; } if (isRetValueDependencyError(ret)) { @@ -635,6 +638,9 @@ glusterBlockDeleteRemote(void *data) "host %s volume %s", strerror(errno), FAILED_REMOTE_DELETE, dobj.block_name, args->addr, args->volume); goto out; + } else if (args->reply) { + errMsg = args->reply; + args->reply = NULL; } if (isRetValueDependencyError(ret)) { @@ -853,6 +859,9 @@ glusterBlockModifyRemote(void *data) "host %s volume %s", strerror(errno), FAILED_REMOTE_MODIFY, cobj.block_name, args->addr, args->volume); goto out; + } else if (args->reply) { + errMsg = args->reply; + args->reply = NULL; } if (isRetValueDependencyError(ret)) { @@ -1249,8 +1258,13 @@ blockStr2arrayAddToJsonObj (json_object *json_obj, char *string, char *label, static void -blockFormatDependencyErrors(int errCode, char **errMsg) +blockFormatDependencyErrors(int errCode, char **errMsg, char *reply_errMsg) { + if (isRetValueDependencyError(errCode) && reply_errMsg) { + GB_STRDUP(*errMsg, reply_errMsg); + return; + } + if (errCode == ESRCH) { GB_ASPRINTF(errMsg, "tcmu-runner is not running in few nodes"); } else if (errCode == ENODEV) { @@ -1511,7 +1525,7 @@ block_modify_cli_1_svc(blockModifyCli *blk, struct svc_req *rqstp) ret = 0; out: - blockFormatDependencyErrors(errCode, &errMsg); + blockFormatDependencyErrors(errCode, &errMsg, NULL); GB_METAUNLOCK(lkfd, blk->volume, ret, errMsg); @@ -1839,7 +1853,8 @@ block_create_cli_1_svc(blockCreateCli *blk, struct svc_req *rqstp) } exist: - blockFormatDependencyErrors(errCode, &errMsg); + blockFormatDependencyErrors(errCode, &errMsg, + savereply?savereply->errMsg:NULL); GB_METAUNLOCK(lkfd, blk->volume, errCode, errMsg); out: @@ -2217,7 +2232,7 @@ block_delete_cli_1_svc(blockDeleteCli *blk, struct svc_req *rqstp) } out: - blockFormatDependencyErrors(errCode, &errMsg); + blockFormatDependencyErrors(errCode, &errMsg, NULL); GB_METAUNLOCK(lkfd, blk->volume, errCode, errMsg); -- cgit