summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kparthas@redhat.com>2012-08-17 12:23:39 +0530
committerVijay Bellur <vbellur@redhat.com>2012-12-12 00:12:26 -0500
commita383a1e8e6099f1ad5545b1298a750a66c5ae42f (patch)
tree94ac8801b825d9a554a8c8d12beda8541b89f580 /xlators
parentf62a8026be3875afd38fb1899e1fa235c8f1a6fb (diff)
glusterd-hooks: added support for separate namespace for 'volume set' keys
[cherry-picked Amar's patch from master] The keys in the above mentioned namespace could be used by hook scripts to peform tasks on 'special' keys as defined by the storage admin. The choice of the key and its semantics of it are outside the scope of glusterd. It is the responsibility of the storage admin to keep the meaning of the key(s) consistent. If a user gives a command like 'gluster volume set <VOLNAME> user.for-this-key do-this" scripts would get 'user.for-this-key=do-this' as argument. Change-Id: I5509e17d99e4ddd8bf5df968dcd51ff9a80dc3ab Signed-off-by: Amar Tumballi <amarts@redhat.com> BUG: 825902 Reviewed-on: http://review.gluster.com/3443 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Krishnan Parthasarathi <kp@gluster.com> Reviewed-by: Anand Avati <avati@redhat.com> Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com> Reviewed-on: https://code.engineering.redhat.com/gerrit/1854 Reviewed-by: Vijay Bellur <vbellur@redhat.com> Tested-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-hooks.h20
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c12
2 files changed, 32 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-hooks.h b/xlators/mgmt/glusterd/src/glusterd-hooks.h
index 120fd5a4781..e717395be40 100644
--- a/xlators/mgmt/glusterd/src/glusterd-hooks.h
+++ b/xlators/mgmt/glusterd/src/glusterd-hooks.h
@@ -25,12 +25,16 @@
#include "config.h"
#endif
+#include <fnmatch.h>
+
#define GLUSTERD_GET_HOOKS_DIR(path, version, priv) \
snprintf (path, PATH_MAX, "%s/hooks/%d", priv->workdir,\
version);
#define GLUSTERD_HOOK_VER 1
+#define GD_HOOKS_SPECIFIC_KEY "user.*"
+
typedef enum glusterd_commit_hook_type {
GD_COMMIT_HOOK_NONE = 0,
GD_COMMIT_HOOK_PRE,
@@ -55,6 +59,22 @@ typedef struct hooks_stub {
} glusterd_hooks_stub_t;
+static inline gf_boolean_t
+is_key_glusterd_hooks_friendly (xlator_t *this, char *volname, char *key)
+{
+ gf_boolean_t is_friendly = _gf_false;
+
+ /* This is very specific to hooks friendly behavior */
+ if (fnmatch (GD_HOOKS_SPECIFIC_KEY, key, FNM_NOESCAPE) == 0) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "user configured key (%s) sent on volume %s",
+ key, volname);
+ is_friendly = _gf_true;
+ }
+
+ return is_friendly;
+}
+
int
glusterd_hooks_create_hooks_directory (char *basedir);
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index b21ecf72fde..fedb9458882 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -456,6 +456,12 @@ glusterd_op_stage_set_volume (dict_t *dict, char **op_errstr)
ret = 0;
goto out;
}
+
+ if (is_key_glusterd_hooks_friendly (this, volname, key)) {
+ ret = 0;
+ goto out;
+ }
+
exists = glusterd_check_option_exists (key, &key_fixed);
if (exists == -1) {
ret = -1;
@@ -1377,6 +1383,12 @@ glusterd_op_set_volume (dict_t *dict)
&volinfo->memory_accounting);
goto out;
}
+
+ if (is_key_glusterd_hooks_friendly (this, volname, key)) {
+ ret = 0;
+ goto out;
+ }
+
ret = glusterd_check_option_exists (key, &key_fixed);
GF_ASSERT (ret);
if (ret == -1) {