Skip to content

Commit

Permalink
cli: increase the clnt_call() total time out.
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Prasanna Kumar Kalever committed May 5, 2017
1 parent a31ee2d commit 1dbbd7d
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 22 deletions.
82 changes: 60 additions & 22 deletions rpc/block_svc_routines.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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:
Expand All @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand All @@ -1499,6 +1511,7 @@ blockCreateCliFormatResponse(blockCreateCli *blk, struct blockCreate *cobj,
char *portals = NULL;
int i = 0;


if (!reply) {
return;
}
Expand All @@ -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);
Expand Down Expand Up @@ -1605,6 +1638,7 @@ blockCreateCliFormatResponse(blockCreateCli *blk, struct blockCreate *cobj,
}

out:
blockFreeMetaInfo(info);
GB_FREE(tmp);
GB_FREE(tmp2);
return;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions rpc/rpcl/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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/$@ $^

0 comments on commit 1dbbd7d

Please sign in to comment.