summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGaurav Kumar Garg <garg.gaurav52@gmail.com>2015-09-24 18:04:23 +0530
committerAtin Mukherjee <amukherj@redhat.com>2015-10-13 20:45:17 -0700
commitf88d0ade1c09aa1a3cee3713dc851da9552d7ff5 (patch)
treee2fe3dec1b22687484f79a453b9bff6cd7bd6dd3
parentfc8df80f157c148cf60500be14c1f6a9aeed8d7b (diff)
glusterd: disabling enable-shared-storage option should not delete volume
Previously when you create volume with "glusterd_shared_storage" name and if user disable enable-shared-storage option then gluster will delete the "glusterd_shared_storage" volume. With this fix gluster will do appropriate validation of enable-shared-storage option and it will not delete volume with "glusterd_shared_storage" name if it is a user created volume. Change-Id: I2bd92f938fb3de6ef496a934933bdcea9f251491 BUG: 1266818 Signed-off-by: Gaurav Kumar Garg <ggarg@redhat.com> Reviewed-on: http://review.gluster.org/12232 Reviewed-by: Atin Mukherjee <amukherj@redhat.com> Reviewed-by: Anand Nekkunti <anekkunt@redhat.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com>
-rw-r--r--tests/bugs/glusterd/bug-1266818-shared-storage-disable.t36
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-messages.h10
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c28
3 files changed, 68 insertions, 6 deletions
diff --git a/tests/bugs/glusterd/bug-1266818-shared-storage-disable.t b/tests/bugs/glusterd/bug-1266818-shared-storage-disable.t
new file mode 100644
index 00000000000..a9ccf1b8954
--- /dev/null
+++ b/tests/bugs/glusterd/bug-1266818-shared-storage-disable.t
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+## Test case for BZ 1266818;
+## Disabling enable-shared-storage option should not delete user created
+## volume with name glusterd_shared_storage
+
+. $(dirname $0)/../../include.rc
+. $(dirname $0)/../../volume.rc
+. $(dirname $0)/../../cluster.rc
+
+cleanup;
+
+## Start a 2 node virtual cluster
+TEST launch_cluster 2;
+
+## Peer probe server 2 from server 1 cli
+TEST $CLI_1 peer probe $H2;
+
+EXPECT_WITHIN $PROBE_TIMEOUT 1 peer_count
+
+## Creating a volume with name glusterd_shared_storage
+TEST $CLI_1 volume create glusterd_shared_storage $H1:$B1/${V0}0 $H2:$B1/${V0}1
+
+## Disabling enable-shared-storage should not succeed and should not delete the
+## user created volume with name "glusterd_shared_storage"
+TEST ! $CLI_1 volume all enable-shared-storage disable
+
+## Volume with name should exist
+TEST $CLI_1 volume info glusterd_shared_storage
+
+cleanup;
+
+
+
+
+
diff --git a/xlators/mgmt/glusterd/src/glusterd-messages.h b/xlators/mgmt/glusterd/src/glusterd-messages.h
index c5603254aa9..03826b7d748 100644
--- a/xlators/mgmt/glusterd/src/glusterd-messages.h
+++ b/xlators/mgmt/glusterd/src/glusterd-messages.h
@@ -40,7 +40,7 @@
*/
#define GLUSTERD_COMP_BASE GLFS_MSGID_GLUSTERD
-#define GLFS_NUM_MESSAGES 568
+#define GLFS_NUM_MESSAGES 571
#define GLFS_MSGID_END (GLUSTERD_COMP_BASE + GLFS_NUM_MESSAGES + 1)
/* Messaged with message IDs */
#define glfs_msg_start_x GLFS_COMP_BASE, "Invalid: Start of messages"
@@ -4605,6 +4605,14 @@
*/
#define GD_MSG_SVC_STOP_FAIL (GLUSTERD_COMP_BASE + 570)
+/*!
+ * @messageid
+ * @diagnosis
+ * @recommendedaction
+ *
+ */
+#define GD_MSG_SHARED_STORAGE_DOES_NOT_EXIST (GLUSTERD_COMP_BASE + 571)
+
/*------------*/
#define glfs_msg_end_x GLFS_MSGID_END, "Invalid: End of messages"
#endif /* !_GLUSTERD_MESSAGES_H_ */
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 0ff2d478ef1..3dfc50f8126 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -758,13 +758,19 @@ out:
static int
glusterd_validate_shared_storage (char *key, char *value, char *errstr)
{
- int32_t ret = -1;
- int32_t exists = -1;
- int32_t count = -1;
- xlator_t *this = NULL;
+ int32_t ret = -1;
+ int32_t exists = -1;
+ int32_t count = -1;
+ char *op = NULL;
+ xlator_t *this = NULL;
+ glusterd_conf_t *conf = NULL;
this = THIS;
GF_VALIDATE_OR_GOTO ("glusterd", this, out);
+
+ conf = this->private;
+ GF_VALIDATE_OR_GOTO (this->name, conf, out);
+
GF_VALIDATE_OR_GOTO (this->name, key, out);
GF_VALIDATE_OR_GOTO (this->name, value, out);
GF_VALIDATE_OR_GOTO (this->name, errstr, out);
@@ -786,7 +792,19 @@ glusterd_validate_shared_storage (char *key, char *value, char *errstr)
goto out;
}
- if (strcmp (value, "enable")) {
+ if (!strncmp (value, "disable", strlen ("disable"))) {
+ ret = dict_get_str (conf->opts, GLUSTERD_SHARED_STORAGE_KEY,
+ &op);
+ if (ret || !strncmp (op, "disable", strlen ("disable"))) {
+ snprintf (errstr, PATH_MAX, "Shared storage volume "
+ "does not exist. Please enable shared storage"
+ " for creating shared storage volume.");
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_SHARED_STORAGE_DOES_NOT_EXIST, "%s",
+ errstr);
+ ret = -1;
+ goto out;
+ }
goto out;
}