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