summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2012-03-31 20:43:12 +0530
committerVijay Bellur <vijay@gluster.com>2012-04-01 05:53:42 -0700
commitc2dd1510e18e4c91d54ce4de91ecd47b408524dd (patch)
treef74e5807c970857137e637efdfb3938af7f2bdea /xlators/mgmt/glusterd
parent778c8d616ba2e9b47cafbbe95dbec7f2eb788302 (diff)
mgmt/glusterd: Improvements for volume heal CLI.
1) Brought in a CLI improvement for volume heal cmd when it fails before initiating a transaction. 2) Minor improvements in UI messages related to self-heal-daemon. Change-Id: I983c1e54b48f2efe8793fa5b00fa50df2067683b BUG: 807261 Signed-off-by: Vijay Bellur <vijay@gluster.com> Reviewed-on: http://review.gluster.com/3057 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Pranith Kumar Karampuri <pranithk@gluster.com>
Diffstat (limited to 'xlators/mgmt/glusterd')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c2
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c19
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-ops.c35
4 files changed, 36 insertions, 23 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 993ddddb2b4..d548b95a8b6 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -690,7 +690,7 @@ glusterd_op_stage_status_volume (dict_t *dict, char **op_errstr)
if (!glusterd_is_volume_replicate (volinfo)) {
ret = -1;
snprintf (msg, sizeof (msg),
- "Volume %s is not a replicate volume",
+ "Volume %s is not of type replicate",
volname);
gf_log (THIS->name, GF_LOG_ERROR, "%s", msg);
goto out;
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 9f1dba151b6..ec191e4f930 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -1579,29 +1579,26 @@ _add_volinfo_dict_to_prdict (dict_t *this, char *key, data_t *value, void *data)
}
int32_t
-glusterd_add_bricks_hname_path_to_dict (dict_t *dict)
+glusterd_add_bricks_hname_path_to_dict (dict_t *dict,
+ glusterd_volinfo_t *volinfo)
{
- char *volname = NULL;
- glusterd_volinfo_t *volinfo = NULL;
glusterd_brickinfo_t *brickinfo = NULL;
int ret = 0;
char key[256] = {0};
int index = 0;
- ret = dict_get_str (dict, "volname", &volname);
- if (ret) {
- gf_log ("", GF_LOG_ERROR, "Unable to get volume name");
- goto out;
- }
- ret = glusterd_volinfo_find (volname, &volinfo);
- if (ret)
- goto out;
list_for_each_entry (brickinfo, &volinfo->bricks, brick_list) {
snprintf (key, sizeof (key), "%d-hostname", index);
ret = dict_set_str (dict, key, brickinfo->hostname);
+ if (ret)
+ goto out;
+
snprintf (key, sizeof (key), "%d-path", index);
ret = dict_set_str (dict, key, brickinfo->path);
+ if (ret)
+ goto out;
+
index++;
}
out:
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.h b/xlators/mgmt/glusterd/src/glusterd-utils.h
index 6e02929f1ec..9cea974c179 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.h
@@ -416,7 +416,8 @@ int
glusterd_restart_rebalance (glusterd_conf_t *conf);
int32_t
-glusterd_add_bricks_hname_path_to_dict (dict_t *dict);
+glusterd_add_bricks_hname_path_to_dict (dict_t *dict,
+ glusterd_volinfo_t *volinfo);
int
glusterd_add_node_to_dict (char *server, dict_t *dict, int count);
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
index 8da30779011..0a076e7213a 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c
@@ -450,6 +450,8 @@ glusterd_handle_cli_heal_volume (rpcsvc_request_t *req)
glusterd_op_t cli_op = GD_OP_HEAL_VOLUME;
char *volname = NULL;
glusterd_volinfo_t *volinfo = NULL;
+ xlator_t *this = NULL;
+ char *op_errstr = NULL;
GF_ASSERT (req);
@@ -460,6 +462,8 @@ glusterd_handle_cli_heal_volume (rpcsvc_request_t *req)
goto out;
}
+ this = THIS;
+
if (cli_req.dict.dict_len) {
/* Unserialize the dictionary */
dict = dict_new ();
@@ -468,7 +472,7 @@ glusterd_handle_cli_heal_volume (rpcsvc_request_t *req)
cli_req.dict.dict_len,
&dict);
if (ret < 0) {
- gf_log (THIS->name, GF_LOG_ERROR,
+ gf_log (this->name, GF_LOG_ERROR,
"failed to "
"unserialize req-buffer to dictionary");
goto out;
@@ -479,21 +483,28 @@ glusterd_handle_cli_heal_volume (rpcsvc_request_t *req)
ret = dict_get_str (dict, "volname", &volname);
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, "failed to get volname");
+ gf_log (this->name, GF_LOG_ERROR, "failed to get volname");
+ gf_asprintf (&op_errstr, "Unable to find volume name");
goto out;
}
- gf_log ("glusterd", GF_LOG_INFO, "Received heal vol req "
+
+ gf_log (this->name, GF_LOG_INFO, "Received heal vol req "
"for volume %s", volname);
- ret = glusterd_add_bricks_hname_path_to_dict (dict);
- if (ret)
- goto out;
ret = glusterd_volinfo_find (volname, &volinfo);
+ if (ret) {
+ gf_asprintf (&op_errstr, "Volume %s does not exist", volname);
+ goto out;
+ }
+
+ ret = glusterd_add_bricks_hname_path_to_dict (dict, volinfo);
if (ret)
goto out;
+
ret = dict_set_int32 (dict, "count", volinfo->brick_count);
if (ret)
goto out;
+
ret = glusterd_op_begin (req, GD_OP_HEAL_VOLUME, dict);
gf_cmd_log ("volume heal","on volname: %s %s", volname,
@@ -506,9 +517,13 @@ out:
glusterd_friend_sm ();
glusterd_op_sm ();
- if (ret)
+ if (ret) {
+ if (!op_errstr)
+ op_errstr = gf_strdup ("operation failed");
ret = glusterd_op_send_cli_response (cli_op, ret, 0, req,
- NULL, "operation failed");
+ NULL, op_errstr);
+ GF_FREE (op_errstr);
+ }
return ret;
}
@@ -1043,8 +1058,8 @@ glusterd_op_stage_heal_volume (dict_t *dict, char **op_errstr)
if (!glusterd_is_volume_replicate (volinfo)) {
ret = -1;
- snprintf (msg, sizeof (msg), "Volume %s is not a replicate "
- "type volume", volname);
+ snprintf (msg, sizeof (msg), "Volume %s is not of type "
+ "replicate", volname);
*op_errstr = gf_strdup (msg);
gf_log (THIS->name, GF_LOG_WARNING, "%s", msg);
goto out;