summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cli/src/cli-rpc-ops.c2
-rw-r--r--rpc/xdr/src/cli1-xdr.x3
-rw-r--r--tests/basic/tier/new-tier-cmds.t65
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rebalance.c45
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c1
5 files changed, 94 insertions, 22 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index d59ff8b..666d44f 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -4539,7 +4539,7 @@ gf_cli_detach_tier (call_frame_t *frame, xlator_t *this,
} else {
/* Need rebalance status to be sent :-) */
if (command == GF_OP_CMD_STATUS)
- cmd |= GF_DEFRAG_CMD_STATUS;
+ cmd |= GF_DEFRAG_CMD_DETACH_STATUS;
else
cmd |= GF_DEFRAG_CMD_STOP_DETACH_TIER;
diff --git a/rpc/xdr/src/cli1-xdr.x b/rpc/xdr/src/cli1-xdr.x
index 231b526..f1d4ea9 100644
--- a/rpc/xdr/src/cli1-xdr.x
+++ b/rpc/xdr/src/cli1-xdr.x
@@ -9,7 +9,8 @@
GF_DEFRAG_CMD_START_DETACH_TIER,
GF_DEFRAG_CMD_STOP_DETACH_TIER,
GF_DEFRAG_CMD_PAUSE_TIER,
- GF_DEFRAG_CMD_RESUME_TIER
+ GF_DEFRAG_CMD_RESUME_TIER,
+ GF_DEFRAG_CMD_DETACH_STATUS
};
enum gf_defrag_status_t {
diff --git a/tests/basic/tier/new-tier-cmds.t b/tests/basic/tier/new-tier-cmds.t
new file mode 100644
index 0000000..c38ecf9
--- /dev/null
+++ b/tests/basic/tier/new-tier-cmds.t
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+. $(dirname $0)/../../include.rc
+. $(dirname $0)/../../volume.rc
+. $(dirname $0)/../../tier.rc
+
+
+# Creates a tiered volume with pure distribute hot and cold tiers
+# Both hot and cold tiers will have an equal number of bricks.
+
+function create_dist_tier_vol () {
+ mkdir $B0/cold
+ mkdir $B0/hot
+ TEST $CLI volume create $V0 disperse 6 disperse-data 4 $H0:$B0/cold/${V0}{1..12}
+ TEST $CLI volume set $V0 performance.quick-read off
+ TEST $CLI volume set $V0 performance.io-cache off
+ TEST $CLI volume start $V0
+ TEST $CLI volume attach-tier $V0 replica 2 $H0:$B0/hot/${V0}{0..5}
+ TEST $CLI volume set $V0 cluster.tier-mode test
+}
+
+function tier_detach_commit () {
+ $CLI volume tier $V0 detach commit | grep "success" | wc -l
+}
+
+cleanup;
+
+#Basic checks
+TEST glusterd
+TEST pidof glusterd
+TEST $CLI volume status
+
+
+#Create and start a tiered volume
+create_dist_tier_vol
+
+#Issue detach tier on the tiered volume
+#Will throw error saying detach tier not started
+
+EXPECT "Tier command failed" $CLI volume tier $V0 detach status
+
+#after starting detach tier the detach tier status should display the status
+
+TEST $CLI volume tier $V0 detach start
+
+TEST $CLI volume tier $V0 detach status
+
+TEST $CLI volume tier $V0 detach stop
+
+#If detach tier is stopped the detach tier command will fail
+
+EXPECT "Tier command failed" $CLI volume tier $V0 detach status
+
+TEST $CLI volume tier $V0 detach start
+
+#wait for the detach to complete
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" tier_detach_commit
+
+#If detach tier is committed then the detach status should fail throwing an error
+#saying its not a tiered volume
+
+EXPECT "Tier command failed" $CLI volume tier $V0 detach status
+
+cleanup;
+
diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
index 5c5568a..6acfc18 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
@@ -523,7 +523,8 @@ __glusterd_handle_defrag_volume (rpcsvc_request_t *req)
if ((cmd == GF_DEFRAG_CMD_STATUS) ||
(cmd == GF_DEFRAG_CMD_STATUS_TIER) ||
(cmd == GF_DEFRAG_CMD_STOP_DETACH_TIER) ||
- (cmd == GF_DEFRAG_CMD_STOP)) {
+ (cmd == GF_DEFRAG_CMD_STOP) ||
+ (cmd == GF_DEFRAG_CMD_DETACH_STATUS)) {
ret = glusterd_op_begin (req, GD_OP_DEFRAG_BRICK_VOLUME,
dict, msg, sizeof (msg));
} else
@@ -700,7 +701,7 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr)
case GF_DEFRAG_CMD_STATUS_TIER:
case GF_DEFRAG_CMD_STATUS:
case GF_DEFRAG_CMD_STOP:
- case GF_DEFRAG_CMD_STOP_DETACH_TIER:
+
ret = dict_get_str (dict, "cmd-str", &cmd_str);
if (ret) {
gf_msg (this->name, GF_LOG_ERROR, 0,
@@ -715,6 +716,7 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr)
ret = -1;
goto out;
}
+
if (strstr(cmd_str, "remove-brick") != NULL) {
if (volinfo->rebal.op != GD_OP_REMOVE_BRICK) {
snprintf (msg, sizeof(msg), "remove-brick not "
@@ -735,7 +737,7 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr)
goto out;
}
}
- if (strstr(cmd_str, "tier") != NULL) {
+ if (cmd == GF_DEFRAG_CMD_STATUS_TIER) {
if (volinfo->type != GF_CLUSTER_TYPE_TIER) {
snprintf (msg, sizeof(msg), "volume %s is not "
"a tier volume.", volinfo->volname);
@@ -743,21 +745,24 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr)
goto out;
}
}
- if (strstr(cmd_str, "detach-tier") != NULL) {
- if (volinfo->type != GF_CLUSTER_TYPE_TIER) {
- snprintf (msg, sizeof(msg), "volume %s is not "
- "a tier volume.", volinfo->volname);
- ret = -1;
- goto out;
- }
- if (volinfo->rebal.op != GD_OP_REMOVE_BRICK) {
- snprintf (msg, sizeof(msg), "Detach-tier "
- "not started");
- ret = -1;
- goto out;
- }
+
+ break;
+
+ case GF_DEFRAG_CMD_STOP_DETACH_TIER:
+ case GF_DEFRAG_CMD_DETACH_STATUS:
+ if (volinfo->type != GF_CLUSTER_TYPE_TIER) {
+ snprintf (msg, sizeof(msg), "volume %s is not "
+ "a tier volume.", volinfo->volname);
+ ret = -1;
+ goto out;
}
+ if (volinfo->rebal.op != GD_OP_REMOVE_BRICK) {
+ snprintf (msg, sizeof(msg), "Detach-tier "
+ "not started");
+ ret = -1;
+ goto out;
+ }
break;
default:
break;
@@ -924,11 +929,11 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
}
if (volinfo->type == GF_CLUSTER_TYPE_TIER &&
- cmd == GF_OP_CMD_STOP_DETACH_TIER) {
+ cmd == GF_OP_CMD_STOP_DETACH_TIER) {
glusterd_defrag_info_set (volinfo, dict,
- GF_DEFRAG_CMD_START_TIER,
- GF_DEFRAG_CMD_START,
- GD_OP_REBALANCE);
+ GF_DEFRAG_CMD_START_TIER,
+ GF_DEFRAG_CMD_START,
+ GD_OP_REBALANCE);
glusterd_restart_rebalance_for_volume (volinfo);
}
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index a388ac1..c25d301 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -10842,6 +10842,7 @@ glusterd_disallow_op_for_tier (glusterd_volinfo_t *volinfo, glusterd_op_t op,
case GF_DEFRAG_CMD_START_DETACH_TIER:
case GF_DEFRAG_CMD_STOP_DETACH_TIER:
case GF_DEFRAG_CMD_STATUS:
+ case GF_DEFRAG_CMD_DETACH_STATUS:
ret = 0;
break;
default: