diff options
author | Atin Mukherjee <amukherj@redhat.com> | 2016-07-01 11:47:48 +0530 |
---|---|---|
committer | Jeff Darcy <jdarcy@redhat.com> | 2016-07-05 04:45:36 -0700 |
commit | 427ef5511232614bafcab686ad797cebb6a2d6b5 (patch) | |
tree | c0e57af2ca6b7dfe4e8cc1c80d6b2c6678620f1c /cli | |
parent | 967a77ed4db0e1c0bcc23f132e312b659ce961ef (diff) |
cli: print volume status client output for partial bricks
In cli the response dictionary is parsed assuming all the bricks to be up.
If in a given cluster one of the node is down client details for the
bricks hosted by the same node are not available in the dictionary resulting
into a blank output for 'gluster volume status <volname> clients'
Fix is to ignore the ret value for dict_get for those keys.
Change-Id: If4fb65b8807ea3ac71b3ed1a754ea75f599e3613
BUG: 1351880
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-on: http://review.gluster.org/14842
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: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'cli')
-rw-r--r-- | cli/src/cli-rpc-ops.c | 37 |
1 files changed, 17 insertions, 20 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 25b1ccdd9cd..2d9c0a954b8 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -6950,29 +6950,33 @@ cli_print_volume_status_clients (dict_t *dict, gf_boolean_t notbrick) index_max = brick_index_max + other_count; for (i = 0; i <= index_max; i++) { + hostname = NULL; + path = NULL; + online = -1; + client_count = 0; + clientname = NULL; + bytesread = 0; + byteswrite = 0; + cli_out ("----------------------------------------------"); memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.hostname", i); ret = dict_get_str (dict, key, &hostname); - if (ret) - goto out; + memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.path", i); ret = dict_get_str (dict, key, &path); - if (ret) - goto out; - - if (notbrick) - cli_out ("%s : %s", hostname, path); - else - cli_out ("Brick : %s:%s", hostname, path); + if (hostname && path) { + if (notbrick) + cli_out ("%s : %s", hostname, path); + else + cli_out ("Brick : %s:%s", hostname, path); + } memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.status", i); ret = dict_get_int32 (dict, key, &online); - if (ret) - goto out; if (!online) { if (notbrick) cli_out ("%s is offline", hostname); @@ -6984,10 +6988,9 @@ cli_print_volume_status_clients (dict_t *dict, gf_boolean_t notbrick) memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.clientcount", i); ret = dict_get_int32 (dict, key, &client_count); - if (ret) - goto out; - cli_out ("Clients connected : %d", client_count); + if (hostname && path) + cli_out ("Clients connected : %d", client_count); if (client_count == 0) continue; @@ -7000,22 +7003,16 @@ cli_print_volume_status_clients (dict_t *dict, gf_boolean_t notbrick) snprintf (key, sizeof (key), "brick%d.client%d.hostname", i, j); ret = dict_get_str (dict, key, &clientname); - if (ret) - goto out; memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.client%d.bytesread", i, j); ret = dict_get_uint64 (dict, key, &bytesread); - if (ret) - goto out; memset (key, 0, sizeof (key)); snprintf (key, sizeof (key), "brick%d.client%d.byteswrite", i, j); ret = dict_get_uint64 (dict, key, &byteswrite); - if (ret) - goto out; cli_out ("%-48s %15"PRIu64" %15"PRIu64, clientname, bytesread, byteswrite); |