Improve cli output of gluster volume heal command.
Improving cli outputs according to the type of the volume, the "heal" action can be performed on the volume. Also checks if the volume is started & then if the "self-heal" daemon is not started, prints appropriate message. Change-Id: I25b0822e4d518c50e2f1173aa8c7c11ae6b76d3f BUG: 769774 Signed-off-by: Rahul C S <rahulcs@redhat.com> Reviewed-on: http://review.gluster.com/2496 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Krishnan Parthasarathi <kp@gluster.com>
This commit is contained in:
parent
d7d9f3d400
commit
31fa069329
@ -965,7 +965,6 @@ glusterd_op_stage_heal_volume (dict_t *dict, char **op_errstr)
|
||||
{
|
||||
int ret = 0;
|
||||
char *volname = NULL;
|
||||
gf_boolean_t exists = _gf_false;
|
||||
gf_boolean_t enabled = _gf_false;
|
||||
glusterd_volinfo_t *volinfo = NULL;
|
||||
char msg[2048];
|
||||
@ -974,18 +973,9 @@ glusterd_op_stage_heal_volume (dict_t *dict, char **op_errstr)
|
||||
|
||||
priv = THIS->private;
|
||||
if (!priv) {
|
||||
ret = -1;
|
||||
gf_log (THIS->name, GF_LOG_ERROR,
|
||||
"priv is NULL");
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!glusterd_shd_is_running ()) {
|
||||
ret = -1;
|
||||
snprintf (msg, sizeof (msg), "Self-heal daemon is not "
|
||||
"running.");
|
||||
*op_errstr = gf_strdup (msg);
|
||||
gf_log (THIS->name, GF_LOG_WARNING, "%s", msg);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -995,38 +985,30 @@ glusterd_op_stage_heal_volume (dict_t *dict, char **op_errstr)
|
||||
goto out;
|
||||
}
|
||||
|
||||
exists = glusterd_check_volume_exists (volname);
|
||||
|
||||
if (!exists) {
|
||||
snprintf (msg, sizeof (msg), "Volume %s does not exist", volname);
|
||||
gf_log ("", GF_LOG_ERROR, "%s",
|
||||
msg);
|
||||
*op_errstr = gf_strdup (msg);
|
||||
ret = -1;
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
ret = glusterd_volinfo_find (volname, &volinfo);
|
||||
|
||||
if (ret)
|
||||
goto out;
|
||||
|
||||
if (!glusterd_is_volume_started (volinfo)) {
|
||||
snprintf (msg, sizeof (msg), "Volume %s is not started.",
|
||||
volname);
|
||||
gf_log (THIS->name, GF_LOG_WARNING, "%s", msg);
|
||||
*op_errstr = gf_strdup (msg);
|
||||
if (ret) {
|
||||
ret = -1;
|
||||
snprintf (msg, sizeof (msg), "Volume %s does not exist", volname);
|
||||
gf_log (THIS->name, GF_LOG_ERROR, "%s", msg);
|
||||
*op_errstr = gf_strdup (msg);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!glusterd_is_volume_replicate (volinfo)) {
|
||||
snprintf (msg, sizeof (msg), "Volume %s is not of type."
|
||||
"replicate", volname);
|
||||
ret = -1;
|
||||
snprintf (msg, sizeof (msg), "Volume %s is not a replicate "
|
||||
"type volume", volname);
|
||||
*op_errstr = gf_strdup (msg);
|
||||
gf_log (THIS->name, GF_LOG_WARNING, "%s", msg);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!glusterd_is_volume_started (volinfo)) {
|
||||
ret = -1;
|
||||
snprintf (msg, sizeof (msg), "Volume %s is not started.",
|
||||
volname);
|
||||
gf_log (THIS->name, GF_LOG_WARNING, "%s", msg);
|
||||
*op_errstr = gf_strdup (msg);
|
||||
ret = -1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -1039,12 +1021,21 @@ glusterd_op_stage_heal_volume (dict_t *dict, char **op_errstr)
|
||||
enabled = dict_get_str_boolean (opt_dict, "cluster.self-heal-daemon",
|
||||
1);
|
||||
if (!enabled) {
|
||||
ret = -1;
|
||||
snprintf (msg, sizeof (msg), "Self-heal-daemon is "
|
||||
"disabled. Heal will not be triggered on volume %s",
|
||||
volname);
|
||||
gf_log (THIS->name, GF_LOG_WARNING, "%s", msg);
|
||||
*op_errstr = gf_strdup (msg);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!glusterd_shd_is_running ()) {
|
||||
ret = -1;
|
||||
snprintf (msg, sizeof (msg), "Self-heal daemon is not "
|
||||
"running. Check self-heal daemon log file.");
|
||||
*op_errstr = gf_strdup (msg);
|
||||
gf_log (THIS->name, GF_LOG_WARNING, "%s", msg);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user