Skip to content

Commit c2d1fa5

Browse files
authored
glusterfsd/mgmt: Connect backup volfile-server in round robin (#4167)
Once we establish a connection with volfile-server, if that connection looses, then we try to connect to the ony be one till the last one on the list. Once we reach the last one, we never go back to the first one. So if the last one is down we will fail to connect to that node until it comes back Change-Id: I8fe801fb536879d13a3c84eb2d935932b44dbaf5 Fixes: #4166 Signed-off-by: Mohammed Rafi KC <[email protected]>
1 parent 8e2fd0b commit c2d1fa5

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

api/src/glfs-mgmt.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,7 @@ mgmt_rpc_notify(struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
819819
rpc_transport_t *rpc_trans = NULL;
820820
struct glfs *fs = NULL;
821821
int ret = 0;
822+
static int log_ctr2;
822823
struct dnscache6 *dnscache = NULL;
823824

824825
this = mydata;
@@ -854,13 +855,26 @@ mgmt_rpc_notify(struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
854855
}
855856
server = ctx->cmd_args.curr_server;
856857
if (server->list.next == &ctx->cmd_args.volfile_servers) {
857-
errno = ENOTCONN;
858-
gf_smsg("glfs-mgmt", GF_LOG_INFO, ENOTCONN,
859-
API_MSG_VOLFILE_SERVER_EXHAUST, NULL);
860-
glfs_init_done(fs, -1);
861-
break;
858+
if (!ctx->active) {
859+
errno = ENOTCONN;
860+
gf_smsg("glfs-mgmt", GF_LOG_INFO, ENOTCONN,
861+
API_MSG_VOLFILE_SERVER_EXHAUST, NULL);
862+
glfs_init_done(fs, -1);
863+
break;
864+
} else {
865+
server = list_first_entry(
866+
&ctx->cmd_args.volfile_servers, typeof(*server),
867+
list);
868+
GF_LOG_OCCASIONALLY(log_ctr2, "glusterfsd-mgmt",
869+
GF_LOG_INFO,
870+
"Exhausted all volfile servers, "
871+
"Retrying from again!");
872+
}
873+
874+
} else {
875+
server = list_entry(server->list.next, typeof(*server),
876+
list);
862877
}
863-
server = list_entry(server->list.next, typeof(*server), list);
864878
ctx->cmd_args.curr_server = server;
865879
ctx->cmd_args.volfile_server_port = server->port;
866880
ctx->cmd_args.volfile_server = server->volfile_server;

glusterfsd/src/glusterfsd-mgmt.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2817,13 +2817,21 @@ mgmt_rpc_notify(struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
28172817
if (server->list.next == &ctx->cmd_args.volfile_servers) {
28182818
if (!ctx->active) {
28192819
need_term = 1;
2820+
gf_log("glusterfsd-mgmt", GF_LOG_INFO,
2821+
"Exhausted all volfile servers, Exiting");
2822+
emval = ENOTCONN;
2823+
break;
2824+
} else {
2825+
server = list_first_entry(&ctx->cmd_args.volfile_servers,
2826+
typeof(*server), list);
2827+
emval = ENOTCONN;
2828+
GF_LOG_OCCASIONALLY(
2829+
log_ctr2, "glusterfsd-mgmt", GF_LOG_INFO,
2830+
"Exhausted all volfile servers, Retrying from again!");
28202831
}
2821-
emval = ENOTCONN;
2822-
GF_LOG_OCCASIONALLY(log_ctr2, "glusterfsd-mgmt", GF_LOG_INFO,
2823-
"Exhausted all volfile servers");
2824-
break;
2832+
} else {
2833+
server = list_entry(server->list.next, typeof(*server), list);
28252834
}
2826-
server = list_entry(server->list.next, typeof(*server), list);
28272835
ctx->cmd_args.curr_server = server;
28282836
ctx->cmd_args.volfile_server = server->volfile_server;
28292837

0 commit comments

Comments
 (0)