summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshishir gowda <shishirng@gluster.com>2012-04-04 16:04:10 +0530
committerVijay Bellur <vijay@gluster.com>2012-04-06 03:38:49 -0700
commit1222e2ae2d42cf12569a0cf00bb1f1504ef4e7b7 (patch)
tree657744f7c1b5828294473438c1c64f670c77bce4
parent7768d700a18f5bdb1e4640070ec5dd380384c7a9 (diff)
remove-brick: Abort should revert volume changes
Also, enhanced gluster cli output. Signed-off-by: shishir gowda <shishirng@gluster.com> Change-Id: I520ccfb63b3568a2e6654d8a5fbf265b9b903af1 BUG: 788524 Reviewed-on: http://review.gluster.com/3082 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
-rw-r--r--cli/src/cli-rpc-ops.c43
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-brick-ops.c27
2 files changed, 60 insertions, 10 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 70c9a3d80aa..779508ad709 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -1557,6 +1557,9 @@ gf_cli3_1_remove_brick_cbk (struct rpc_req *req, struct iovec *iov,
gf_cli_rsp rsp = {0,};
int ret = -1;
char msg[1024] = {0,};
+ gf1_op_commands cmd = GF_OP_CMD_NONE;
+ dict_t *dict = NULL;
+ char *cmd_str = "unknown";
if (-1 == req->rpc_status) {
goto out;
@@ -1568,12 +1571,47 @@ gf_cli3_1_remove_brick_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
+ dict = dict_new ();
+
+ ret = dict_unserialize (rsp.dict.dict_val, rsp.dict.dict_len, &dict);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "failed to unserialize rsp to dict");
+ goto out;
+ }
+ ret = dict_get_int32 (dict, "command", (int32_t *)&cmd);
+ if (ret) {
+ gf_log ("", GF_LOG_ERROR, "failed to get command");
+ goto out;
+ }
+
+ switch (cmd) {
+
+ case GF_OP_CMD_START:
+ cmd_str = "start";
+ break;
+ case GF_OP_CMD_COMMIT:
+ cmd_str = "commit";
+ break;
+ case GF_OP_CMD_ABORT:
+ cmd_str = "abort";
+ break;
+ case GF_OP_CMD_PAUSE:
+ cmd_str = "pause";
+ break;
+ case GF_OP_CMD_COMMIT_FORCE:
+ cmd_str = "commit force";
+ break;
+ default:
+ cmd_str = "unkown";
+ break;
+ }
+
gf_log ("cli", GF_LOG_INFO, "Received resp to remove brick");
if (rsp.op_ret && strcmp (rsp.op_errstr, ""))
snprintf (msg, sizeof (msg), "%s", rsp.op_errstr);
else
- snprintf (msg, sizeof (msg), "Remove Brick %s",
+ snprintf (msg, sizeof (msg), "Remove Brick %s %s", cmd_str,
(rsp.op_ret) ? "unsuccessful": "successful");
#if (HAVE_LIB_XML)
@@ -1595,6 +1633,9 @@ out:
free (rsp.dict.dict_val);
if (rsp.op_errstr)
free (rsp.op_errstr);
+ if (dict)
+ dict_unref(dict);
+
return ret;
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
index 8fdedbd32a4..aa57341ffd7 100644
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
@@ -1250,14 +1250,7 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr)
case GF_OP_CMD_PAUSE:
case GF_OP_CMD_ABORT:
- {
- if (!volinfo->decommission_in_progress) {
- errstr = gf_strdup("remove-brick is not in progress");
- gf_log ("glusterd", GF_LOG_ERROR, "%s", errstr);
- goto out;
- }
break;
- }
case GF_OP_CMD_COMMIT:
if (volinfo->decommission_in_progress) {
@@ -1523,13 +1516,29 @@ glusterd_op_remove_brick (dict_t *dict, char **op_errstr)
}
/* Fall back to the old volume file */
- list_for_each_entry_safe (brickinfo, tmp, &volinfo->bricks, brick_list) {
+ list_for_each_entry_safe (brickinfo, tmp, &volinfo->bricks,
+ brick_list) {
if (!brickinfo->decommissioned)
continue;
brickinfo->decommissioned = 0;
}
+ ret = glusterd_create_volfiles_and_notify_services (volinfo);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_WARNING,
+ "failed to create volfiles");
+ goto out;
+ }
+
+ ret = glusterd_store_volinfo (volinfo,
+ GLUSTERD_VOLINFO_VER_AC_INCREMENT);
+ if (ret) {
+ gf_log (THIS->name, GF_LOG_WARNING,
+ "failed to store volinfo");
+ goto out;
+ }
+
ret = 0;
- break;
+ goto out;
}
case GF_OP_CMD_START: