summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd
diff options
context:
space:
mode:
authorSaravanakumar Arumugam <sarumuga@redhat.com>2016-06-06 14:44:35 +0530
committerNiels de Vos <ndevos@redhat.com>2016-06-13 07:40:04 -0700
commit1364929574c1af7784ac47088d2f7507ee0103e4 (patch)
tree635c126a050299fa6fe457c59898f14a8adfe16d /xlators/mgmt/glusterd
parenta238ad371c32feddb5af8a48642870bc6b9ee767 (diff)
glusterd/geo-rep: Avoid started status check if same host
After carrying out add-brick, session creation is carried out again, to involve new brick in the session. This needs to be done, even if the session is in Started state. While involving slave uuid as part of a session, User is warned if session is in Started state. This check needs to be avoided if it is same slave host and session creation needs to be proceeded. > Change-Id: Ic73edd5bd9e3ee55da96f5aceec0bafa14d3f3dd > BUG: 1342979 > Signed-off-by: Saravanakumar Arumugam <sarumuga@redhat.com> > Reviewed-on: http://review.gluster.org/14653 > CentOS-regression: Gluster Build System <jenkins@build.gluster.com> > Smoke: Gluster Build System <jenkins@build.gluster.com> > NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> > Reviewed-by: Aravinda VK <avishwan@redhat.com> (cherry picked from commit c62493efadbcf5085bbd65a409eed9391301c154) Change-Id: Ic73edd5bd9e3ee55da96f5aceec0bafa14d3f3dd BUG: 1344607 Signed-off-by: Saravanakumar Arumugam <sarumuga@redhat.com> Reviewed-on: http://review.gluster.org/14711 NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Niels de Vos <ndevos@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.com>
Diffstat (limited to 'xlators/mgmt/glusterd')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-geo-rep.c91
1 files changed, 65 insertions, 26 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
index 47ef39cbaf0..0120404a2ee 100644
--- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
+++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
@@ -583,6 +583,7 @@ struct dictidxmark {
struct slave_vol_config {
char old_slvhost[_POSIX_HOST_NAME_MAX+1];
+ char old_slvuser[_POSIX_LOGIN_NAME_MAX];
unsigned old_slvidx;
char slave_voluuid[GF_UUID_BUF_SIZE];
};
@@ -2878,8 +2879,14 @@ get_slavehost_from_voluuid (dict_t *dict, char *key, data_t *value, void *data)
/* To go past username in non-root geo-rep session */
tmp = strchr (slave_host, '@');
- if (tmp)
+ if (tmp) {
+ strncpy (slave_vol->old_slvuser, slave_host,
+ (tmp - slave_host));
+ slave_vol->old_slvuser[(tmp - slave_host) + 1]
+ = '\0';
slave_host = tmp + 1;
+ } else
+ strcpy (slave_vol->old_slvuser, "root");
tmp = strchr (slave_host, ':');
if (!tmp) {
@@ -2892,7 +2899,7 @@ get_slavehost_from_voluuid (dict_t *dict, char *key, data_t *value, void *data)
strncpy (slave_vol->old_slvhost, slave_host,
(tmp - slave_host));
- slave_vol->old_slvhost[(tmp - slave_host)+1] = '\0';
+ slave_vol->old_slvhost[(tmp - slave_host) + 1] = '\0';
goto out;
}
@@ -2964,6 +2971,11 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr)
int ret_status = 0;
char *statedir = NULL;
char statefiledir[PATH_MAX] = {0,};
+ gf_boolean_t is_different_slavehost = _gf_false;
+ gf_boolean_t is_different_username = _gf_false;
+ char *slave_user = NULL;
+ char *save_ptr = NULL;
+ char *slave_url_buf = NULL;
this = THIS;
GF_ASSERT (this);
@@ -3225,32 +3237,57 @@ glusterd_op_stage_gsync_create (dict_t *dict, char **op_errstr)
slave_vol, slave_host);
goto out;
}
- /* Now, check whether session is already started, if so, warn!*/
- ret = snprintf (old_confpath, sizeof(old_confpath) - 1,
- "%s/"GEOREP"/%s_%s_%s/gsyncd.conf",
- conf->workdir, volinfo->volname,
- slave1.old_slvhost, slave_vol);
- /* construct old slave url with (old) slave host */
- old_slave_url = old_slave_url_info;
- strncpy (old_slave_url, slave1.old_slvhost,
- sizeof(old_slave_url_info));
- old_slave_url = strcat (old_slave_url, "::");
- old_slave_url = strncat (old_slave_url, slave_vol,
- sizeof(old_slave_url_info));
+ /* Now, check whether session is already started.If so, warn!*/
+ is_different_slavehost =
+ (strcmp (slave_host, slave1.old_slvhost) != 0)
+ ? _gf_true : _gf_false;
- ret = glusterd_check_gsync_running_local (volinfo->volname,
- old_slave_url,
- old_confpath,
- &is_running);
- if (_gf_true == is_running) {
- snprintf (errmsg, sizeof(errmsg), "Geo"
- " -replication session between %s and %s"
- " is still active. Please stop the "
- "session and retry.",
- volinfo->volname, old_slave_url);
- ret = -1;
- goto out;
+ if (strstr (slave_url, "@")) {
+ slave_url_buf = gf_strdup (slave_url);
+ if (!slave_url_buf) {
+ gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
+ GD_MSG_NO_MEMORY,
+ "Unable to allocate memory");
+ ret = -1;
+ goto out;
+ }
+ slave_user = strtok_r (slave_url_buf, "@", &save_ptr);
+ } else
+ slave_user = "root";
+ is_different_username =
+ (strcmp (slave_user, slave1.old_slvuser) != 0)
+ ? _gf_true : _gf_false;
+
+ /* Do the check, only if different slave host/slave user */
+ if (is_different_slavehost || is_different_username) {
+ ret = snprintf (old_confpath, sizeof(old_confpath) - 1,
+ "%s/"GEOREP"/%s_%s_%s/gsyncd.conf",
+ conf->workdir, volinfo->volname,
+ slave1.old_slvhost, slave_vol);
+
+ /* construct old slave url with (old) slave host */
+ old_slave_url = old_slave_url_info;
+ strncpy (old_slave_url, slave1.old_slvhost,
+ sizeof(old_slave_url_info));
+ old_slave_url = strcat (old_slave_url, "::");
+ old_slave_url = strncat (old_slave_url, slave_vol,
+ sizeof(old_slave_url_info));
+
+ ret = glusterd_check_gsync_running_local (
+ volinfo->volname,
+ old_slave_url,
+ old_confpath,
+ &is_running);
+ if (_gf_true == is_running) {
+ snprintf (errmsg, sizeof(errmsg), "Geo"
+ "-replication session between %s and %s"
+ " is still active. Please stop the "
+ "session and retry.",
+ volinfo->volname, old_slave_url);
+ ret = -1;
+ goto out;
+ }
}
ret = dict_set_dynstr_with_alloc (dict, "old_slavehost",
@@ -3291,6 +3328,8 @@ out:
if (ret && errmsg[0] != '\0')
*op_errstr = gf_strdup (errmsg);
+ if (slave_url_buf)
+ GF_FREE (slave_url_buf);
gf_msg_debug (this->name, 0, "Returning %d", ret);
return ret;