e3c68b
From 852c475040a599ed35798dbb388c6b59c1d0a820 Mon Sep 17 00:00:00 2001
e3c68b
From: Sanju Rakonde <srakonde@redhat.com>
e3c68b
Date: Tue, 22 Oct 2019 15:06:29 +0530
e3c68b
Subject: [PATCH 323/335] cli: display detailed rebalance info
e3c68b
e3c68b
Problem: When one of the node is down in cluster,
e3c68b
rebalance status is not displaying detailed
e3c68b
information.
e3c68b
e3c68b
Cause: In glusterd_volume_rebalance_use_rsp_dict()
e3c68b
we are aggregating rsp from all the nodes into a
e3c68b
dictionary and sending it to cli for printing. While
e3c68b
assigning a index to keys we are considering all the
e3c68b
peers instead of considering only the peers which are
e3c68b
up. Because of which, index is not reaching till 1.
e3c68b
while parsing the rsp cli unable to find status-1
e3c68b
key in dictionary and going out without printing
e3c68b
any information.
e3c68b
e3c68b
Solution: The simplest fix for this without much
e3c68b
code change is to continue to look for other keys
e3c68b
when status-1 key is not found.
e3c68b
e3c68b
> upstream patch: https://review.gluster.org/#/c/glusterfs/+/23588
e3c68b
> fixes: bz#1764119
e3c68b
> Change-Id: I0062839933c9706119eb85416256eade97e976dc
e3c68b
> Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
e3c68b
e3c68b
BUG: 1761326
e3c68b
Change-Id: I0062839933c9706119eb85416256eade97e976dc
e3c68b
Signed-off-by: Sanju Rakonde <srakonde@redhat.com>
e3c68b
Reviewed-on: https://code.engineering.redhat.com/gerrit/185749
e3c68b
Tested-by: RHGS Build Bot <nigelb@redhat.com>
e3c68b
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
e3c68b
---
e3c68b
 cli/src/cli-rpc-ops.c                      | 21 ++++++++++++++-------
e3c68b
 tests/bugs/glusterd/rebalance-in-cluster.t |  9 +++++++++
e3c68b
 2 files changed, 23 insertions(+), 7 deletions(-)
e3c68b
e3c68b
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
e3c68b
index b167e26..4e91265 100644
e3c68b
--- a/cli/src/cli-rpc-ops.c
e3c68b
+++ b/cli/src/cli-rpc-ops.c
e3c68b
@@ -1597,13 +1597,20 @@ gf_cli_print_rebalance_status(dict_t *dict, enum gf_task_types task_type,
e3c68b
         goto out;
e3c68b
     }
e3c68b
 
e3c68b
-    snprintf(key, sizeof(key), "status-1");
e3c68b
-
e3c68b
-    ret = dict_get_int32(dict, key, (int32_t *)&status_rcd);
e3c68b
-    if (ret) {
e3c68b
-        gf_log("cli", GF_LOG_TRACE, "count %d %d", count, 1);
e3c68b
-        gf_log("cli", GF_LOG_TRACE, "failed to get status");
e3c68b
-        goto out;
e3c68b
+    for (i = 1; i <= count; i++) {
e3c68b
+        snprintf(key, sizeof(key), "status-%d", i);
e3c68b
+        ret = dict_get_int32(dict, key, (int32_t *)&status_rcd);
e3c68b
+        /* If information from a node is missing we should skip
e3c68b
+         * the node and try to fetch information of other nodes.
e3c68b
+         * If information is not found for all nodes, we should
e3c68b
+         * error out.
e3c68b
+         */
e3c68b
+        if (!ret)
e3c68b
+            break;
e3c68b
+        if (ret && i == count) {
e3c68b
+            gf_log("cli", GF_LOG_TRACE, "failed to get status");
e3c68b
+            goto out;
e3c68b
+        }
e3c68b
     }
e3c68b
 
e3c68b
     /* Fix layout will be sent to all nodes for the volume
e3c68b
diff --git a/tests/bugs/glusterd/rebalance-in-cluster.t b/tests/bugs/glusterd/rebalance-in-cluster.t
e3c68b
index 9565fae..469ec6c 100644
e3c68b
--- a/tests/bugs/glusterd/rebalance-in-cluster.t
e3c68b
+++ b/tests/bugs/glusterd/rebalance-in-cluster.t
e3c68b
@@ -4,6 +4,10 @@
e3c68b
 . $(dirname $0)/../../cluster.rc
e3c68b
 . $(dirname $0)/../../volume.rc
e3c68b
 
e3c68b
+function rebalance_status_field_1 {
e3c68b
+        $CLI_1 volume rebalance $1 status | awk '{print $7}' | sed -n 3p
e3c68b
+}
e3c68b
+
e3c68b
 cleanup;
e3c68b
 TEST launch_cluster 2;
e3c68b
 TEST $CLI_1 peer probe $H2;
e3c68b
@@ -29,6 +33,11 @@ TEST $CLI_1 volume add-brick $V0 $H1:$B1/${V0}1 $H2:$B2/${V0}1
e3c68b
 TEST $CLI_1 volume rebalance $V0  start
e3c68b
 EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" cluster_rebalance_status_field 1  $V0
e3c68b
 
e3c68b
+#bug - 1764119 - rebalance status should display detailed info when any of the node is dowm
e3c68b
+TEST kill_glusterd 2
e3c68b
+EXPECT_WITHIN $REBALANCE_TIMEOUT "completed" rebalance_status_field_1 $V0
e3c68b
+
e3c68b
+TEST start_glusterd 2
e3c68b
 #bug-1245142
e3c68b
 
e3c68b
 $CLI_1 volume rebalance $V0  start &
e3c68b
-- 
e3c68b
1.8.3.1
e3c68b