Skip to content

Commit 744c3be

Browse files
authored
glusterfsd/mgmt: Connect backup volfile-server in round robin (#4167) (#4579)
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 > cherry-picked from commit c2d1fa5 Change-Id: I8fe801fb536879d13a3c84eb2d935932b44dbaf5 Fixes: #4166 Signed-off-by: Mohammed Rafi KC <[email protected]>
1 parent a06250f commit 744c3be

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
@@ -816,6 +816,7 @@ mgmt_rpc_notify(struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
816816
rpc_transport_t *rpc_trans = NULL;
817817
struct glfs *fs = NULL;
818818
int ret = 0;
819+
static int log_ctr2;
819820
struct dnscache6 *dnscache = NULL;
820821

821822
this = mydata;
@@ -851,13 +852,26 @@ mgmt_rpc_notify(struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
851852
}
852853
server = ctx->cmd_args.curr_server;
853854
if (server->list.next == &ctx->cmd_args.volfile_servers) {
854-
errno = ENOTCONN;
855-
gf_smsg("glfs-mgmt", GF_LOG_INFO, ENOTCONN,
856-
API_MSG_VOLFILE_SERVER_EXHAUST, NULL);
857-
glfs_init_done(fs, -1);
858-
break;
855+
if (!ctx->active) {
856+
errno = ENOTCONN;
857+
gf_smsg("glfs-mgmt", GF_LOG_INFO, ENOTCONN,
858+
API_MSG_VOLFILE_SERVER_EXHAUST, NULL);
859+
glfs_init_done(fs, -1);
860+
break;
861+
} else {
862+
server = list_first_entry(
863+
&ctx->cmd_args.volfile_servers, typeof(*server),
864+
list);
865+
GF_LOG_OCCASIONALLY(log_ctr2, "glusterfsd-mgmt",
866+
GF_LOG_INFO,
867+
"Exhausted all volfile servers, "
868+
"Retrying from again!");
869+
}
870+
871+
} else {
872+
server = list_entry(server->list.next, typeof(*server),
873+
list);
859874
}
860-
server = list_entry(server->list.next, typeof(*server), list);
861875
ctx->cmd_args.curr_server = server;
862876
ctx->cmd_args.volfile_server_port = server->port;
863877
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)