diff options
author | Avra Sengupta <asengupt@redhat.com> | 2014-06-04 12:30:44 +0000 |
---|---|---|
committer | Venky Shankar <vshankar@redhat.com> | 2014-06-12 05:48:54 -0700 |
commit | 1f21201a434dd37b621efd3cc5d2ef1fd077c303 (patch) | |
tree | 138ebbea13840f091450f35bdc8dc39f1035dcfd /xlators/mgmt/glusterd | |
parent | 665366a72b720d2eee61aba8b3108e12747db767 (diff) |
glusterd/geo-rep: Create the conf file path correctly
In case of mount brocker, the conf file path needs to
be correctly created, and then fetch the status file
Change-Id: Iaa1b04ee46f10961a7056e834170d68282c36efa
BUG: 1104649
Signed-off-by: Avra Sengupta <asengupt@redhat.com>
Reviewed-on: http://review.gluster.org/7977
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Kotresh HR <khiremat@redhat.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Tested-by: Venky Shankar <vshankar@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 4 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-geo-rep.c | 117 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 12 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.h | 4 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 2 |
5 files changed, 77 insertions, 62 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c index 6544d7324e2..adbaf79aad8 100644 --- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c @@ -889,7 +889,7 @@ _glusterd_restart_gsync_session (dict_t *this, char *key, char *path_list = NULL; char *slave_vol = NULL; char *slave_host = NULL; - char *slave_ip = NULL; + char *slave_url = NULL; char *conf_path = NULL; char **errmsg = NULL; int ret = -1; @@ -925,7 +925,7 @@ _glusterd_restart_gsync_session (dict_t *this, char *key, } ret = glusterd_get_slave_details_confpath (param->volinfo, - param->rsp_dict, &slave_ip, + param->rsp_dict, &slave_url, &slave_host, &slave_vol, &conf_path, errmsg); if (ret) { diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c index de5452c557f..def83fb2055 100644 --- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c +++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c @@ -976,7 +976,7 @@ _get_status_mst_slv (dict_t *this, char *key, data_t *value, void *data) glusterd_gsync_status_temp_t *param = NULL; char *slave = NULL; char *slave_buf = NULL; - char *slave_ip = NULL; + char *slave_url = NULL; char *slave_vol = NULL; char *slave_host = NULL; char *errmsg = NULL; @@ -1001,7 +1001,7 @@ _get_status_mst_slv (dict_t *this, char *key, data_t *value, void *data) return 0; slave++; - ret = glusterd_get_slave_info (slave, &slave_ip, + ret = glusterd_get_slave_info (slave, &slave_url, &slave_host, &slave_vol, &errmsg); if (ret) { if (errmsg) @@ -1017,7 +1017,7 @@ _get_status_mst_slv (dict_t *this, char *key, data_t *value, void *data) ret = snprintf (conf_path, sizeof(conf_path) - 1, "%s/"GEOREP"/%s_%s_%s/gsyncd.conf", priv->workdir, param->volinfo->volname, - slave_ip, slave_vol); + slave_host, slave_vol); conf_path[ret] = '\0'; ret = glusterd_get_gsync_status_mst_slv(param->volinfo, @@ -1430,7 +1430,7 @@ _get_slave_status (dict_t *dict, char *key, data_t *value, void *data) { gsync_status_param_t *param = NULL; char *slave = NULL; - char *slave_ip = NULL; + char *slave_url = NULL; char *slave_vol = NULL; char *slave_host = NULL; char *errmsg = NULL; @@ -1466,7 +1466,7 @@ _get_slave_status (dict_t *dict, char *key, data_t *value, void *data) } slave++; - ret = glusterd_get_slave_info (slave, &slave_ip, + ret = glusterd_get_slave_info (slave, &slave_url, &slave_host, &slave_vol, &errmsg); if (ret) { if (errmsg) @@ -1482,7 +1482,7 @@ _get_slave_status (dict_t *dict, char *key, data_t *value, void *data) ret = snprintf (conf_path, sizeof(conf_path) - 1, "%s/"GEOREP"/%s_%s_%s/gsyncd.conf", priv->workdir, param->volinfo->volname, - slave_ip, slave_vol); + slave_host, slave_vol); if (ret < 0) { gf_log ("", GF_LOG_ERROR, "Unable to assign conf_path."); ret = -1; @@ -1568,7 +1568,7 @@ glusterd_verify_gsync_status_opts (dict_t *dict, char **op_errstr) glusterd_volinfo_t *volinfo = NULL; int ret = 0; char *conf_path = NULL; - char *slave_ip = NULL; + char *slave_url = NULL; char *slave_host = NULL; char *slave_vol = NULL; glusterd_conf_t *priv = NULL; @@ -1604,7 +1604,7 @@ glusterd_verify_gsync_status_opts (dict_t *dict, char **op_errstr) goto out; } - ret = glusterd_get_slave_details_confpath (volinfo, dict, &slave_ip, + ret = glusterd_get_slave_details_confpath (volinfo, dict, &slave_url, &slave_host, &slave_vol, &conf_path, op_errstr); if (ret) { @@ -1907,7 +1907,7 @@ fetch_data: } int -glusterd_create_status_file (char *master, char *slave, char *slave_ip, +glusterd_create_status_file (char *master, char *slave, char *slave_host, char *slave_vol, char *status) { int ret = -1; @@ -1931,7 +1931,7 @@ glusterd_create_status_file (char *master, char *slave, char *slave_ip, runner_add_args (&runner, GSYNCD_PREFIX"/gsyncd", "--create", status, "-c", NULL); runner_argprintf (&runner, "%s/"GEOREP"/%s_%s_%s/gsyncd.conf", - priv->workdir, master, slave_ip, slave_vol); + priv->workdir, master, slave_host, slave_vol); runner_argprintf (&runner, "--iprefix=%s", DATADIR); runner_argprintf (&runner, ":%s", master); runner_add_args (&runner, slave, NULL); @@ -2405,7 +2405,7 @@ glusterd_op_stage_gsync_set (dict_t *dict, char **op_errstr) int pfd = -1; char *volname = NULL; char *slave = NULL; - char *slave_ip = NULL; + char *slave_url = NULL; char *slave_host = NULL; char *slave_vol = NULL; char *down_peerstr = NULL; @@ -2467,7 +2467,7 @@ glusterd_op_stage_gsync_set (dict_t *dict, char **op_errstr) goto out; } - ret = glusterd_get_slave_details_confpath (volinfo, dict, &slave_ip, + ret = glusterd_get_slave_details_confpath (volinfo, dict, &slave_url, &slave_host, &slave_vol, &conf_path, op_errstr); if (ret) { @@ -2719,7 +2719,7 @@ out: static int gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave, - char *slave_ip, char *slave_vol, char *conf_path, + char *slave_host, char *slave_vol, char *conf_path, char **op_errstr, gf_boolean_t is_pause) { int32_t ret = 0; @@ -2740,7 +2740,7 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave, GF_ASSERT (dict); GF_ASSERT (master); GF_ASSERT (slave); - GF_ASSERT (slave_ip); + GF_ASSERT (slave_host); GF_ASSERT (slave_vol); GF_ASSERT (conf_path); @@ -2799,7 +2799,7 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave, goto out; (void) strcat (monitor_status, "(Paused)"); ret = glusterd_create_status_file ( master, slave, - slave_ip, slave_vol, + slave_host, slave_vol, monitor_status); if (ret) { gf_log (this->name, GF_LOG_ERROR, @@ -2829,8 +2829,9 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave, goto out; } token = strtok (monitor_status, "("); - ret = glusterd_create_status_file ( master, slave, - slave_ip, slave_vol, token); + ret = glusterd_create_status_file (master, slave, + slave_host, + slave_vol, token); if (ret) { gf_log (this->name, GF_LOG_ERROR, "Unable to update state_file." @@ -3025,7 +3026,7 @@ glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave, char *subop = NULL; char *master = NULL; char *conf_path = NULL; - char *slave_ip = NULL; + char *slave_host = NULL; char *slave_vol = NULL; struct stat stbuf = {0, }; gf_boolean_t restart_required = _gf_true; @@ -3122,10 +3123,10 @@ glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave, ret = lstat (op_value, &stbuf); if (ret) { - ret = dict_get_str (dict, "slave_ip", &slave_ip); + ret = dict_get_str (dict, "slave_host", &slave_host); if (ret) { gf_log ("", GF_LOG_ERROR, - "Unable to fetch slave IP."); + "Unable to fetch slave host."); goto out; } @@ -3136,9 +3137,11 @@ glusterd_gsync_configure (glusterd_volinfo_t *volinfo, char *slave, goto out; } - ret = glusterd_create_status_file (volinfo->volname, slave, - slave_ip, slave_vol, - "Switching Status File"); + ret = glusterd_create_status_file (volinfo->volname, + slave, slave_host, + slave_vol, + "Switching Status " + "File"); if (ret || lstat (op_value, &stbuf)) { gf_log ("", GF_LOG_ERROR, "Unable to create %s" ". Error : %s", op_value, @@ -3980,9 +3983,9 @@ glusterd_get_gsync_status (dict_t *dict, char **op_errstr, dict_t *rsp_dict) } static int -glusterd_gsync_delete (glusterd_volinfo_t *volinfo, char *slave, char *slave_ip, - char *slave_vol, char *path_list, dict_t *dict, - dict_t *resp_dict, char **op_errstr) +glusterd_gsync_delete (glusterd_volinfo_t *volinfo, char *slave, + char *slave_host, char *slave_vol, char *path_list, + dict_t *dict, dict_t *resp_dict, char **op_errstr) { int32_t ret = -1; runner_t runner = {0,}; @@ -3993,7 +3996,7 @@ glusterd_gsync_delete (glusterd_volinfo_t *volinfo, char *slave, char *slave_ip, char *conf_path = NULL; GF_ASSERT (slave); - GF_ASSERT (slave_ip); + GF_ASSERT (slave_host); GF_ASSERT (slave_vol); GF_ASSERT (op_errstr); GF_ASSERT (dict); @@ -4045,7 +4048,7 @@ glusterd_gsync_delete (glusterd_volinfo_t *volinfo, char *slave, char *slave_ip, ret = snprintf (geo_rep_dir, sizeof(geo_rep_dir) - 1, "%s/"GEOREP"/%s_%s_%s", gl_workdir, - volinfo->volname, slave_ip, slave_vol); + volinfo->volname, slave_host, slave_vol); geo_rep_dir[ret] = '\0'; ret = rmdir (geo_rep_dir); @@ -4394,8 +4397,9 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict) int32_t type = -1; char *host_uuid = NULL; char *slave = NULL; - char *slave_ip = NULL; + char *slave_url = NULL; char *slave_vol = NULL; + char *slave_host = NULL; char *volname = NULL; char *path_list = NULL; glusterd_volinfo_t *volinfo = NULL; @@ -4431,9 +4435,15 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict) if (ret < 0) goto out; - ret = dict_get_str (dict, "slave_ip", &slave_ip); + ret = dict_get_str (dict, "slave_url", &slave_url); if (ret) { - gf_log ("", GF_LOG_ERROR, "Unable to fetch slave volume name."); + gf_log ("", GF_LOG_ERROR, "Unable to fetch slave url."); + goto out; + } + + ret = dict_get_str (dict, "slave_host", &slave_host); + if (ret) { + gf_log ("", GF_LOG_ERROR, "Unable to fetch slave hostname."); goto out; } @@ -4480,7 +4490,7 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict) if (ret && !is_force && path_list) goto out; - ret = glusterd_gsync_delete (volinfo, slave, slave_ip, + ret = glusterd_gsync_delete (volinfo, slave, slave_host, slave_vol, path_list, dict, rsp_dict, op_errstr); goto out; @@ -4525,7 +4535,7 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict) if (type == GF_GSYNC_OPTION_TYPE_PAUSE) { ret = gd_pause_or_resume_gsync (dict, volname, slave, - slave_ip, slave_vol, + slave_host, slave_vol, conf_path, op_errstr, _gf_true); if (ret) @@ -4533,7 +4543,7 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict) " Pause Failed"); } else if (type == GF_GSYNC_OPTION_TYPE_RESUME) { ret = gd_pause_or_resume_gsync (dict, volname, slave, - slave_ip, slave_vol, + slave_host, slave_vol, conf_path, op_errstr, _gf_false); if (ret) @@ -4549,7 +4559,7 @@ glusterd_op_gsync_set (dict_t *dict, char **op_errstr, dict_t *rsp_dict) if (!ret) { ret = glusterd_create_status_file ( volinfo->volname, - slave, slave_ip, + slave, slave_host, slave_vol,"Stopped"); if (ret) { gf_log ("", GF_LOG_ERROR, "Unable to " @@ -4572,7 +4582,7 @@ out: int glusterd_get_slave_details_confpath (glusterd_volinfo_t *volinfo, - dict_t *dict, char **slave_ip, + dict_t *dict, char **slave_url, char **slave_host, char **slave_vol, char **conf_path, char **op_errstr) { @@ -4592,7 +4602,7 @@ glusterd_get_slave_details_confpath (glusterd_volinfo_t *volinfo, goto out; } - ret = glusterd_get_slave_info (slave, slave_ip, + ret = glusterd_get_slave_info (slave, slave_url, slave_host, slave_vol, op_errstr); if (ret) { gf_log ("", GF_LOG_ERROR, @@ -4601,7 +4611,7 @@ glusterd_get_slave_details_confpath (glusterd_volinfo_t *volinfo, goto out; } - ret = dict_set_str (dict, "slave_ip", *slave_ip); + ret = dict_set_str (dict, "slave_url", *slave_url); if (ret) { gf_log ("", GF_LOG_ERROR, "Unable to store slave IP."); @@ -4658,6 +4668,10 @@ glusterd_get_slave_info (char *slave, char **linearr = NULL; int32_t ret = -1; char errmsg[PATH_MAX] = ""; + xlator_t *this = NULL; + + this = THIS; + GF_ASSERT (this); ret = glusterd_urltransform_single (slave, "normalize", &linearr); @@ -4666,7 +4680,7 @@ glusterd_get_slave_info (char *slave, "Invalid Url: %s", slave); errmsg[ret] = '\0'; *op_errstr = gf_strdup (errmsg); - gf_log ("", GF_LOG_ERROR, "Failed to normalize url"); + gf_log (this->name, GF_LOG_ERROR, "Failed to normalize url"); goto out; } @@ -4676,22 +4690,23 @@ glusterd_get_slave_info (char *slave, if (slave) { ret = glusterd_geo_rep_parse_slave (slave, hostname, op_errstr); if (ret) { - gf_log ("", GF_LOG_ERROR, + gf_log (this->name, GF_LOG_ERROR, "Invalid slave url: %s", *op_errstr); goto out; } + gf_log (this->name, GF_LOG_DEBUG, "Hostname : %s", *hostname); *slave_url = gf_strdup (slave); if (!*slave_url) { - gf_log ("", GF_LOG_ERROR, + gf_log (this->name, GF_LOG_ERROR, "Failed to gf_strdup"); ret = -1; goto out; } - gf_log ("", GF_LOG_DEBUG, "Slave IP : %s", *slave_url); + gf_log (this->name, GF_LOG_DEBUG, "Slave URL : %s", *slave_url); ret = 0; } else { - gf_log ("", GF_LOG_ERROR, "Invalid slave name"); + gf_log (this->name, GF_LOG_ERROR, "Invalid slave name"); goto out; } @@ -4699,21 +4714,21 @@ glusterd_get_slave_info (char *slave, if (slave) { *slave_vol = gf_strdup (slave); if (!*slave_vol) { - gf_log ("", GF_LOG_ERROR, + gf_log (this->name, GF_LOG_ERROR, "Failed to gf_strdup"); ret = -1; GF_FREE (*slave_url); goto out; } - gf_log ("", GF_LOG_DEBUG, "Slave Vol : %s", *slave_vol); + gf_log (this->name, GF_LOG_DEBUG, "Slave Vol : %s", *slave_vol); ret = 0; } else { - gf_log ("", GF_LOG_ERROR, "Invalid slave name"); + gf_log (this->name, GF_LOG_ERROR, "Invalid slave name"); goto out; } out: - gf_log ("", GF_LOG_DEBUG, "Returning %d", ret); + gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret); return ret; } @@ -4987,7 +5002,7 @@ create_conf_file (glusterd_conf_t *conf, char *conf_path) static int glusterd_create_essential_dir_files (glusterd_volinfo_t *volinfo, dict_t *dict, - char *slave, char *slave_ip, + char *slave, char *slave_host, char *slave_vol, char **op_errstr) { int ret = -1; @@ -5018,7 +5033,7 @@ glusterd_create_essential_dir_files (glusterd_volinfo_t *volinfo, dict_t *dict, } ret = snprintf (buf, sizeof(buf) - 1, "%s/"GEOREP"/%s_%s_%s", - conf->workdir, volinfo->volname, slave_ip, slave_vol); + conf->workdir, volinfo->volname, slave_host, slave_vol); buf[ret] = '\0'; ret = mkdir_p (buf, 0777, _gf_true); if (ret) { @@ -5062,7 +5077,7 @@ glusterd_create_essential_dir_files (glusterd_volinfo_t *volinfo, dict_t *dict, goto out; } else { ret = glusterd_create_status_file (volinfo->volname, slave, - slave_ip, slave_vol, + slave_host, slave_vol, "Not Started"); if (ret || lstat (statefile, &stbuf)) { snprintf (errmsg, sizeof (errmsg), "Unable to create %s" @@ -5134,7 +5149,7 @@ glusterd_op_gsync_create (dict_t *dict, char **op_errstr, dict_t *rsp_dict) goto out; } - ret = dict_get_str (dict, "slave_ip", &slave_url); + ret = dict_get_str (dict, "slave_url", &slave_url); if (ret) { snprintf (errmsg, sizeof (errmsg), "Unable to fetch slave IP."); diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 94949e79111..d79ff249535 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -6716,7 +6716,7 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data) { char *path_list = NULL; char *slave = NULL; - char *slave_ip = NULL; + char *slave_url = NULL; char *slave_vol = NULL; char *slave_host = NULL; char *statefile = NULL; @@ -6751,7 +6751,7 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data) ret = glusterd_get_local_brickpaths (volinfo, &path_list); /*Generating the conf file path needed by gsyncd */ - ret = glusterd_get_slave_info (slave, &slave_ip, &slave_host, + ret = glusterd_get_slave_info (slave, &slave_url, &slave_host, &slave_vol, &op_errstr); if (ret) { gf_log ("", GF_LOG_ERROR, @@ -6763,7 +6763,7 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data) ret = snprintf (confpath, sizeof(confpath) - 1, "%s/"GEOREP"/%s_%s_%s/gsyncd.conf", priv->workdir, volinfo->volname, - slave_ip, slave_vol); + slave_host, slave_vol); confpath[ret] = '\0'; /* Fetching the last status of the node */ @@ -6822,7 +6822,7 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data) gf_log ("", GF_LOG_INFO, "Geo-Rep Session was not started between " "%s and %s::%s. Not Restarting", volinfo->volname, - slave_ip, slave_vol); + slave_url, slave_vol); goto out; } else if (strstr(buf, "Paused")) { is_paused = _gf_true; @@ -6832,7 +6832,7 @@ _local_gsyncd_start (dict_t *this, char *key, data_t *value, void *data) "Not Restarting. Use start (force) to " "start the session between %s and %s::%s.", volinfo->volname, - slave_ip, slave_vol); + slave_url, slave_vol); goto out; } @@ -6849,7 +6849,7 @@ out: if (is_template_in_use) { ret = glusterd_create_status_file (volinfo->volname, slave, - slave_ip, slave_vol, + slave_host, slave_vol, "Config Corrupted"); if (ret) { gf_log ("", GF_LOG_ERROR, diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h index dc37cf232cd..2d7c4269d34 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.h +++ b/xlators/mgmt/glusterd/src/glusterd-utils.h @@ -624,7 +624,7 @@ glusterd_are_vol_all_peers_up (glusterd_volinfo_t *volinfo, int glusterd_get_slave_details_confpath (glusterd_volinfo_t *volinfo, - dict_t *dict, char **slave_ip, + dict_t *dict, char **slave_url, char **slave_host, char **slave_vol, char **conf_path, char **op_errstr); @@ -642,7 +642,7 @@ int glusterd_gsync_read_frm_status (char *path, char *buf, size_t blen); int -glusterd_create_status_file (char *master, char *slave, char *slave_ip, +glusterd_create_status_file (char *master, char *slave, char *slave_url, char *slave_vol, char *status); int diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c index 9b390321087..d885ab0a63f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c @@ -1200,7 +1200,7 @@ glusterd_op_stage_stop_volume (dict_t *dict, char **op_errstr) } if (is_run && param.is_active) { - gf_log (this->name, GF_LOG_WARNING, GEOREP" sessions active" + gf_log (this->name, GF_LOG_WARNING, GEOREP" sessions active " "for the volume %s ", volname); snprintf (msg, sizeof(msg), GEOREP" sessions are active " "for the volume '%s'.\nUse 'volume "GEOREP" " |