summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/bugs/glusterd/bug-1260185-donot-allow-detach-commit-unnecessarily.t41
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-brick-ops.c30
2 files changed, 62 insertions, 9 deletions
diff --git a/tests/bugs/glusterd/bug-1260185-donot-allow-detach-commit-unnecessarily.t b/tests/bugs/glusterd/bug-1260185-donot-allow-detach-commit-unnecessarily.t
new file mode 100644
index 00000000000..220216ec509
--- /dev/null
+++ b/tests/bugs/glusterd/bug-1260185-donot-allow-detach-commit-unnecessarily.t
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+## Test case for BZ: 1260185
+## Do not allow detach-tier commit without "force" option or without
+## user have not started "detach-tier start" operation
+
+. $(dirname $0)/../../include.rc
+. $(dirname $0)/../../volume.rc
+. $(dirname $0)/../../cluster.rc
+
+cleanup;
+
+## Start glusterd
+TEST glusterd;
+TEST pidof glusterd;
+
+## Lets create and start the volume
+TEST $CLI volume create $V0 $H0:$B0/${V0}{1..2}
+TEST $CLI volume start $V0
+
+## Perform attach-tier operation on volume $V0
+TEST $CLI volume attach-tier $V0 $H0:$B0/${V0}{3..4}
+
+## detach-tier commit operation without force option on volume $V0
+## should not succeed
+TEST ! $CLI volume detach-tier $V0 commit
+
+## detach-tier commit operation with force option on volume $V0
+## should succeed
+TEST $CLI volume detach-tier $V0 commit force
+
+## Again performing attach-tier operation on volume $V0
+TEST $CLI volume attach-tier $V0 $H0:$B0/${V0}{5..6}
+
+## Do detach-tier start on volume $V0
+TEST $CLI volume detach-tier $V0 start
+
+## Now detach-tier commit on volume $V0 should succeed.
+TEST $CLI volume detach-tier $V0 commit
+
+cleanup;
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
index 9e6c73d88a1..73c40bd082c 100644
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
@@ -1692,16 +1692,28 @@ glusterd_remove_brick_validate_bricks (gf1_op_commands cmd, int32_t brick_count,
goto out;
}
/* Do not allow commit if the bricks are not decommissioned
- * if its a remove brick commit
+ * if its a remove brick commit or detach-tier commit
*/
- if (cmd == GF_OP_CMD_COMMIT && !brickinfo->decommissioned) {
- snprintf (msg, sizeof (msg), "Brick %s "
- "is not decommissioned. "
- "Use start or force option",
- brick);
- *errstr = gf_strdup (msg);
- ret = -1;
- goto out;
+ if (!brickinfo->decommissioned) {
+ if (cmd == GF_OP_CMD_COMMIT) {
+ snprintf (msg, sizeof (msg), "Brick %s "
+ "is not decommissioned. "
+ "Use start or force option", brick);
+ *errstr = gf_strdup (msg);
+ ret = -1;
+ goto out;
+ }
+
+ if (cmd == GF_OP_CMD_DETACH_COMMIT) {
+ snprintf (msg, sizeof (msg), "Brick's in Hot "
+ "tier is not decommissioned yet. Use "
+ "gluster volume detach-tier <VOLNAME>"
+ " <start | commit | [force]>"
+ " command instead");
+ *errstr = gf_strdup (msg);
+ ret = -1;
+ goto out;
+ }
}
if (glusterd_is_local_brick (THIS, volinfo, brickinfo))