summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2017-05-05 15:11:24 +0530
committerPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2017-05-05 16:09:30 +0530
commit1dbbd7d457251afd1f005bf262b5c366642535e2 (patch)
tree232fbe0301bccbe8a8d42fd6589b24403319fe00
parenta31ee2d59d59c74e2a1b91dc40cd12b7c918a45c (diff)
cli: increase the clnt_call() total time out.
The connect() in daemon takes too long to return for invalid IP addresses, the delay is much higher that the CLI RPC Timeout, hence the CLI returns before the daemon returns. Hence SIGPIPE is issued. The issue can be fixed by increasing the CLI RPC clnt_call() TIMEOUT. This should actually be handled like: struct timeval tv; CLIENT *cl; cl=clnt_create("somehost", SOMEPROG, SOMEVERS, "tcp"); if (cl=NULL) { exit(1); } tv.tv_sec=60; /* change timeout to 1 minute */ tv.tv_usec=0; clnt_control(cl, CLSET_TIMEOUT, &tv); But currently there is a bug in sun RPC which ignores TIMEOUT set using cln_control. See [1] Hence using regex to override default TIMEOUT generated in rpc code. [1] https://lists.gnu.org/archive/html/bug-glibc/2000-10/msg00095.html Change-Id: I75eceea6b9f362f8bf8c2fcb687155635efc65d7 Fixes: #15 Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
-rw-r--r--rpc/block_svc_routines.c82
-rw-r--r--rpc/rpcl/Makefile.am1
2 files changed, 61 insertions, 22 deletions
diff --git a/rpc/block_svc_routines.c b/rpc/block_svc_routines.c
index 4a1a3e6..728c86a 100644
--- a/rpc/block_svc_routines.c
+++ b/rpc/block_svc_routines.c
@@ -478,14 +478,14 @@ glusterBlockCreateRemote(void *data)
saveret = ret;
if (errno == ENETUNREACH || errno == ECONNREFUSED || errno == ETIMEDOUT) {
GB_ASPRINTF(&errMsg, ": %s", strerror(errno));
- LOG("mgmt", GB_LOG_ERROR, "%s hence %s for block %s on"
+ LOG("mgmt", GB_LOG_ERROR, "%s hence %s for block %s on "
"host %s volume %s", strerror(errno), FAILED_REMOTE_CREATE,
cobj.block_name, args->addr, args->volume);
goto out;
}
if (ret == EKEYEXPIRED) {
- LOG("mgmt", GB_LOG_ERROR, "%s [%s] hence create block %s on"
+ LOG("mgmt", GB_LOG_ERROR, "%s [%s] hence create block %s on "
"host %s volume %s failed", FAILED_DEPENDENCY, strerror(errno),
cobj.block_name, args->addr, args->volume);
goto out;
@@ -601,14 +601,14 @@ glusterBlockDeleteRemote(void *data)
if (ret) {
saveret = ret;
if (errno == ENETUNREACH || errno == ECONNREFUSED || errno == ETIMEDOUT) {
- LOG("mgmt", GB_LOG_ERROR, "%s hence %s for block %s on"
+ LOG("mgmt", GB_LOG_ERROR, "%s hence %s for block %s on "
"host %s volume %s", strerror(errno), FAILED_REMOTE_DELETE,
dobj.block_name, args->addr, args->volume);
goto out;
}
if (ret == EKEYEXPIRED) {
- LOG("mgmt", GB_LOG_ERROR, "%s [%s] hence delete block %s on"
+ LOG("mgmt", GB_LOG_ERROR, "%s [%s] hence delete block %s on "
"host %s volume %s failed", FAILED_DEPENDENCY, strerror(errno),
dobj.block_name, args->addr, args->volume);
goto out;
@@ -657,7 +657,7 @@ glusterBlockDeleteFillArgs(MetaInfo *info, bool deleteall, blockRemoteObj *args,
case GB_AUTH_CLEAR_ENFORCE_FAIL:
if (!deleteall)
break;
- case GB_CONFIG_INPROGRESS:
+ /* case GB_CONFIG_INPROGRESS: untouched may be due to connect failed */
case GB_CONFIG_FAIL:
case GB_CLEANUP_INPROGRESS:
case GB_CLEANUP_FAIL:
@@ -676,7 +676,8 @@ glusterBlockDeleteFillArgs(MetaInfo *info, bool deleteall, blockRemoteObj *args,
static int
-glusterBlockCollectAttemptSuccess(blockRemoteObj *args, size_t count,
+glusterBlockCollectAttemptSuccess(struct glfs *glfs, char *blockname,
+ blockRemoteObj *args, size_t count,
char **attempt, char **success)
{
char *a_tmp = NULL;
@@ -686,21 +687,23 @@ glusterBlockCollectAttemptSuccess(blockRemoteObj *args, size_t count,
for (i = 0; i < count; i++) {
if (args[i].exit) {
if (GB_ASPRINTF(attempt, "%s %s",
- (a_tmp==NULL?"":a_tmp), args[i].addr) == -1) {
+ (a_tmp==NULL?"":a_tmp), args[i].addr) == -1) {
goto fail;
}
GB_FREE(a_tmp);
a_tmp = *attempt;
} else {
if (GB_ASPRINTF(success, "%s %s",
- (s_tmp==NULL?"":s_tmp), args[i].addr) == -1) {
+ (s_tmp==NULL?"":s_tmp), args[i].addr) == -1) {
goto fail;
}
GB_FREE(s_tmp);
s_tmp = *success;
}
}
+
return 0;
+
fail:
GB_FREE(a_tmp);
GB_FREE(s_tmp);
@@ -747,9 +750,10 @@ glusterBlockDeleteRemoteAsync(MetaInfo *info,
pthread_join(tid[i], NULL);
}
- ret = glusterBlockCollectAttemptSuccess (args, count, &d_attempt, &d_success);
+ ret = glusterBlockCollectAttemptSuccess (glfs, dobj->block_name, args,
+ count, &d_attempt, &d_success);
if (ret) {
- goto out;
+ goto out;
}
if (d_attempt) {
@@ -812,14 +816,14 @@ glusterBlockModifyRemote(void *data)
if (ret) {
saveret = ret;
if (errno == ENETUNREACH || errno == ECONNREFUSED || errno == ETIMEDOUT) {
- LOG("mgmt", GB_LOG_ERROR, "%s hence %s for block %s on"
+ LOG("mgmt", GB_LOG_ERROR, "%s hence %s for block %s on "
"host %s volume %s", strerror(errno), FAILED_REMOTE_MODIFY,
cobj.block_name, args->addr, args->volume);
goto out;
}
if (ret == EKEYEXPIRED) {
- LOG("mgmt", GB_LOG_ERROR, "%s [%s] hence modify block %s on"
+ LOG("mgmt", GB_LOG_ERROR, "%s [%s] hence modify block %s on "
"host %s volume %s failed", FAILED_DEPENDENCY, strerror(errno),
cobj.block_name, args->addr, args->volume);
goto out;
@@ -934,15 +938,16 @@ glusterBlockModifyRemoteAsync(MetaInfo *info,
if (!rollback) {
/* collect return */
- ret = glusterBlockCollectAttemptSuccess (args, count, &local->attempt,
- &local->success);
+ ret = glusterBlockCollectAttemptSuccess(glfs, mobj->block_name,
+ args, count, &local->attempt,
+ &local->success);
if (ret)
goto out;
} else {
/* collect return */
- ret = glusterBlockCollectAttemptSuccess (args, count,
- &local->rb_attempt,
- &local->rb_success);
+ ret = glusterBlockCollectAttemptSuccess(glfs, mobj->block_name, args,
+ count, &local->rb_attempt,
+ &local->rb_success);
if (ret)
goto out;
}
@@ -1007,7 +1012,7 @@ glusterBlockCleanUp(operations opt, struct glfs *glfs, char *blockname,
count = glusterBlockDeleteFillArgs(info, deleteall, NULL, NULL, NULL);
asyncret = glusterBlockDeleteRemoteAsync(info, glfs, &dobj, count,
- deleteall, &drobj);
+ deleteall, &drobj);
if (asyncret) {
LOG("mgmt", GB_LOG_WARNING,
"glusterBlockDeleteRemoteAsync: return %d %s for block %s on volume %s",
@@ -1177,6 +1182,12 @@ blockFormatErrorResponse (operations op, int json_resp, int errCode,
char *errMsg, struct blockResponse *reply)
{
json_object *json_obj = NULL;
+
+
+ if (!reply) {
+ return;
+ }
+
reply->exit = errCode;
if (json_resp) {
json_obj = json_object_new_object();
@@ -1486,11 +1497,12 @@ block_modify_cli_1_svc(blockModifyCli *blk, struct svc_req *rqstp)
}
void
-blockCreateCliFormatResponse(blockCreateCli *blk, struct blockCreate *cobj,
- int errCode, char *errMsg,
- blockRemoteCreateResp *savereply,
+blockCreateCliFormatResponse(struct glfs *glfs, blockCreateCli *blk,
+ struct blockCreate *cobj, int errCode,
+ char *errMsg, blockRemoteCreateResp *savereply,
struct blockResponse *reply)
{
+ MetaInfo *info = NULL;
json_object *json_obj = NULL;
json_object *json_array1 = NULL;
json_object *json_array2 = NULL;
@@ -1499,6 +1511,7 @@ blockCreateCliFormatResponse(blockCreateCli *blk, struct blockCreate *cobj,
char *portals = NULL;
int i = 0;
+
if (!reply) {
return;
}
@@ -1513,6 +1526,26 @@ blockCreateCliFormatResponse(blockCreateCli *blk, struct blockCreate *cobj,
return;
}
+ if (GB_ALLOC(info) < 0) {
+ return;
+ }
+
+ if (blockGetMetaInfo(glfs, blk->block_name, info, NULL)) {
+ goto out;
+ }
+
+ for (i = 0; i < info->nhosts; i++) {
+ tmp = savereply->obj->d_attempt;
+ if (blockMetaStatusEnumParse(info->list[i]->status) == GB_CONFIG_INPROGRESS) {
+ if (GB_ASPRINTF(&savereply->obj->d_attempt, "%s %s",
+ (tmp==NULL?"":tmp), info->list[i]->addr) == -1) {
+ goto out;
+ }
+ GB_FREE(tmp);
+ }
+ }
+ tmp = NULL;
+
if (savereply->obj->d_success || savereply->obj->d_attempt) {
removeDuplicateSubstr(&savereply->obj->d_success);
removeDuplicateSubstr(&savereply->obj->d_attempt);
@@ -1605,6 +1638,7 @@ blockCreateCliFormatResponse(blockCreateCli *blk, struct blockCreate *cobj,
}
out:
+ blockFreeMetaInfo(info);
GB_FREE(tmp);
GB_FREE(tmp2);
return;
@@ -1759,7 +1793,7 @@ block_create_cli_1_svc(blockCreateCli *blk, struct svc_req *rqstp)
}
optfail:
- blockCreateCliFormatResponse(blk, &cobj, errCode, errMsg, savereply, reply);
+ blockCreateCliFormatResponse(glfs, blk, &cobj, errCode, errMsg, savereply, reply);
GB_FREE(errMsg);
blockServerDefFree(list);
glfs_fini(glfs);
@@ -2502,6 +2536,10 @@ blockInfoCliFormatResponse(blockInfoCli *blk, int errCode,
return;
}
+ if (!info) {
+ return;
+ }
+
if (blk->json_resp) {
json_obj = json_object_new_object();
json_object_object_add(json_obj, "NAME", GB_JSON_OBJ_TO_STR(blk->block_name));
diff --git a/rpc/rpcl/Makefile.am b/rpc/rpcl/Makefile.am
index 3aa6f0d..8a8ada4 100644
--- a/rpc/rpcl/Makefile.am
+++ b/rpc/rpcl/Makefile.am
@@ -17,6 +17,7 @@ block_xdr.c: block.x
block_clnt.c: block.x
rpcgen -l -o $(top_builddir)/rpc/rpcl/$@ $^
+ $(SED) -i 's|TIMEOUT = { 25, 0 }|TIMEOUT = { 300, 0 }|' $(top_builddir)/rpc/rpcl/$@
block_svc.c: block.x
rpcgen -m -o $(top_builddir)/rpc/rpcl/$@ $^