diff options
-rw-r--r-- | cli/src/cli-rpc-ops.c | 2 | ||||
-rw-r--r-- | tests/bugs/bug-961669.t | 43 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 15 |
3 files changed, 58 insertions, 2 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 08f3bcae5..8f69fa0ef 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -2007,6 +2007,8 @@ gf_cli_remove_brick_cbk (struct rpc_req *req, struct iovec *iov, if (ret) { gf_log ("cli", GF_LOG_ERROR, "remove-brick-id is not present in dict"); + cli_err ("volume remove-brick %s: failed: %s", cmd_str, + rsp.op_errstr); goto out; } break; diff --git a/tests/bugs/bug-961669.t b/tests/bugs/bug-961669.t new file mode 100644 index 000000000..1b8326225 --- /dev/null +++ b/tests/bugs/bug-961669.t @@ -0,0 +1,43 @@ +#!/bin/bash + +#Test case: Create a replicate volume; mount and write to it; kill one brick; try to remove the other. + +. $(dirname $0)/../include.rc +. $(dirname $0)/../volume.rc + +cleanup; + +#Basic checks +TEST glusterd +TEST pidof glusterd +TEST $CLI volume info + +#Create a 1x2 replicate volume +TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1}; +TEST $CLI volume start $V0 + +# Mount FUSE and create file/directory +TEST glusterfs -s $H0 --volfile-id $V0 $M0 +TEST touch $M0/zerobytefile.txt +TEST mkdir $M0/test_dir +TEST dd if=/dev/zero of=$M0/file bs=1024 count=1024 + +#Kill one of the bricks. This step can be skipped without affecting the outcome of the test. +kill -9 `cat /var/lib/glusterd/vols/$V0/run/$H0-d-backends-${V0}1.pid`; + +function remove_brick_status { + $CLI volume remove-brick $V0 replica 1 $H0:$B0/${V0}1 start 2>&1 +} + +#Remove brick +EXPECT "volume remove-brick start: failed: Removing brick from a replicate volume is not allowed" remove_brick_status; + +#Check the volume type +EXPECT "Replicate" echo `$CLI volume info |grep Type |awk '{print $2}'` + +TEST umount $M0 +TEST $CLI volume stop $V0 +TEST $CLI volume delete $V0; +TEST ! $CLI volume info $V0; + +cleanup; diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c index 92e1b2622..912a6a798 100644 --- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c @@ -671,16 +671,27 @@ __glusterd_handle_remove_brick (rpcsvc_request_t *req) strcpy (vol_type, "distribute"); } - /* Do not allow remove-brick if the volume is plain stripe */ + /* Do not allow remove-brick if the volume is a stripe volume*/ if ((volinfo->type == GF_CLUSTER_TYPE_STRIPE) && (volinfo->brick_count == volinfo->stripe_count)) { snprintf (err_str, sizeof (err_str), - "Removing brick from a plain stripe is not allowed"); + "Removing brick from a stripe volume is not allowed"); gf_log (this->name, GF_LOG_ERROR, "%s", err_str); ret = -1; goto out; } + /*Do not allow remove-brick if the volume is a replicate volume*/ + if ((volinfo->type == GF_CLUSTER_TYPE_REPLICATE) && + (volinfo->brick_count == volinfo->replica_count)) { + snprintf (err_str, sizeof(err_str), + "Removing brick from a replicate volume " + "is not allowed"); + gf_log (this->name, GF_LOG_ERROR, "%s", err_str); + ret = -1; + goto out; + } + if (!replica_count && (volinfo->type == GF_CLUSTER_TYPE_STRIPE_REPLICATE) && (volinfo->brick_count == volinfo->dist_leaf_count)) { |