mirror of
https://github.com/gluster/gluster-block.git
synced 2026-02-05 12:45:33 +01:00
cli-timeout: make rpc-timeout as configurable option
There are two rpc calls involved in the design,
Channel A: From cli process to local daemon (cli thread)
Channel B: From local daemon (cli thread) to remote daemon (remote thread)
Timeout for channel A is configurable now, using
/etc/sysconfig/gluster-blockd, by adjusting option 'GB_CLI_TIMEOUT' (in seconds)
$ cat /etc/sysconfig/gluster-blockd
GB_CLI_TIMEOUT=900
Changes to this value takes effect every time we start running/triggering new
cli command/request.
At the moment making Timeout configurable for channel B is not important, it is
hardcoded as 300 seconds in the code for now.
Some more details:
-----------------
It would have been an easy fix calling clnt_control() right after clnt_create(),
unfortunately there is a bug in glibc, which is why we had to hack the rpc
generated code instead of directly calling clnt_control(), see my very old
commit [1] which explains why we had to override (in a hacky-way) the default
generated TIMEOUT.
[1] 1dbbd7d457
Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com>
Reviewed & Tested-by: Xiubo Li <xiubli@redhat.com>
Reviewed-by: Amar Tumballi <amarts@redhat.com>
This commit is contained in:
committed by
Prasanna Kumar Kalever
parent
0fd2ea41bd
commit
61e6fa82f4
@@ -42,6 +42,8 @@
|
||||
|
||||
extern const char *argp_program_version;
|
||||
|
||||
struct timeval TIMEOUT; /* cli process to daemon cli thread timeout */
|
||||
|
||||
typedef enum clioperations {
|
||||
CREATE_CLI = 1,
|
||||
LIST_CLI = 2,
|
||||
@@ -54,6 +56,41 @@ typedef enum clioperations {
|
||||
} clioperations;
|
||||
|
||||
|
||||
gbConfig *
|
||||
glusterBlockCLILoadConfig(void)
|
||||
{
|
||||
gbConfig *cfg = NULL;
|
||||
int ret;
|
||||
|
||||
if (GB_ALLOC(cfg) < 0) {
|
||||
LOG("cli", GB_LOG_ERROR,
|
||||
"Alloc GB config failed for configPath: %s!\n", GB_DEF_CONFIGPATH);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (GB_STRDUP(cfg->configPath, GB_DEF_CONFIGPATH) < 0) {
|
||||
LOG("cli", GB_LOG_ERROR,
|
||||
"failed to copy configPath: %s\n", GB_DEF_CONFIGPATH);
|
||||
goto freeConfig;
|
||||
}
|
||||
|
||||
if (glusterBlockLoadConfig(cfg, false)) {
|
||||
LOG("cli", GB_LOG_ERROR,
|
||||
"Loading GB config failed for configPath: %s!\n", GB_DEF_CONFIGPATH);
|
||||
goto freeConfigPath;
|
||||
}
|
||||
|
||||
return cfg;
|
||||
|
||||
freeConfigPath:
|
||||
GB_FREE(cfg->configPath);
|
||||
freeConfig:
|
||||
GB_FREE(cfg);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
glusterBlockCliRPC_1(void *cobj, clioperations opt)
|
||||
{
|
||||
@@ -71,6 +108,7 @@ glusterBlockCliRPC_1(void *cobj, clioperations opt)
|
||||
blockGenConfigCli *genconfig_obj;
|
||||
blockResponse reply = {0,};
|
||||
char errMsg[2048] = {0};
|
||||
gbConfig *conf = NULL;
|
||||
|
||||
|
||||
if (strlen(GB_UNIX_ADDRESS) > SUN_PATH_MAX) {
|
||||
@@ -110,6 +148,20 @@ glusterBlockCliRPC_1(void *cobj, clioperations opt)
|
||||
goto out;
|
||||
}
|
||||
|
||||
conf = glusterBlockCLILoadConfig();
|
||||
if (!conf) {
|
||||
LOG("cli", GB_LOG_ERROR,
|
||||
"glusterBlockCLILoadConfig() failed, for block %s create on volume %s"
|
||||
" with hosts %s\n", create_obj->block_name, create_obj->volume,
|
||||
create_obj->block_hosts);
|
||||
goto out;
|
||||
}
|
||||
|
||||
TIMEOUT.tv_sec = conf->GB_CLI_TIMEOUT;
|
||||
if (!TIMEOUT.tv_sec) {
|
||||
TIMEOUT.tv_sec = CLI_TIMEOUT_DEF;
|
||||
}
|
||||
|
||||
switch(opt) {
|
||||
case CREATE_CLI:
|
||||
create_obj = cobj;
|
||||
@@ -212,6 +264,11 @@ glusterBlockCliRPC_1(void *cobj, clioperations opt)
|
||||
close (sockfd);
|
||||
}
|
||||
|
||||
if (conf) {
|
||||
GB_FREE(conf->configPath);
|
||||
GB_FREE(conf);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user