summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrasanna Kumar Kalever <prasanna.kalever@redhat.com>2016-03-23 15:45:08 +0530
committerJeff Darcy <jdarcy@redhat.com>2016-03-24 08:08:07 -0700
commit1b1fae4b8b351ee768f8fa61c3e5e5debfa2eb15 (patch)
tree5e8df31471e0caa791dc07000fe96dea3df6a80e
parentaebd8d69d9c918a55f0619303de6880a4214dc94 (diff)
glfs-mgmt: fix connecting to multiple volfile transports
Problem: [ {"host":"1.2.3.4", "port":"24007", "transport":"tcp"}, {"host":"/var/run/glusterd.socket", "transport":"unix"} ] Consider the above case where we have two volfile servers, each has different transport type, we first try to connect to server1 which has transport type "tcp" let's say we found that host address is invalid, now we pick the next available server2, in our case it is of type "unix" and try to connect to it. but we fail to connect to it even we have right unix path, because multiple volfile servers with different transport type is not taken care currently. Solution: Every time we receive a RPC_CLNT_DISCONNECT event in mgmt_rpc_notify, we need to check the transport type of the volfile server in the list and set the keys "transport.socket.connect-path" or "remote-host" accordingly. Change-Id: I36bec46ef2e92e4642a7d7d64b423d0bc3ab269b BUG: 1320489 Signed-off-by: Prasanna Kumar Kalever <prasanna.kalever@redhat.com> Reviewed-on: http://review.gluster.org/13819 Smoke: Gluster Build System <jenkins@build.gluster.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Tested-by: Prasanna Kumar Kalever <pkalever@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
-rw-r--r--api/src/glfs-mgmt.c83
1 files changed, 57 insertions, 26 deletions
diff --git a/api/src/glfs-mgmt.c b/api/src/glfs-mgmt.c
index 4587e20df35..fd6b2f5c60c 100644
--- a/api/src/glfs-mgmt.c
+++ b/api/src/glfs-mgmt.c
@@ -759,32 +759,6 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
ctx->cmd_args.volfile_server = server->volfile_server;
ctx->cmd_args.volfile_server_transport = server->transport;
- ret = dict_set_int32 (rpc_trans->options,
- "remote-port",
- server->port);
- if (ret != 0) {
- gf_msg ("glfs-mgmt", GF_LOG_ERROR, ENOTCONN,
- API_MSG_DICT_SET_FAILED,
- "failed to set remote-port: %d",
- server->port);
- errno = ENOTCONN;
- glfs_init_done (fs, -1);
- break;
- }
-
- ret = dict_set_str (rpc_trans->options,
- "remote-host",
- server->volfile_server);
- if (ret != 0) {
- gf_msg ("glfs-mgmt", GF_LOG_ERROR, ENOTCONN,
- API_MSG_DICT_SET_FAILED,
- "failed to set remote-host: %s",
- server->volfile_server);
- errno = ENOTCONN;
- glfs_init_done (fs, -1);
- break;
- }
-
ret = dict_set_str (rpc_trans->options,
"transport-type",
server->transport);
@@ -797,6 +771,63 @@ mgmt_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
glfs_init_done (fs, -1);
break;
}
+
+ if (strcmp(server->transport, "unix") == 0) {
+ ret = dict_set_str (rpc_trans->options,
+ "transport.socket.connect-path",
+ server->volfile_server);
+ if (ret != 0) {
+ gf_msg ("glfs-mgmt", GF_LOG_ERROR,
+ ENOTCONN,
+ API_MSG_DICT_SET_FAILED,
+ "failed to set socket.connect-path: %s",
+ server->volfile_server);
+ errno = ENOTCONN;
+ glfs_init_done (fs, -1);
+ break;
+ }
+ /* delete the remote-host and remote-port keys
+ * in case they were set while looping through
+ * list of volfile servers previously
+ */
+ dict_del (rpc_trans->options, "remote-host");
+ dict_del (rpc_trans->options, "remote-port");
+ } else {
+ ret = dict_set_int32 (rpc_trans->options,
+ "remote-port",
+ server->port);
+ if (ret != 0) {
+ gf_msg ("glfs-mgmt", GF_LOG_ERROR,
+ ENOTCONN,
+ API_MSG_DICT_SET_FAILED,
+ "failed to set remote-port: %d",
+ server->port);
+ errno = ENOTCONN;
+ glfs_init_done (fs, -1);
+ break;
+ }
+
+ ret = dict_set_str (rpc_trans->options,
+ "remote-host",
+ server->volfile_server);
+ if (ret != 0) {
+ gf_msg ("glfs-mgmt", GF_LOG_ERROR,
+ ENOTCONN,
+ API_MSG_DICT_SET_FAILED,
+ "failed to set remote-host: %s",
+ server->volfile_server);
+ errno = ENOTCONN;
+ glfs_init_done (fs, -1);
+ break;
+ }
+ /* delete the "transport.socket.connect-path"
+ * key in case if it was set while looping
+ * through list of volfile servers previously
+ */
+ dict_del (rpc_trans->options,
+ "transport.socket.connect-path");
+ }
+
gf_msg ("glfs-mgmt", GF_LOG_INFO, 0,
API_MSG_VOLFILE_CONNECTING,
"connecting to next volfile server %s"