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-rebalance.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-rebalance.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-rebalance.c | 53 |
1 files changed, 2 insertions, 51 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-rebalance.c b/xlators/mgmt/glusterd/src/glusterd-rebalance.c index 2de20fdcf6e..dab8f68f0b1 100644 --- a/xlators/mgmt/glusterd/src/glusterd-rebalance.c +++ b/xlators/mgmt/glusterd/src/glusterd-rebalance.c @@ -40,51 +40,6 @@ int32_t glusterd_brick_op_cbk (struct rpc_req *req, struct iovec *iov, int count, void *myframe); - -void -glusterd_rebalance_cmd_attempted_log (int cmd, char *volname) -{ - switch (cmd) { - case GF_DEFRAG_CMD_START_LAYOUT_FIX: - gf_cmd_log ("Volume rebalance"," on volname: %s " - "cmd: start fix layout , attempted", - volname); - gf_log ("glusterd", GF_LOG_INFO, "Received rebalance " - "volume start layout fix on %s", volname); - break; - case GF_DEFRAG_CMD_START_FORCE: - gf_cmd_log ("Volume rebalance"," on volname: %s " - "cmd: start data force attempted", - volname); - gf_log ("glusterd", GF_LOG_INFO, "Received rebalance " - "volume start migrate data on %s", volname); - break; - case GF_DEFRAG_CMD_START: - gf_cmd_log ("Volume rebalance"," on volname: %s " - "cmd: start, attempted", volname); - gf_log ("glusterd", GF_LOG_INFO, "Received rebalance " - "volume start on %s", volname); - break; - case GF_DEFRAG_CMD_STOP: - gf_cmd_log ("Volume rebalance"," on volname: %s " - "cmd: stop, attempted", volname); - gf_log ("glusterd", GF_LOG_INFO, "Received rebalance " - "volume stop on %s", volname); - break; - default: - break; - } -} - -void -glusterd_rebalance_cmd_log (int cmd, char *volname, int status) -{ - if (cmd != GF_DEFRAG_CMD_STATUS) { - gf_cmd_log ("volume rebalance"," on volname: %s %d %s", - volname, cmd, ((status)?"FAILED":"SUCCESS")); - } -} - int glusterd_defrag_start_validate (glusterd_volinfo_t *volinfo, char *op_errstr, size_t len) @@ -463,8 +418,6 @@ glusterd_handle_defrag_volume (rpcsvc_request_t *req) goto out; } - glusterd_rebalance_cmd_attempted_log (cmd, volname); - ret = dict_set_static_bin (dict, "node-uuid", MY_UUID, 16); if (ret) goto out; @@ -482,10 +435,10 @@ out: glusterd_op_sm (); if (ret) { + ret = glusterd_op_send_cli_response (GD_OP_REBALANCE, ret, 0, req, + dict, "operation failed"); if (dict) dict_unref (dict); - ret = glusterd_op_send_cli_response (GD_OP_REBALANCE, ret, 0, req, - NULL, "operation failed"); } free (cli_req.dict.dict_val);//malloced by xdr @@ -628,8 +581,6 @@ glusterd_op_rebalance (dict_t *dict, char **op_errstr, dict_t *rsp_dict) break; } - glusterd_rebalance_cmd_log (cmd, volname, ret); - out: if (ret && op_errstr && msg[0]) *op_errstr = gf_strdup (msg); |