From c37f00c27cd27364896400704963737bb6c90668 Mon Sep 17 00:00:00 2001
From: Samikshan Bairagya <samikshan@gmail.com>
Date: Thu, 13 Oct 2016 17:13:54 +0530
Subject: [PATCH 135/141] cli, glusterd: Address issues in get-state cli output
This fixes the following data points:
1. Volume type
2. Peer state
3. List of other hostnames for a peer
4. Data unit information for rebalance
The following data points are removed:
1. Mount options and filesystem types for bricks
2. global-option-version from list of global options
The following data points are added:
1. Replica Count
2. Tier type for bricks belonging to hot/cold tier
> Reviewed-on: http://review.gluster.org/15662
> Reviewed-by: mohammed rafi kc <rkavunga@redhat.com>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
> Smoke: Gluster Build System <jenkins@build.gluster.org>
> Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
>Reviewed-on: http://review.gluster.org/15696
>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: Atin Mukherjee <amukherj@redhat.com>
Change-Id: I5011250e863fdc4929b203cdb345d79b2f16c6a5
BUG: 1382277
Signed-off-by: Samikshan Bairagya <samikshan@gmail.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/87965
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Tested-by: Atin Mukherjee <amukherj@redhat.com>
---
xlators/mgmt/glusterd/src/glusterd-handler.c | 57 +++++++++++++---------
xlators/mgmt/glusterd/src/glusterd-peer-utils.c | 51 --------------------
xlators/mgmt/glusterd/src/glusterd-peer-utils.h | 3 -
xlators/mgmt/glusterd/src/glusterd-utils.c | 4 +-
4 files changed, 36 insertions(+), 79 deletions(-)
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index d81204e..d2bb20d 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -4957,6 +4957,9 @@ glusterd_print_global_options (dict_t *opts, char *key, data_t *val, void *data)
GF_VALIDATE_OR_GOTO (THIS->name, val, out);
GF_VALIDATE_OR_GOTO (THIS->name, data, out);
+ if (strcmp (key, "global-option-version") == 0)
+ goto out;
+
fp = (FILE *) data;
fprintf (fp, "%s: %s\n", key, val->data);
out:
@@ -5045,7 +5048,6 @@ glusterd_get_state (rpcsvc_request_t *req, dict_t *dict)
char transport_type_str[STATUS_STRLEN] = {0,};
char quorum_status_str[STATUS_STRLEN] = {0,};
char rebal_status_str[STATUS_STRLEN] = {0,};
- char peer_state_str[STATUS_STRLEN] = {0,};
char vol_status_str[STATUS_STRLEN] = {0,};
this = THIS;
@@ -5133,25 +5135,29 @@ glusterd_get_state (rpcsvc_request_t *req, dict_t *dict)
fprintf (fp, "\n[Peers]\n");
cds_list_for_each_entry_rcu (peerinfo, &priv->peers, uuid_list) {
- ret = gd_peer_state_str (peerinfo, peer_state_str);
- if (ret) {
- rcu_read_unlock ();
- gf_msg (this->name, GF_LOG_ERROR, 0,
- GD_MSG_STATE_STR_GET_FAILED,
- "Failed to get peer state");
- goto out;
- }
-
fprintf (fp, "Peer%d.primary_hostname: %s\n", ++count,
peerinfo->hostname);
fprintf (fp, "Peer%d.uuid: %s\n", count, gd_peer_uuid_str (peerinfo));
- fprintf (fp, "Peer%d.state: %s\n", count, peer_state_str);
- fprintf (fp, "Peer%d.connected: %d\n", count, peerinfo->connected);
+ fprintf (fp, "Peer%d.state: %s\n", count,
+ glusterd_friend_sm_state_name_get (peerinfo->state.state));
+ fprintf (fp, "Peer%d.connected: %s\n", count,
+ peerinfo->connected ? "Connected" : "Disconnected");
- fprintf (fp, "Peer%d.hostnames: ", count);
+ fprintf (fp, "Peer%d.othernames: ", count);
+ count_bkp = 0;
cds_list_for_each_entry (peer_hostname_info,
- &peerinfo->hostnames, hostname_list)
- fprintf (fp, "%s, ", peer_hostname_info->hostname);
+ &peerinfo->hostnames, hostname_list) {
+ if (strcmp (peerinfo->hostname,
+ peer_hostname_info->hostname) == 0)
+ continue;
+
+ if (count_bkp > 0)
+ fprintf (fp, ",");
+
+ fprintf (fp, "%s", peer_hostname_info->hostname);
+ count_bkp++;
+ }
+ count_bkp = 0;
fprintf (fp, "\n");
}
rcu_read_unlock ();
@@ -5237,12 +5243,17 @@ glusterd_get_state (rpcsvc_request_t *req, dict_t *dict)
count, brickinfo->rdma_port);
fprintf (fp, "Volume%d.Brick%d.status: %s\n", count_bkp,
count, brickinfo->status ? "Started" : "Stopped");
- fprintf (fp, "Volume%d.Brick%d.filesystem_type: %s\n",
- count_bkp, count, brickinfo->fstype);
- fprintf (fp, "Volume%d.Brick%d.mount_options: %s\n",
- count_bkp, count, brickinfo->mnt_opts);
fprintf (fp, "Volume%d.Brick%d.signedin: %s\n", count_bkp,
count, brickinfo->signed_in ? "True" : "False");
+
+ /*FIXME: This is a hacky way of figuring out whether a
+ * brick belongs to the hot or cold tier */
+ if (volinfo->type == GF_CLUSTER_TYPE_TIER) {
+ fprintf (fp, "Volume%d.Brick%d.tier: %s\n",
+ count_bkp, count,
+ count <= volinfo->tier_info.hot_brick_count ?
+ "Hot" : "Cold");
+ }
}
count = count_bkp;
@@ -5255,6 +5266,8 @@ glusterd_get_state (rpcsvc_request_t *req, dict_t *dict)
volinfo->snap_count);
fprintf (fp, "Volume%d.stripe_count: %d\n", count,
volinfo->stripe_count);
+ fprintf (fp, "Volume%d.replica_count: %d\n", count,
+ volinfo->replica_count);
fprintf (fp, "Volume%d.subvol_count: %d\n", count,
volinfo->subvol_count);
fprintf (fp, "Volume%d.arbiter_count: %d\n", count,
@@ -5283,10 +5296,8 @@ glusterd_get_state (rpcsvc_request_t *req, dict_t *dict)
volinfo->rebal.lookedup_files);
fprintf (fp, "Volume%d.rebalance.files: %"PRIu64"\n", count,
volinfo->rebal.rebalance_files);
- fprintf (fp, "Volume%d.rebalance.data: %"PRIu64"\n", count,
- volinfo->rebal.rebalance_data);
- fprintf (fp, "Volume%d.rebalance.data: %"PRIu64"\n", count,
- volinfo->rebal.rebalance_data);
+ fprintf (fp, "Volume%d.rebalance.data: %s\n", count,
+ gf_uint64_2human_readable (volinfo->rebal.rebalance_data));
if (volinfo->type == GF_CLUSTER_TYPE_TIER) {
ret = glusterd_volume_get_hot_tier_type_str (
diff --git a/xlators/mgmt/glusterd/src/glusterd-peer-utils.c b/xlators/mgmt/glusterd/src/glusterd-peer-utils.c
index 509efb7..72d6b17 100644
--- a/xlators/mgmt/glusterd/src/glusterd-peer-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-peer-utils.c
@@ -393,57 +393,6 @@ gd_peer_uuid_str (glusterd_peerinfo_t *peerinfo)
return peerinfo->uuid_str;
}
-int
-gd_peer_state_str (glusterd_peerinfo_t *peerinfo, char *state_str)
-{
- int ret = -1;
-
- GF_VALIDATE_OR_GOTO (THIS->name, peerinfo, out);
- GF_VALIDATE_OR_GOTO (THIS->name, state_str, out);
-
- switch (peerinfo->state.state) {
- case GD_FRIEND_STATE_DEFAULT:
- gf_asprintf (&state_str, "%s", "default");
- break;
- case GD_FRIEND_STATE_REQ_SENT:
- gf_asprintf (&state_str, "%s", "request sent");
- break;
- case GD_FRIEND_STATE_REQ_RCVD:
- gf_asprintf (&state_str, "%s", "request received");
- break;
- case GD_FRIEND_STATE_BEFRIENDED:
- gf_asprintf (&state_str, "%s", "befriended");
- break;
- case GD_FRIEND_STATE_REQ_ACCEPTED:
- gf_asprintf (&state_str, "%s", "request accepted");
- break;
- case GD_FRIEND_STATE_REQ_SENT_RCVD:
- gf_asprintf (&state_str, "%s", "request sent received");
- break;
- case GD_FRIEND_STATE_REJECTED:
- gf_asprintf (&state_str, "%s", "rejected");
- break;
- case GD_FRIEND_STATE_UNFRIEND_SENT:
- gf_asprintf (&state_str, "%s", "unfriend sent");
- break;
- case GD_FRIEND_STATE_PROBE_RCVD:
- gf_asprintf (&state_str, "%s", "probe received");
- break;
- case GD_FRIEND_STATE_CONNECTED_RCVD:
- gf_asprintf (&state_str, "%s", "connected received");
- break;
- case GD_FRIEND_STATE_CONNECTED_ACCEPTED:
- gf_asprintf (&state_str, "%s", "connected accepted");
- break;
- case GD_FRIEND_STATE_MAX:
- goto out;
- }
-
- ret = 0;
-out:
- return ret;
-}
-
gf_boolean_t
glusterd_are_all_peers_up ()
{
diff --git a/xlators/mgmt/glusterd/src/glusterd-peer-utils.h b/xlators/mgmt/glusterd/src/glusterd-peer-utils.h
index ee78b03..9332cf2 100644
--- a/xlators/mgmt/glusterd/src/glusterd-peer-utils.h
+++ b/xlators/mgmt/glusterd/src/glusterd-peer-utils.h
@@ -42,9 +42,6 @@ glusterd_uuid_to_hostname (uuid_t uuid);
char*
gd_peer_uuid_str (glusterd_peerinfo_t *peerinfo);
-int
-gd_peer_state_str (glusterd_peerinfo_t *peerinfo, char *state_str);
-
gf_boolean_t
glusterd_are_all_peers_up ();
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index dd8766b..df0c0ab 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -11244,8 +11244,8 @@ glusterd_volume_get_type_str (glusterd_volinfo_t *volinfo, char **voltype_str)
GF_VALIDATE_OR_GOTO (THIS->name, volinfo, out);
- type = get_vol_type (volinfo->type, volinfo->brick_count,
- volinfo->dist_leaf_count);
+ type = get_vol_type (volinfo->type, volinfo->dist_leaf_count,
+ volinfo->brick_count);
*voltype_str = vol_type_str[type];
--
1.7.1