summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-hooks.c
diff options
context:
space:
mode:
authorNandaja Varma <nandaja.varma@gmail.com>2015-06-25 00:57:00 +0530
committerKaushal M <kaushal@redhat.com>2015-06-26 23:56:09 -0700
commit8708953fa3d9187997dc6d484dae663b4469c7ca (patch)
tree38e9ef4db291ee0c1c50805bc08aee6fa3c7780f /xlators/mgmt/glusterd/src/glusterd-hooks.c
parent08586ee518de438fe2bbbaa74ae4c9a02a5d88cf (diff)
glusterd: Porting left out log messages to new framework
This is a backport of http://review.gluster.org/11388 cherry-picked from commit 23c1e6dc0fa86c014e1a8b6aa5729675f6d69017 >Change-Id: I70d40ae3b5f49a21e1b93f82885cd58fa2723647 >BUG: 1235538 >Signed-off-by: Nandaja Varma <nandaja.varma@gmail.com> Change-Id: I70d40ae3b5f49a21e1b93f82885cd58fa2723647 BUG: 1217722 Signed-off-by: Nandaja Varma <nandaja.varma@gmail.com> Reviewed-on: http://review.gluster.org/11422 Tested-by: Gluster Build System <jenkins@build.gluster.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Anand Nekkunti <anekkunt@redhat.com> Reviewed-by: Kaushal M <kaushal@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-hooks.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-hooks.c50
1 files changed, 31 insertions, 19 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-hooks.c b/xlators/mgmt/glusterd/src/glusterd-hooks.c
index 3e3f18959b0..220c6b022f5 100644
--- a/xlators/mgmt/glusterd/src/glusterd-hooks.c
+++ b/xlators/mgmt/glusterd/src/glusterd-hooks.c
@@ -28,6 +28,7 @@
#include "glusterd-utils.h"
#include "glusterd-store.h"
#include "glusterd-hooks.h"
+#include "glusterd-messages.h"
#include <fnmatch.h>
@@ -89,16 +90,18 @@ glusterd_hooks_create_hooks_directory (char *basedir)
snprintf (path, sizeof (path), "%s/hooks", basedir);
ret = mkdir_p (path, 0777, _gf_true);
if (ret) {
- gf_log (THIS->name, GF_LOG_CRITICAL, "Unable to create %s due"
- "to %s", path, strerror (errno));
+ gf_msg (THIS->name, GF_LOG_CRITICAL, errno,
+ GD_MSG_CREATE_DIR_FAILED, "Unable to create %s",
+ path);
goto out;
}
GLUSTERD_GET_HOOKS_DIR (version_dir, GLUSTERD_HOOK_VER, priv);
ret = mkdir_p (version_dir, 0777, _gf_true);
if (ret) {
- gf_log (THIS->name, GF_LOG_CRITICAL, "Unable to create %s due "
- "to %s", version_dir, strerror (errno));
+ gf_msg (THIS->name, GF_LOG_CRITICAL, errno,
+ GD_MSG_CREATE_DIR_FAILED, "Unable to create %s",
+ version_dir);
goto out;
}
@@ -111,9 +114,10 @@ glusterd_hooks_create_hooks_directory (char *basedir)
cmd_subdir);
ret = mkdir_p (path, 0777, _gf_true);
if (ret) {
- gf_log (THIS->name, GF_LOG_CRITICAL,
- "Unable to create %s due to %s",
- path, strerror (errno));
+ gf_msg (THIS->name, GF_LOG_CRITICAL, errno,
+ GD_MSG_CREATE_DIR_FAILED,
+ "Unable to create %s",
+ path);
goto out;
}
@@ -123,9 +127,10 @@ glusterd_hooks_create_hooks_directory (char *basedir)
version_dir, cmd_subdir, type_subdir[type]);
ret = mkdir_p (path, 0777, _gf_true);
if (ret) {
- gf_log (THIS->name, GF_LOG_CRITICAL,
- "Unable to create %s due to %s",
- path, strerror (errno));
+ gf_msg (THIS->name, GF_LOG_CRITICAL, errno,
+ GD_MSG_CREATE_DIR_FAILED,
+ "Unable to create %s",
+ path);
goto out;
}
}
@@ -176,10 +181,10 @@ glusterd_hooks_add_custom_args (dict_t *dict, runner_t *runner)
ret = dict_get_str (dict, "hooks_args", &hooks_args);
if (ret)
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"No Hooks Arguments.");
else
- gf_log (this->name, GF_LOG_DEBUG,
+ gf_msg_debug (this->name, 0,
"Hooks Args = %s", hooks_args);
if (hooks_args)
@@ -337,7 +342,8 @@ glusterd_hooks_run_hooks (char *hooks_path, glusterd_op_t op, dict_t *op_ctx,
ret = dict_get_str (op_ctx, "volname", &volname);
if (ret) {
- gf_log (this->name, GF_LOG_CRITICAL, "Failed to get volname "
+ gf_msg (this->name, GF_LOG_CRITICAL, errno,
+ GD_MSG_DICT_GET_FAILED, "Failed to get volname "
"from operation context");
goto out;
}
@@ -345,8 +351,10 @@ glusterd_hooks_run_hooks (char *hooks_path, glusterd_op_t op, dict_t *op_ctx,
hookdir = opendir (hooks_path);
if (!hookdir) {
ret = -1;
- gf_log (this->name, GF_LOG_ERROR, "Failed to open dir %s, due "
- "to %s", hooks_path, strerror (errno));
+ gf_msg (this->name, GF_LOG_ERROR, errno,
+ GD_MSG_DIR_OP_FAILED,
+ "Failed to open dir %s",
+ hooks_path);
goto out;
}
@@ -390,7 +398,8 @@ glusterd_hooks_run_hooks (char *hooks_path, glusterd_op_t op, dict_t *op_ctx,
runner_argprintf (&runner, "--volname=%s", volname);
ret = glusterd_hooks_add_op_args (&runner, op, op_ctx, type);
if (ret) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to add "
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ GD_MSG_ADD_OP_ARGS_FAIL, "Failed to add "
"command specific arguments");
goto out;
}
@@ -480,7 +489,8 @@ glusterd_hooks_stub_init (glusterd_hooks_stub_t **stub, char *scriptdir,
ret = 0;
out:
if (ret) {
- gf_log (THIS->name, GF_LOG_ERROR, "Failed to initialize "
+ gf_msg (THIS->name, GF_LOG_ERROR, 0,
+ GD_MSG_POST_HOOK_STUB_INIT_FAIL, "Failed to initialize "
"post hooks stub");
glusterd_hooks_stub_cleanup (hooks_stub);
}
@@ -492,7 +502,8 @@ void
glusterd_hooks_stub_cleanup (glusterd_hooks_stub_t *stub)
{
if (!stub) {
- gf_log_callingfn (THIS->name, GF_LOG_WARNING,
+ gf_msg_callingfn (THIS->name, GF_LOG_WARNING, 0,
+ GD_MSG_HOOK_STUB_NULL,
"hooks_stub is NULL");
return;
}
@@ -582,7 +593,8 @@ glusterd_hooks_spawn_worker (xlator_t *this)
ret = pthread_create (&hooks_priv->worker, NULL, hooks_worker,
(void *)this);
if (ret)
- gf_log (this->name, GF_LOG_CRITICAL, "Failed to spawn post "
+ gf_msg (this->name, GF_LOG_CRITICAL, errno,
+ GD_MSG_SPAWN_THREADS_FAIL, "Failed to spawn post "
"hooks worker thread");
out:
return ret;