diff options
author | Krutika Dhananjay <kdhananj@redhat.com> | 2012-09-12 17:16:22 +0530 |
---|---|---|
committer | Anand Avati <avati@redhat.com> | 2012-09-20 08:26:22 -0700 |
commit | e09245b8d152fdae8152f8e29d2be1827e6090e1 (patch) | |
tree | c930304e13da4d4f56b60ef692653d445ba10f30 /xlators/mgmt/glusterd/src/glusterd-brick-ops.c | |
parent | f9652adfd1315c0a817917eb35f61f43f58e673b (diff) |
glusterd: Fix to log command status at the appropriate time
PROBLEM:
In the existing implementation, the success/failure of
execution of a command is decided (and logged) in glusterd
handler functions. Strictly speaking, the logging mechanism
must take into account what course the command takes within
the state machine before concluding whether it succeeded or
failed.
FIX:
This patch attempts to fix the above issue for vol commands.
The format of the log message is as follows:
for failure:
<command string> : FAILED : <cause of failure>
for success:
<command string> : SUCCESS
APPROACH (in a nutshell):
* The command string is packed into dict at cli and sent to
glusterd.
* glusterd logs the command status just before doing a
"submit_reply", which is called (either directly or
indirectly via a call to glusterd_op_cli_send_response)
at 2 places for every vol command:
i. in handler functions, and
ii. in glusterd_op_txn_complete
In short, the failure of a command in the handler implies the
command has indeed failed. However, its success in the handler
does NOT necessarily mean the command succeeded/will succeed.
Change-Id: I5a8a2ddc318ef2dc2a9699f704a6bcd2f0ab0277
BUG: 823081
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Reviewed-on: http://review.gluster.org/3948
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-brick-ops.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c index 9efccd9a49a..b32c9872ac3 100644 --- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c @@ -343,7 +343,6 @@ glusterd_handle_add_brick (rpcsvc_request_t *req) char *bricks = NULL; char *volname = NULL; int brick_count = 0; - char *brick_list = NULL; void *cli_rsp = NULL; char err_str[2048] = {0,}; gf_cli_rsp rsp = {0,}; @@ -388,8 +387,6 @@ glusterd_handle_add_brick (rpcsvc_request_t *req) ret = dict_get_str (dict, "volname", &volname); - gf_cmd_log ("Volume add-brick", "on volname: %s attempted", - volname); if (ret) { gf_log ("", GF_LOG_ERROR, "Unable to get volume name"); snprintf (err_str, sizeof (err_str), "Unable to get volume " @@ -510,9 +507,6 @@ brick_val: goto out; } - gf_cmd_log ("Volume add-brick", "volname: %s type %d count:%d bricks:%s" - ,volname, volinfo->type, brick_count, brick_list); - if (type != volinfo->type) { ret = dict_set_int32 (dict, "type", type); if (ret) @@ -523,19 +517,17 @@ brick_val: ret = glusterd_op_begin (req, GD_OP_ADD_BRICK, dict); out: - gf_cmd_log ("Volume add-brick","on volname: %s %s", volname, - (ret != 0)? "FAILED" : "SUCCESS"); if (ret) { - if (dict) - dict_unref (dict); rsp.op_ret = -1; rsp.op_errno = 0; if (err_str[0] == '\0') snprintf (err_str, sizeof (err_str), "Operation failed"); rsp.op_errstr = err_str; cli_rsp = &rsp; - glusterd_submit_reply(req, cli_rsp, NULL, 0, NULL, - (xdrproc_t)xdr_gf_cli_rsp); + glusterd_to_cli (req, cli_rsp, NULL, 0, NULL, + (xdrproc_t)xdr_gf_cli_rsp, dict); + if (dict) + dict_unref (dict); ret = 0; //sent error to cli, prevent second reply } @@ -610,7 +602,6 @@ glusterd_handle_remove_brick (rpcsvc_request_t *req) goto out; } - gf_cmd_log ("Volume remove-brick","on volname: %s attempted", volname); ret = dict_get_int32 (dict, "count", &count); if (ret) { gf_log ("", GF_LOG_ERROR, "Unable to get count"); @@ -814,17 +805,11 @@ glusterd_handle_remove_brick (rpcsvc_request_t *req) break; } } - gf_cmd_log ("Volume remove-brick","volname: %s count:%d bricks:%s", - volname, count, brick_list); ret = glusterd_op_begin (req, GD_OP_REMOVE_BRICK, dict); - gf_cmd_log ("Volume remove-brick","on volname: %s %s", volname, - (ret) ? "FAILED" : "SUCCESS"); out: if (ret) { - if (dict) - dict_unref (dict); rsp.op_ret = -1; rsp.op_errno = 0; if (err_str[0] == '\0') @@ -832,8 +817,10 @@ out: gf_log ("", GF_LOG_ERROR, "%s", err_str); rsp.op_errstr = err_str; cli_rsp = &rsp; - glusterd_submit_reply(req, cli_rsp, NULL, 0, NULL, - (xdrproc_t)xdr_gf_cli_rsp); + glusterd_to_cli (req, cli_rsp, NULL, 0, NULL, + (xdrproc_t)xdr_gf_cli_rsp, dict); + if (dict) + dict_unref (dict); ret = 0; //sent error to cli, prevent second reply |