summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorN Balachandran <nbalacha@redhat.com>2019-07-25 11:51:32 +0530
committerAmar Tumballi <amarts@redhat.com>2019-08-14 03:21:30 +0000
commit6ef9ffea7fee43ea6f59c8c36fd183f90e9c26f8 (patch)
treec73a7e68188ecf463fc58e5843e2a860909a8675
parent089e53c7f1c32644ce2b37830b678b4c0c7071fc (diff)
glusterd: create separate logdirs for cluster.rc instances
Create a separate logdir for each host instance created by cluster.rc. This makes it easier to determine the files belonging to a particular instance. Change-Id: Ic8321f83f98995412b7d5f095b3d3f0391767a8b Fixes: bz#1733042 Signed-off-by: N Balachandran <nbalacha@redhat.com>
-rw-r--r--tests/cluster.rc11
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-geo-rep.c72
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc-helper.c3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-messages.h2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-mountbroker.c7
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-mountbroker.h3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-quota.c4
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rebalance.c6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-shd-svc.c6
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-snapd-svc.c3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-tierd-svc-helper.c3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c20
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-ops.c3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.c175
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h1
16 files changed, 186 insertions, 135 deletions
diff --git a/tests/cluster.rc b/tests/cluster.rc
index 99be8e7..06f329e 100644
--- a/tests/cluster.rc
+++ b/tests/cluster.rc
@@ -50,15 +50,16 @@ function define_glusterds() {
sopt="management.glusterd-sockfile=${!b}/glusterd/gd.sock"
#Get the logdir
logdir=`gluster --print-logdir`
+ clopt="management.cluster-test-mode=${logdir}/$i";
#Fetch the testcases name and prefix the glusterd log with it
logfile=`echo ${0##*/}`_glusterd$i.log
- lopt="--log-file=$logdir/$logfile"
+ lopt="--log-file=$logdir/$i/$logfile"
if [ "$2" == "-LDEBUG" ]; then
- eval "glusterd_$i='glusterd -LDEBUG --xlator-option $wopt --xlator-option $bopt --xlator-option $ropt --xlator-option $sopt $lopt $popt'";
- eval "glusterd$i='glusterd -LDEBUG --xlator-option $wopt --xlator-option $bopt --xlator-option $ropt --xlator-option $sopt $lopt $popt'";
+ eval "glusterd_$i='glusterd -LDEBUG --xlator-option $wopt --xlator-option $bopt --xlator-option $ropt --xlator-option $sopt --xlator-option $clopt $lopt $popt'";
+ eval "glusterd$i='glusterd -LDEBUG --xlator-option $wopt --xlator-option $bopt --xlator-option $ropt --xlator-option $sopt --xlator-option $clopt $lopt $popt'";
else
- eval "glusterd_$i='glusterd --xlator-option $wopt --xlator-option $bopt --xlator-option $ropt --xlator-option $sopt $lopt $popt'";
- eval "glusterd$i='glusterd --xlator-option $wopt --xlator-option $bopt --xlator-option $ropt --xlator-option $sopt $lopt $popt'";
+ eval "glusterd_$i='glusterd --xlator-option $wopt --xlator-option $bopt --xlator-option $ropt --xlator-option $sopt --xlator-option $clopt $lopt $popt'";
+ eval "glusterd$i='glusterd --xlator-option $wopt --xlator-option $bopt --xlator-option $ropt --xlator-option $sopt --xlator-option $clopt $lopt $popt'";
fi
done
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
index 5c75f2b..a26260d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
+++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
@@ -2857,8 +2857,8 @@ glusterd_verify_slave(char *volname, char *slave_url, char *slave_vol,
goto out;
}
- snprintf(log_file_path, sizeof(log_file_path),
- DEFAULT_LOG_FILE_DIRECTORY "/create_verify_log");
+ snprintf(log_file_path, sizeof(log_file_path), "%s/create_verify_log",
+ priv->logdir);
runinit(&runner);
runner_add_args(&runner, GSYNCD_PREFIX "/gverify.sh", NULL);
@@ -6242,26 +6242,28 @@ create_conf_file(glusterd_conf_t *conf, char *conf_path)
/* log-file */
runinit_gsyncd_setrx(&runner, conf_path);
- runner_add_args(&runner, "log-file",
- DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP
- "/${mastervol}/${eSlave}.log",
- ".", ".", NULL);
+ runner_add_arg(&runner, "log-file");
+ runner_argprintf(&runner, "%s/%s/${mastervol}/${eSlave}.log", conf->logdir,
+ GEOREP);
+ runner_add_args(&runner, ".", ".", NULL);
RUN_GSYNCD_CMD;
/* changelog-log-file */
runinit_gsyncd_setrx(&runner, conf_path);
- runner_add_args(&runner, "changelog-log-file",
- DEFAULT_LOG_FILE_DIRECTORY
- "/" GEOREP "/${mastervol}/${eSlave}${local_id}-changes.log",
- ".", ".", NULL);
+ runner_add_arg(&runner, "changelog-log-file");
+ runner_argprintf(&runner,
+ "%s/%s/${mastervol}/${eSlave}${local_id}-changes.log",
+ conf->logdir, GEOREP);
+ runner_add_args(&runner, ".", ".", NULL);
RUN_GSYNCD_CMD;
/* gluster-log-file */
runinit_gsyncd_setrx(&runner, conf_path);
- runner_add_args(&runner, "gluster-log-file",
- DEFAULT_LOG_FILE_DIRECTORY
- "/" GEOREP "/${mastervol}/${eSlave}${local_id}.gluster.log",
- ".", ".", NULL);
+ runner_add_arg(&runner, "gluster-log-file");
+ runner_argprintf(&runner,
+ "%s/%s/${mastervol}/${eSlave}${local_id}.gluster.log",
+ conf->logdir, GEOREP);
+ runner_add_args(&runner, ".", ".", NULL);
RUN_GSYNCD_CMD;
/* ignore-deletes */
@@ -6303,33 +6305,35 @@ create_conf_file(glusterd_conf_t *conf, char *conf_path)
/* log-file */
runinit_gsyncd_setrx(&runner, conf_path);
- runner_add_args(
- &runner, "log-file",
- DEFAULT_LOG_FILE_DIRECTORY
- "/" GEOREP
- "-slaves/${session_owner}:${local_node}${local_id}.${slavevol}.log",
- ".", NULL);
+ runner_add_arg(&runner, "log-file");
+ runner_argprintf(&runner,
+ "%s/%s-slaves/"
+ "${session_owner}:${local_node}${local_id}.${slavevol}."
+ "log",
+ conf->logdir, GEOREP);
+ runner_add_args(&runner, ".", ".", NULL);
RUN_GSYNCD_CMD;
/* MountBroker log-file */
runinit_gsyncd_setrx(&runner, conf_path);
- runner_add_args(
- &runner, "log-file-mbr",
- DEFAULT_LOG_FILE_DIRECTORY
- "/" GEOREP
- "-slaves/mbr/${session_owner}:${local_node}${local_id}.${slavevol}.log",
- ".", NULL);
+ runner_add_arg(&runner, "log-file-mbr");
+ runner_argprintf(&runner,
+ "%s/%s-slaves/mbr/"
+ "${session_owner}:${local_node}${local_id}.${slavevol}."
+ "log",
+ conf->logdir, GEOREP);
+ runner_add_args(&runner, ".", ".", NULL);
RUN_GSYNCD_CMD;
/* gluster-log-file */
runinit_gsyncd_setrx(&runner, conf_path);
- runner_add_args(
- &runner, "gluster-log-file",
- DEFAULT_LOG_FILE_DIRECTORY
- "/" GEOREP
- "-slaves/"
- "${session_owner}:${local_node}${local_id}.${slavevol}.gluster.log",
- ".", NULL);
+ runner_add_arg(&runner, "gluster-log-file");
+ runner_argprintf(&runner,
+ "%s/%s-slaves/"
+ "${session_owner}:${local_node}${local_id}.${slavevol}."
+ "gluster.log",
+ conf->logdir, GEOREP);
+ runner_add_args(&runner, ".", ".", NULL);
RUN_GSYNCD_CMD;
out:
@@ -6395,7 +6399,7 @@ glusterd_create_essential_dir_files(glusterd_volinfo_t *volinfo, dict_t *dict,
goto out;
}
- ret = snprintf(buf, PATH_MAX, DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP "/%s",
+ ret = snprintf(buf, PATH_MAX, "%s/" GEOREP "/%s", conf->logdir,
volinfo->volname);
if ((ret < 0) || (ret >= PATH_MAX)) {
ret = -1;
diff --git a/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc-helper.c
index e338bf4..319bfa1 100644
--- a/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc-helper.c
+++ b/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc-helper.c
@@ -81,7 +81,8 @@ glusterd_svc_build_gfproxyd_volfile_path(glusterd_volinfo_t *volinfo,
void
glusterd_svc_build_gfproxyd_logdir(char *logdir, char *volname, size_t len)
{
- snprintf(logdir, len, "%s/gfproxy/%s", DEFAULT_LOG_FILE_DIRECTORY, volname);
+ glusterd_conf_t *conf = THIS->private;
+ snprintf(logdir, len, "%s/gfproxy/%s", conf->logdir, volname);
}
void
diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h
index 3a6e940..9280c81 100644
--- a/xlators/mgmt/glusterd/src/glusterd-messages.h
+++ b/xlators/mgmt/glusterd/src/glusterd-messages.h
@@ -301,6 +301,6 @@ GLFS_MSGID(
GD_MSG_DAEMON_LOG_LEVEL_VOL_OPT_VALIDATE_FAIL, GD_MSG_SHD_START_FAIL,
GD_MSG_SHD_OBJ_GET_FAIL, GD_MSG_SVC_ATTACH_FAIL, GD_MSG_ATTACH_INFO,
GD_MSG_DETACH_INFO, GD_MSG_SVC_DETACH_FAIL,
- GD_MSG_RPC_TRANSPORT_GET_PEERNAME_FAIL);
+ GD_MSG_RPC_TRANSPORT_GET_PEERNAME_FAIL, GD_MSG_CLUSTER_RC_ENABLE);
#endif /* !_GLUSTERD_MESSAGES_H_ */
diff --git a/xlators/mgmt/glusterd/src/glusterd-mountbroker.c b/xlators/mgmt/glusterd/src/glusterd-mountbroker.c
index 691b96f..9c4b2fb 100644
--- a/xlators/mgmt/glusterd/src/glusterd-mountbroker.c
+++ b/xlators/mgmt/glusterd/src/glusterd-mountbroker.c
@@ -233,7 +233,7 @@ const char *georep_mnt_desc_template =
"user-map-root=%s "
")"
"SUB+("
- "log-file=" DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP
+ "log-file=%s/" GEOREP
"*/* "
"log-level=* "
"volfile-id=* "
@@ -243,7 +243,8 @@ const char *georep_mnt_desc_template =
")";
int
-make_georep_mountspec(gf_mount_spec_t *mspec, const char *volnames, char *user)
+make_georep_mountspec(gf_mount_spec_t *mspec, const char *volnames, char *user,
+ char *logdir)
{
char *georep_mnt_desc = NULL;
char *meetspec = NULL;
@@ -286,7 +287,7 @@ make_georep_mountspec(gf_mount_spec_t *mspec, const char *volnames, char *user)
}
ret = gf_asprintf(&georep_mnt_desc, georep_mnt_desc_template,
- GF_CLIENT_PID_GSYNCD, user, meetspec);
+ GF_CLIENT_PID_GSYNCD, user, logdir, meetspec);
if (ret == -1) {
georep_mnt_desc = NULL;
goto out;
diff --git a/xlators/mgmt/glusterd/src/glusterd-mountbroker.h b/xlators/mgmt/glusterd/src/glusterd-mountbroker.h
index c871522..20c1347 100644
--- a/xlators/mgmt/glusterd/src/glusterd-mountbroker.h
+++ b/xlators/mgmt/glusterd/src/glusterd-mountbroker.h
@@ -30,7 +30,8 @@ int
parse_mount_pattern_desc(gf_mount_spec_t *mspec, char *pdesc);
int
-make_georep_mountspec(gf_mount_spec_t *mspec, const char *volname, char *user);
+make_georep_mountspec(gf_mount_spec_t *mspec, const char *volname, char *user,
+ char *logdir);
int
glusterd_do_mount(char *label, dict_t *argdict, char **path, int *op_errno);
diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c
index 6436799..53d5605 100644
--- a/xlators/mgmt/glusterd/src/glusterd-quota.c
+++ b/xlators/mgmt/glusterd/src/glusterd-quota.c
@@ -2046,8 +2046,8 @@ glusterd_create_quota_auxiliary_mount(xlator_t *this, char *volname, int type)
mountdir);
goto out;
}
- snprintf(logfile, PATH_MAX - 1, "%s/quota-mount-%s.log",
- DEFAULT_LOG_FILE_DIRECTORY, volname);
+ snprintf(logfile, PATH_MAX - 1, "%s/quota-mount-%s.log", priv->logdir,
+ volname);
snprintf(qpid, 15, "%d", GF_CLIENT_PID_QUOTA_MOUNT);
if (dict_get_strn(this->options, "transport.socket.bind-address",
diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
index d440a71..4ce20a9 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
@@ -266,13 +266,13 @@ glusterd_handle_defrag_start(glusterd_volinfo_t *volinfo, char *op_errstr,
GLUSTERD_GET_DEFRAG_SOCK_FILE(sockfile, volinfo);
GLUSTERD_GET_DEFRAG_PID_FILE(pidfile, volinfo, priv);
- snprintf(logfile, PATH_MAX, "%s/%s-%s.log", DEFAULT_LOG_FILE_DIRECTORY,
- volinfo->volname, "rebalance");
+ snprintf(logfile, PATH_MAX, "%s/%s-%s.log", priv->logdir, volinfo->volname,
+ "rebalance");
runinit(&runner);
if (this->ctx->cmd_args.valgrind) {
snprintf(valgrind_logfile, PATH_MAX, "%s/valgrind-%s-rebalance.log",
- DEFAULT_LOG_FILE_DIRECTORY, volinfo->volname);
+ priv->logdir, volinfo->volname);
runner_add_args(&runner, "valgrind", "--leak-check=full",
"--trace-children=yes", "--track-origins=yes", NULL);
diff --git a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
index 81594e3..5077ec1 100644
--- a/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
+++ b/xlators/mgmt/glusterd/src/glusterd-shd-svc.c
@@ -90,8 +90,8 @@ glusterd_shdsvc_init(void *data, glusterd_conn_t *mux_conn,
GLUSTERD_GET_SHD_RUNDIR(rundir, volinfo, priv);
glusterd_svc_create_rundir(rundir);
- glusterd_svc_build_logfile_path(shd_svc_name, DEFAULT_LOG_FILE_DIRECTORY,
- logfile, sizeof(logfile));
+ glusterd_svc_build_logfile_path(shd_svc_name, priv->logdir, logfile,
+ sizeof(logfile));
/* Initialize the connection mgmt */
if (mux_conn && mux_svc->rpc) {
@@ -104,7 +104,7 @@ glusterd_shdsvc_init(void *data, glusterd_conn_t *mux_conn,
if (ret < 0)
goto out;
} else {
- ret = mkdir_p(DEFAULT_LOG_FILE_DIRECTORY, 0755, _gf_true);
+ ret = mkdir_p(priv->logdir, 0755, _gf_true);
if ((ret == -1) && (EEXIST != errno)) {
gf_msg(this->name, GF_LOG_ERROR, errno, GD_MSG_CREATE_DIR_FAILED,
"Unable to create logdir %s", logdir);
diff --git a/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c b/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c
index 1da4076..3042789 100644
--- a/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c
+++ b/xlators/mgmt/glusterd/src/glusterd-snapd-svc.c
@@ -27,7 +27,8 @@ char *snapd_svc_name = "snapd";
static void
glusterd_svc_build_snapd_logdir(char *logdir, char *volname, size_t len)
{
- snprintf(logdir, len, "%s/snaps/%s", DEFAULT_LOG_FILE_DIRECTORY, volname);
+ glusterd_conf_t *priv = THIS->private;
+ snprintf(logdir, len, "%s/snaps/%s", priv->logdir, volname);
}
static void
diff --git a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c
index c2b3149..f4f39d9 100644
--- a/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c
+++ b/xlators/mgmt/glusterd/src/glusterd-svc-mgmt.c
@@ -144,7 +144,7 @@ glusterd_svc_init(glusterd_svc_t *svc, char *svc_name)
glusterd_svc_build_rundir(svc_name, priv->rundir, rundir, sizeof(rundir));
ret = glusterd_svc_init_common(svc, svc_name, priv->workdir, rundir,
- DEFAULT_LOG_FILE_DIRECTORY, NULL);
+ priv->logdir, NULL);
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-tierd-svc-helper.c b/xlators/mgmt/glusterd/src/glusterd-tierd-svc-helper.c
index 59843a0..035795b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-tierd-svc-helper.c
+++ b/xlators/mgmt/glusterd/src/glusterd-tierd-svc-helper.c
@@ -81,7 +81,8 @@ glusterd_svc_build_tierd_volfile_path(glusterd_volinfo_t *volinfo, char *path,
void
glusterd_svc_build_tierd_logdir(char *logdir, char *volname, size_t len)
{
- snprintf(logdir, len, "%s/tier/%s", DEFAULT_LOG_FILE_DIRECTORY, volname);
+ glusterd_conf_t *conf = THIS->private;
+ snprintf(logdir, len, "%s/tier/%s", priv->logdir, volname);
}
void
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index c2fefc1..59b9cbe 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -2003,9 +2003,9 @@ retry:
len = snprintf(valgrind_logfile, PATH_MAX, "%s/valgrind-%s-%s.log",
volinfo->logdir, volinfo->volname, exp_path);
} else {
- len = snprintf(
- valgrind_logfile, PATH_MAX, "%s/bricks/valgrind-%s-%s.log",
- DEFAULT_LOG_FILE_DIRECTORY, volinfo->volname, exp_path);
+ len = snprintf(valgrind_logfile, PATH_MAX,
+ "%s/bricks/valgrind-%s-%s.log", priv->logdir,
+ volinfo->volname, exp_path);
}
if ((len < 0) || (len >= PATH_MAX)) {
ret = -1;
@@ -2035,8 +2035,8 @@ retry:
len = snprintf(logfile, PATH_MAX, "%s/%s.log", volinfo->logdir,
exp_path);
} else {
- len = snprintf(logfile, PATH_MAX, "%s/bricks/%s.log",
- DEFAULT_LOG_FILE_DIRECTORY, exp_path);
+ len = snprintf(logfile, PATH_MAX, "%s/bricks/%s.log", priv->logdir,
+ exp_path);
}
if ((len < 0) || (len >= PATH_MAX)) {
ret = -1;
@@ -13712,9 +13712,8 @@ glusterd_handle_replicate_brick_ops(glusterd_volinfo_t *volinfo,
&volfileserver) != 0)
volfileserver = "localhost";
- snprintf(logfile, sizeof(logfile),
- DEFAULT_LOG_FILE_DIRECTORY "/%s-replace-brick-mount.log",
- volinfo->volname);
+ snprintf(logfile, sizeof(logfile), "%s/%s-replace-brick-mount.log",
+ priv->logdir, volinfo->volname);
if (!*logfile) {
ret = -1;
goto out;
@@ -13726,9 +13725,8 @@ glusterd_handle_replicate_brick_ops(glusterd_volinfo_t *volinfo,
break;
case GD_OP_ADD_BRICK:
- snprintf(logfile, sizeof(logfile),
- DEFAULT_LOG_FILE_DIRECTORY "/%s-add-brick-mount.log",
- volinfo->volname);
+ snprintf(logfile, sizeof(logfile), "%s/%s-add-brick-mount.log",
+ priv->logdir, volinfo->volname);
if (!*logfile) {
ret = -1;
goto out;
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
index 4624fe1..cd92a16 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
@@ -2892,8 +2892,7 @@ glusterd_clearlocks_mount(glusterd_volinfo_t *volinfo, char **xl_opts,
runner_add_args(&runner, SBIN_DIR "/glusterfs", "-f", NULL);
runner_argprintf(&runner, "%s", client_volfpath);
runner_add_arg(&runner, "-l");
- runner_argprintf(&runner,
- DEFAULT_LOG_FILE_DIRECTORY "/%s-clearlocks-mnt.log",
+ runner_argprintf(&runner, "%s/%s-clearlocks-mnt.log", priv->logdir,
volinfo->volname);
if (volinfo->memory_accounting)
runner_add_arg(&runner, "--mem-accounting");
diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c
index 39f46a2..7da16ea 100644
--- a/xlators/mgmt/glusterd/src/glusterd.c
+++ b/xlators/mgmt/glusterd/src/glusterd.c
@@ -555,7 +555,9 @@ glusterd_crt_georep_folders(char *georepdir, glusterd_conf_t *conf)
char *greplg_s = NULL;
struct group *gr = NULL;
int ret = 0;
+ int gr_ret = 0;
int32_t len = 0;
+ char logdir[PATH_MAX] = {0};
GF_ASSERT(georepdir);
GF_ASSERT(conf);
@@ -580,77 +582,91 @@ glusterd_crt_georep_folders(char *georepdir, glusterd_conf_t *conf)
goto out;
}
- if (SLEN(DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP) >= PATH_MAX) {
+ ret = dict_get_str(THIS->options, GEOREP "-log-group", &greplg_s);
+ if (ret)
+ ret = 0;
+ else {
+ gr = getgrnam(greplg_s);
+ if (!gr) {
+ gf_msg("glusterd", GF_LOG_CRITICAL, 0, GD_MSG_LOGGROUP_INVALID,
+ "group " GEOREP "-log-group %s does not exist", greplg_s);
+ gr_ret = -1;
+ }
+ }
+ if ((strlen(conf->logdir) + 2 + SLEN(GEOREP)) >= PATH_MAX) {
ret = -1;
gf_msg("glusterd", GF_LOG_CRITICAL, 0, GD_MSG_DIRPATH_TOO_LONG,
- "directory path " DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP
- " is longer than PATH_MAX");
+ "directory path %s/" GEOREP " is longer than PATH_MAX",
+ conf->logdir);
+ goto out;
+ }
+ len = snprintf(logdir, PATH_MAX, "%s/" GEOREP, conf->logdir);
+ if ((len < 0) || (len >= PATH_MAX)) {
+ ret = -1;
goto out;
}
- ret = mkdir_p(DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP, 0755, _gf_true);
+ ret = mkdir_p(logdir, 0755, _gf_true);
if (-1 == ret) {
gf_msg("glusterd", GF_LOG_CRITICAL, errno, GD_MSG_CREATE_DIR_FAILED,
"Unable to create " GEOREP " log directory");
goto out;
}
+ if (gr) {
+ gr_ret = group_write_allow(logdir, gr->gr_gid);
+ }
- /* Slave log file directory */
- if (SLEN(DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP "-slaves") >= PATH_MAX) {
+ if ((strlen(conf->logdir) + 2 + SLEN(GEOREP "-slaves")) >= PATH_MAX) {
ret = -1;
gf_msg("glusterd", GF_LOG_CRITICAL, 0, GD_MSG_DIRPATH_TOO_LONG,
- "directory path " DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP
+ "directory path %s/" GEOREP
"-slaves"
- " is longer than PATH_MAX");
+ " is longer than PATH_MAX",
+ conf->logdir);
+ goto out;
+ }
+ len = snprintf(logdir, PATH_MAX, "%s/" GEOREP "-slaves", conf->logdir);
+ if ((len < 0) || (len >= PATH_MAX)) {
+ ret = -1;
goto out;
}
- ret = mkdir_p(DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP "-slaves", 0755,
- _gf_true);
+ ret = mkdir_p(logdir, 0755, _gf_true);
if (-1 == ret) {
gf_msg("glusterd", GF_LOG_CRITICAL, errno, GD_MSG_CREATE_DIR_FAILED,
"Unable to create " GEOREP " slave log directory");
goto out;
}
+ if (gr && !gr_ret) {
+ gr_ret = group_write_allow(logdir, gr->gr_gid);
+ }
/* MountBroker log file directory */
- if (SLEN(DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP "-slaves/mbr") >= PATH_MAX) {
+ if ((strlen(conf->logdir) + 2 + SLEN(GEOREP "-slaves/mbr")) >= PATH_MAX) {
ret = -1;
gf_msg("glusterd", GF_LOG_CRITICAL, 0, GD_MSG_DIRPATH_TOO_LONG,
- "directory path " DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP
+ "directory path %s/" GEOREP
"-slaves/mbr"
- " is longer than PATH_MAX");
+ " is longer than PATH_MAX",
+ conf->logdir);
+ goto out;
+ }
+
+ len = snprintf(logdir, PATH_MAX, "%s/" GEOREP "-slaves/mbr", conf->logdir);
+ if ((len < 0) || (len >= PATH_MAX)) {
+ ret = -1;
goto out;
}
- ret = mkdir_p(DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP "-slaves/mbr", 0755,
- _gf_true);
+
+ ret = mkdir_p(logdir, 0755, _gf_true);
if (-1 == ret) {
gf_msg("glusterd", GF_LOG_CRITICAL, errno, GD_MSG_CREATE_DIR_FAILED,
"Unable to create " GEOREP " mountbroker slave log directory");
goto out;
}
-
- ret = dict_get_str(THIS->options, GEOREP "-log-group", &greplg_s);
- if (ret)
- ret = 0;
- else {
- gr = getgrnam(greplg_s);
- if (!gr) {
- gf_msg("glusterd", GF_LOG_CRITICAL, 0, GD_MSG_LOGGROUP_INVALID,
- "group " GEOREP "-log-group %s does not exist", greplg_s);
- ret = -1;
- goto out;
- }
-
- ret = group_write_allow(DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP,
- gr->gr_gid);
- if (ret == 0)
- ret = group_write_allow(
- DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP "-slaves", gr->gr_gid);
- if (ret == 0)
- ret = group_write_allow(DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP
- "-slaves/mbr",
- gr->gr_gid);
+ if (gr && !gr_ret) {
+ gr_ret = group_write_allow(logdir, gr->gr_gid);
}
-
+ if (gr_ret)
+ ret = gr_ret;
out:
gf_msg_debug("glusterd", 0, "Returning %d", ret);
return ret;
@@ -814,18 +830,19 @@ configure_syncdaemon(glusterd_conf_t *conf)
/* log-file */
runinit_gsyncd_setrx(&runner, conf);
- runner_add_args(&runner, "log-file",
- DEFAULT_LOG_FILE_DIRECTORY "/" GEOREP
- "/${mastervol}/${eSlave}.log",
- ".", ".", NULL);
+ runner_add_arg(&runner, "log-file");
+ runner_argprintf(&runner, "%s/" GEOREP "/${mastervol}/${eSlave}.log",
+ conf->logdir);
+ runner_add_args(&runner, ".", ".", NULL);
RUN_GSYNCD_CMD;
/* gluster-log-file */
runinit_gsyncd_setrx(&runner, conf);
- runner_add_args(&runner, "gluster-log-file",
- DEFAULT_LOG_FILE_DIRECTORY
- "/" GEOREP "/${mastervol}/${eSlave}${local_id}.gluster.log",
- ".", ".", NULL);
+ runner_add_arg(&runner, "gluster-log-file");
+ runner_argprintf(
+ &runner, "%s/" GEOREP "/${mastervol}/${eSlave}${local_id}.gluster.log",
+ conf->logdir);
+ runner_add_args(&runner, ".", ".", NULL);
RUN_GSYNCD_CMD;
/* ignore-deletes */
@@ -867,33 +884,36 @@ configure_syncdaemon(glusterd_conf_t *conf)
/* log-file */
runinit_gsyncd_setrx(&runner, conf);
- runner_add_args(
- &runner, "log-file",
- DEFAULT_LOG_FILE_DIRECTORY
- "/" GEOREP
+ runner_add_arg(&runner, "log-file");
+ runner_argprintf(
+ &runner,
+ "%s/" GEOREP
"-slaves/${session_owner}:${local_node}${local_id}.${slavevol}.log",
- ".", NULL);
+ conf->logdir);
+ runner_add_args(&runner, ".", ".", NULL);
RUN_GSYNCD_CMD;
/* MountBroker log-file */
runinit_gsyncd_setrx(&runner, conf);
- runner_add_args(
- &runner, "log-file-mbr",
- DEFAULT_LOG_FILE_DIRECTORY
- "/" GEOREP
+ runner_add_arg(&runner, "log-file-mbr");
+ runner_argprintf(
+ &runner,
+ "%s/" GEOREP
"-slaves/mbr/${session_owner}:${local_node}${local_id}.${slavevol}.log",
- ".", NULL);
+ conf->logdir);
+ runner_add_args(&runner, ".", ".", NULL);
RUN_GSYNCD_CMD;
/* gluster-log-file */
runinit_gsyncd_setrx(&runner, conf);
- runner_add_args(
- &runner, "gluster-log-file",
- DEFAULT_LOG_FILE_DIRECTORY
- "/" GEOREP
+ runner_add_arg(&runner, "gluster-log-file");
+ runner_argprintf(
+ &runner,
+ "%s/" GEOREP
"-slaves/"
"${session_owner}:${local_node}${local_id}.${slavevol}.gluster.log",
- ".", NULL);
+ conf->logdir);
+ runner_add_args(&runner, ".", ".", NULL);
RUN_GSYNCD_CMD;
out:
@@ -1052,7 +1072,7 @@ _install_mount_spec(dict_t *opts, char *key, data_t *value, void *data)
} else
user = label;
- rv = make_georep_mountspec(mspec, volname, user);
+ rv = make_georep_mountspec(mspec, volname, user, priv->logdir);
GF_FREE(volname);
if (rv != 0)
@@ -1373,6 +1393,9 @@ init(xlator_t *this)
char rundir[PATH_MAX] = {
0,
};
+ char logdir[VALID_GLUSTERD_PATHMAX] = {
+ 0,
+ };
char cmd_log_filename[PATH_MAX] = {
0,
};
@@ -1421,6 +1444,25 @@ init(xlator_t *this)
if (len < 0 || len >= PATH_MAX)
exit(2);
+ dir_data = dict_get(this->options, "cluster-test-mode");
+ if (!dir_data) {
+ /* Use default working dir */
+ len = snprintf(logdir, PATH_MAX, "%s", DEFAULT_LOG_FILE_DIRECTORY);
+ } else {
+ len = snprintf(logdir, PATH_MAX, "%s", dir_data->data);
+ gf_msg(this->name, GF_LOG_INFO, 0, GD_MSG_CLUSTER_RC_ENABLE,
+ "cluster-test-mode is enabled logdir is %s", dir_data->data);
+ }
+ if (len < 0 || len >= PATH_MAX)
+ exit(2);
+
+ ret = mkdir_p(logdir, 0777, _gf_true);
+ if ((ret == -1) && (EEXIST != errno)) {
+ gf_msg(THIS->name, GF_LOG_ERROR, errno, GD_MSG_CREATE_DIR_FAILED,
+ "Unable to create log dir %s", logdir);
+ exit(1);
+ }
+
dir_data = dict_get(this->options, "working-directory");
if (!dir_data) {
@@ -1535,8 +1577,7 @@ init(xlator_t *this)
exit(1);
}
- snprintf(cmd_log_filename, PATH_MAX, "%s/cmd_history.log",
- DEFAULT_LOG_FILE_DIRECTORY);
+ snprintf(cmd_log_filename, PATH_MAX, "%s/cmd_history.log", logdir);
ret = gf_cmd_log_init(cmd_log_filename);
if (ret == -1) {
@@ -1606,8 +1647,7 @@ init(xlator_t *this)
exit(1);
}
- len = snprintf(storedir, sizeof(storedir), "%s/bricks",
- DEFAULT_LOG_FILE_DIRECTORY);
+ len = snprintf(storedir, sizeof(storedir), "%s/bricks", logdir);
if ((len < 0) || (len >= sizeof(storedir))) {
exit(1);
}
@@ -1822,6 +1862,9 @@ init(xlator_t *this)
/* coverity[BUFFER_SIZE_WARNING] */
(void)strncpy(conf->rundir, rundir, sizeof(conf->rundir));
+ /* coverity[BUFFER_SIZE_WARNING] */
+ (void)strncpy(conf->logdir, logdir, sizeof(conf->logdir));
+
synclock_init(&conf->big_lock, SYNC_LOCK_RECURSIVE);
pthread_mutex_init(&conf->xprt_lock, NULL);
INIT_LIST_HEAD(&conf->xprt_list);
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index 85fad2d..00211da 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -227,6 +227,7 @@ typedef struct {
*/
char workdir[VALID_GLUSTERD_PATHMAX];
char rundir[VALID_GLUSTERD_PATHMAX];
+ char logdir[VALID_GLUSTERD_PATHMAX];
} glusterd_conf_t;
typedef struct glusterd_add_dict_args {