summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvmallika <vmallika@redhat.com>2014-11-14 12:06:39 +0530
committerKrishnan Parthasarathi <kparthas@redhat.com>2014-11-14 03:37:59 -0800
commitc3c28ad86be6feb0b148df4681da432047dc0bc3 (patch)
treea254dbd8ce7ea5755bf035cadf2806785c99fe38
parent3e0a9c04ed86153a2822b92d69b31e20ef5c63f6 (diff)
mgmt/glusterd: Validate the options of uss
Change-Id: Id13dc4cd3f5246446a9dfeabc9caa52f91477524 BUG: 1111554 Signed-off-by: Varun Shastry <vshastry@redhat.com> Signed-off-by: vmallika <vmallika@redhat.com> Reviewed-on: http://review.gluster.org/8133 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com> Tested-by: Krishnan Parthasarathi <kparthas@redhat.com>
-rw-r--r--tests/basic/uss.t8
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c17
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c5
3 files changed, 23 insertions, 7 deletions
diff --git a/tests/basic/uss.t b/tests/basic/uss.t
index f86c19d981e..aabe00cd880 100644
--- a/tests/basic/uss.t
+++ b/tests/basic/uss.t
@@ -13,6 +13,7 @@ function check_readonly()
}
cleanup;
+TESTS_EXPECTED_IN_LOOP=10
TEST init_n_bricks 3;
TEST setup_lvm 3;
@@ -50,6 +51,13 @@ for i in {11..20} ; do echo "foo" > $M0/dir2/foo$i ; done
TEST $CLI snapshot create snap4 $V0;
+## Test that features.uss takes only options enable/disable and throw error for
+## any other argument.
+for i in {1..10}; do
+ RANDOM_STRING=`cat /dev/urandom | tr -dc 'a-zA-Z' | fold -w 8 | head -n 1`
+ TEST_IN_LOOP ! $CLI volume set $V0 features.uss $RANDOM_STRING
+done
+
TEST $CLI volume set $V0 features.uss enable;
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index b5128aa6426..6c83446e9b1 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -13117,14 +13117,12 @@ glusterd_is_snapd_enabled (glusterd_volinfo_t *volinfo)
ret = dict_get_str_boolean (volinfo->dict, "features.uss", -2);
if (ret == -2) {
gf_log (this->name, GF_LOG_DEBUG, "Key features.uss not "
- "present in the volinfo dict");
+ "present in the dict for volume %s", volinfo->volname);
ret = 0;
} else if (ret == -1) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to get "
- "'features.uss' from %s volume dict",
- volinfo->volname);
- ret = 0;
+ gf_log (this->name, GF_LOG_ERROR, "Failed to get 'features.uss'"
+ " from dict for volume %s", volinfo->volname);
}
return ret;
@@ -13462,7 +13460,14 @@ glusterd_handle_snapd_option (glusterd_volinfo_t *volinfo)
if (volinfo->is_snap_volume)
return 0;
- if (glusterd_is_snapd_enabled (volinfo)) {
+ ret = glusterd_is_snapd_enabled (volinfo);
+ if (ret == -1) {
+ gf_log (this->name, GF_LOG_ERROR, "Failed to read volume "
+ "options");
+ goto out;
+ }
+
+ if (ret) {
if (!glusterd_is_volume_started (volinfo)) {
if (glusterd_is_snapd_running (volinfo)) {
ret = glusterd_snapd_stop (volinfo);
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 476e3b0c1d9..22af263547b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -2876,7 +2876,10 @@ client_graph_builder (volgen_graph_t *graph, glusterd_volinfo_t *volinfo,
if (ret)
goto out;
- if (!volinfo->is_snap_volume && glusterd_is_snapd_enabled (volinfo)) {
+ ret = dict_get_str_boolean (set_dict, "features.uss", _gf_false);
+ if (ret == -1)
+ goto out;
+ if (ret && !volinfo->is_snap_volume) {
ret = volgen_graph_build_snapview_client
(graph, volinfo, volname, set_dict);
if (ret == -1)