summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAvra Sengupta <asengupt@redhat.com>2016-10-25 12:44:29 +0530
committerAtin Mukherjee <amukherj@redhat.com>2016-11-06 21:18:28 -0800
commit42e334eef6f64663bababe30bb6faf8bd00e6bc9 (patch)
tree73b4dc47a8cb78855a50d32ccbea98680c26402c
parenta125687227662a37ba7d0098bf086fc10ce6ad6f (diff)
glusterd/shared storage: Check for hook-script at staging
Check if S32gluster_enable_shared_storage.sh is present at /var/lib/glusterd/hooks/1/set/post/ at staging before proceeding with the command. Fail the command with the appropriate error message in case it is not present. > Reviewed-on: http://review.gluster.org/15718 > NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> > Smoke: Gluster Build System <jenkins@build.gluster.org> > CentOS-regression: Gluster Build System <jenkins@build.gluster.org> > Reviewed-by: Atin Mukherjee <amukherj@redhat.com> (cherry picked from commit 29587a91716e1e55bd172d63340c40249fb343c9) Change-Id: I84e3912f1cdffb927f8a40d74d52be43ee69388b BUG: 1377448 Signed-off-by: Avra Sengupta <asengupt@redhat.com> Reviewed-on: http://review.gluster.org/15741 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c29
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h2
2 files changed, 25 insertions, 6 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 5fc47673867..0ff8ebcbe7b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -772,12 +772,14 @@ 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;
- char *op = NULL;
- xlator_t *this = NULL;
- glusterd_conf_t *conf = NULL;
+ int32_t ret = -1;
+ int32_t exists = -1;
+ int32_t count = -1;
+ char *op = NULL;
+ char hook_script[PATH_MAX] = "";
+ xlator_t *this = NULL;
+ glusterd_conf_t *conf = NULL;
+ struct stat stbuf = {0,};
this = THIS;
GF_VALIDATE_OR_GOTO ("glusterd", this, out);
@@ -806,6 +808,21 @@ glusterd_validate_shared_storage (char *key, char *value, char *errstr)
goto out;
}
+ snprintf (hook_script, sizeof(hook_script),
+ "%s"GLUSTERD_SHRD_STRG_HOOK_SCRIPT, conf->workdir);
+
+ ret = sys_lstat (hook_script, &stbuf);
+ if (ret) {
+ snprintf (errstr, PATH_MAX,
+ "The hook-script (%s) required "
+ "for this operation is not present. "
+ "Please install the hook-script "
+ "and retry", hook_script);
+ gf_msg (this->name, GF_LOG_ERROR, ENOENT,
+ GD_MSG_FILE_OP_FAILED, "%s", errstr);
+ goto out;
+ }
+
if (!strncmp (value, "disable", strlen ("disable"))) {
ret = dict_get_str (conf->opts, GLUSTERD_SHARED_STORAGE_KEY,
&op);
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index 9889565e2b7..bb6af7f378f 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -47,6 +47,8 @@
#define GEO_CONF_MAX_OPT_VALS 6
#define GLUSTERD_CREATE_HOOK_SCRIPT "/hooks/1/gsync-create/post/" \
"S56glusterd-geo-rep-create-post.sh"
+#define GLUSTERD_SHRD_STRG_HOOK_SCRIPT "/hooks/1/set/post/" \
+ "S32gluster_enable_shared_storage.sh"
#define GLUSTER_SHARED_STORAGE "gluster_shared_storage"
#define GLUSTERD_SHARED_STORAGE_KEY "cluster.enable-shared-storage"