12a457
From 2935963e3130b66dfc2f7a4ab8b0f2c6abe1949d Mon Sep 17 00:00:00 2001
12a457
From: Pranith Kumar K <pkarampu@redhat.com>
12a457
Date: Mon, 21 Dec 2015 17:55:49 +0530
12a457
Subject: [PATCH 137/139] heal: Have fixed number of fields in heal info output
12a457
MIME-Version: 1.0
12a457
Content-Type: text/plain; charset=UTF-8
12a457
Content-Transfer-Encoding: 8bit
12a457
12a457
Sample output:
12a457
⚡ gluster v heal r2 info
12a457
Brick localhost.localdomain:/home/gfs/r2_0
12a457
/a
12a457
/
12a457
Status: Connected
12a457
Number of entries: 2
12a457
12a457
Brick localhost.localdomain:/home/gfs/r2_1
12a457
Status: Transport endpoint is not connected
12a457
Number of entries: -
12a457
12a457
Brick localhost.localdomain:/home/gfs/r2_2
12a457
Status: Connected
12a457
Number of entries: 0
12a457
12a457
Brick localhost.localdomain:/home/gfs/r2_3
12a457
Status: Connected
12a457
Number of entries: 0
12a457
12a457
Partial failure will print:
12a457
...
12a457
<gfid:3efb51cf-5fa5-4bed-817b-afd600e9449e>
12a457
Status: Failed to process entries completely. (Transport endpoint is not connected)
12a457
Number of entries: 372
12a457
...
12a457
12a457
 >BUG: 1297897
12a457
 >Change-Id: I79131cbf255acd98f11eedafb53246c465f6665d
12a457
 >Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
12a457
 >Reviewed-on: http://review.gluster.org/13231
12a457
 >Smoke: Gluster Build System <jenkins@build.gluster.com>
12a457
 >Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com>
12a457
 >Reviewed-by: Sahina Bose <sabose@redhat.com>
12a457
 >NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
12a457
 >CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
12a457
12a457
BUG: 1097555
12a457
Change-Id: I3b7a5511c6f734234b04928190d19feebea22310
12a457
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
12a457
Reviewed-on: https://code.engineering.redhat.com/gerrit/73910
12a457
---
12a457
 heal/src/glfs-heal.c |   31 ++++++++++++++++++++-----------
12a457
 1 files changed, 20 insertions(+), 11 deletions(-)
12a457
12a457
diff --git a/heal/src/glfs-heal.c b/heal/src/glfs-heal.c
12a457
index 1af58de..19bf417 100644
12a457
--- a/heal/src/glfs-heal.c
12a457
+++ b/heal/src/glfs-heal.c
12a457
@@ -56,23 +56,32 @@ void
12a457
 glfsh_print_heal_op_status (int ret, uint64_t num_entries,
12a457
                             gf_xl_afr_op_t heal_op)
12a457
 {
12a457
+        char *fmt_str = NULL;
12a457
 
12a457
-        if (ret == -ENOTCONN && num_entries == 0) {
12a457
+        if (heal_op == GF_SHD_OP_INDEX_SUMMARY)
12a457
+                fmt_str = "Number of entries:";
12a457
+        else if (heal_op == GF_SHD_OP_SPLIT_BRAIN_FILES)
12a457
+                fmt_str = "Number of entries in split-brain:";
12a457
+        else if (heal_op == GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK)
12a457
+                fmt_str = "Number of healed entries:";
12a457
+
12a457
+        if (ret < 0 && num_entries == 0) {
12a457
                 printf ("Status: %s\n", strerror (-ret));
12a457
+                if (fmt_str)
12a457
+                        printf ("%s -\n", fmt_str);
12a457
                 return;
12a457
+        } else if (ret == 0) {
12a457
+                printf ("Status: Connected\n");
12a457
         }
12a457
+
12a457
         if (ret < 0) {
12a457
-                printf ("Failed to process entries completely. "
12a457
-                         "Number of entries so far: %"PRIu64"\n", num_entries);
12a457
+                if (fmt_str)
12a457
+                        printf ("Status: Failed to process entries completely. "
12a457
+                                "(%s)\n%s: %"PRIu64"\n",
12a457
+                         strerror (-ret), fmt_str, num_entries);
12a457
         } else {
12a457
-                if (heal_op == GF_SHD_OP_INDEX_SUMMARY)
12a457
-                        printf ("Number of entries: %"PRIu64"\n", num_entries);
12a457
-                else if (heal_op == GF_SHD_OP_SPLIT_BRAIN_FILES)
12a457
-                        printf ("Number of entries in split-brain: %"PRIu64"\n"
12a457
-                                , num_entries);
12a457
-                else if (heal_op == GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK)
12a457
-                        printf ("Number of healed entries: %"PRIu64"\n",
12a457
-                                num_entries);
12a457
+                if (fmt_str)
12a457
+                        printf ("%s %"PRIu64"\n", fmt_str, num_entries);
12a457
         }
12a457
         return;
12a457
 }
12a457
-- 
12a457
1.7.1
12a457