summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtests/bugs/bug-1089668.t25
-rwxr-xr-xtests/bugs/bug-973073.t2
-rw-r--r--tests/dht.rc13
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rebalance.c20
4 files changed, 59 insertions, 1 deletions
diff --git a/tests/bugs/bug-1089668.t b/tests/bugs/bug-1089668.t
new file mode 100755
index 00000000000..e5e0805c06e
--- /dev/null
+++ b/tests/bugs/bug-1089668.t
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+. $(dirname $0)/../include.rc
+. $(dirname $0)/../volume.rc
+. $(dirname $0)/../dht.rc
+
+#This script checks command "gluster volume rebalance <volname> status will not
+#show any output when user have done only remove-brick start and command
+#'gluster volume remove-brick <volname> <brick_name> status' will not show
+#any output when user have triggered only rebalance start.
+
+TEST glusterd
+TEST pidof glusterd
+TEST $CLI volume create $V0 $H0:$B0/${V0}{1,2}
+TEST $CLI volume start $V0
+
+TEST $CLI volume rebalance $V0 start
+TEST ! $CLI volume remove-brick $V0 $H0:$B0/${V0}1 status
+
+TEST $CLI volume rebalance $V0 stop
+
+TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}1 start
+TEST ! $CLI volume rebalance $V0 status
+
+cleanup
diff --git a/tests/bugs/bug-973073.t b/tests/bugs/bug-973073.t
index 83e2839c67d..619f1733114 100755
--- a/tests/bugs/bug-973073.t
+++ b/tests/bugs/bug-973073.t
@@ -34,7 +34,7 @@ TEST glusterfs -s $H0 --volfile-id $V0 $M0;
TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}2 start
## remove-brick status == rebalance_status
-EXPECT_WITHIN 30 "0" rebalance_completed
+EXPECT_WITHIN 30 "0" remove_brick_completed
TEST $CLI volume remove-brick $V0 $H0:$B0/${V0}2 stop
diff --git a/tests/dht.rc b/tests/dht.rc
index 54425c9dc69..a11bbfd8a97 100644
--- a/tests/dht.rc
+++ b/tests/dht.rc
@@ -78,3 +78,16 @@ function rebalance_completed()
echo $val
return $val
}
+
+function remove_brick_completed()
+{
+ val=1
+ test=`gluster volume remove-brick $V0 $H0:$B0/${V0}2 status |grep localhost|grep -v "in progress" 2>&1`
+ if [ $? -eq 0 ]
+ then
+ val=0
+ fi
+
+ echo $val
+ return $val
+}
diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
index bdedf4c0446..4186946c183 100644
--- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c
+++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c
@@ -512,6 +512,7 @@ int
glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr)
{
char *volname = NULL;
+ char *cmd_str = NULL;
int ret = 0;
int32_t cmd = 0;
char msg[2048] = {0};
@@ -582,6 +583,25 @@ glusterd_op_stage_rebalance (dict_t *dict, char **op_errstr)
break;
case GF_DEFRAG_CMD_STATUS:
case GF_DEFRAG_CMD_STOP:
+ ret = dict_get_str (dict, "cmd-str", &cmd_str);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Failed to get "
+ "command string");
+ ret = -1;
+ goto out;
+ }
+ if ((strstr(cmd_str,"rebalance") != NULL) &&
+ (volinfo->rebal.op != GD_OP_REBALANCE)){
+ snprintf (msg,sizeof(msg),"Rebalance not started.");
+ ret = -1;
+ goto out;
+ }
+ if ((strstr(cmd_str,"remove-brick")!= NULL) &&
+ (volinfo->rebal.op != GD_OP_REMOVE_BRICK)){
+ snprintf (msg,sizeof(msg),"remove-brick not started.");
+ ret = -1;
+ goto out;
+ }
break;
default:
break;