21ab4e
From a7d463c44d1daa0be48a5ad063ec63b5a8e8002e Mon Sep 17 00:00:00 2001
21ab4e
From: Aravinda VK <avishwan@redhat.com>
21ab4e
Date: Mon, 12 Dec 2016 13:06:15 +0530
21ab4e
Subject: [PATCH 308/361] geo-rep: Fix log-rsync-performance config issue
21ab4e
21ab4e
If log-rsync-performance config is not set, gconf.get_realtime
21ab4e
will return None, Added default value as False if config file
21ab4e
doesn't have this option set.
21ab4e
21ab4e
mainline:
21ab4e
> BUG: 1393678
21ab4e
> Reviewed-on: http://review.gluster.org/16102
21ab4e
> Smoke: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
21ab4e
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
21ab4e
> Reviewed-by: Kotresh HR <khiremat@redhat.com>
21ab4e
> Tested-by: Kotresh HR <khiremat@redhat.com>
21ab4e
(cherry picked from commit 508e052a95e2f36173a274250f38dd92c8add868)
21ab4e
21ab4e
BUG: 1425690
21ab4e
Change-Id: I89016ab480a16179db59913d635d8553beb7e14f
21ab4e
Signed-off-by: Aravinda VK <avishwan@redhat.com>
21ab4e
Reviewed-on: https://code.engineering.redhat.com/gerrit/101288
21ab4e
Tested-by: Milind Changire <mchangir@redhat.com>
21ab4e
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
21ab4e
---
21ab4e
 geo-replication/syncdaemon/configinterface.py | 17 +++++++++--------
21ab4e
 geo-replication/syncdaemon/resource.py        |  9 +++++----
21ab4e
 2 files changed, 14 insertions(+), 12 deletions(-)
21ab4e
21ab4e
diff --git a/geo-replication/syncdaemon/configinterface.py b/geo-replication/syncdaemon/configinterface.py
21ab4e
index adcefb8..b5935df 100644
21ab4e
--- a/geo-replication/syncdaemon/configinterface.py
21ab4e
+++ b/geo-replication/syncdaemon/configinterface.py
21ab4e
@@ -235,7 +235,7 @@ class GConffile(object):
21ab4e
             self.config.readfp(fp)
21ab4e
         self._normconfig()
21ab4e
 
21ab4e
-    def get_realtime(self, opt):
21ab4e
+    def get_realtime(self, opt, default_value=None):
21ab4e
         try:
21ab4e
             sres = os.stat(self.path)
21ab4e
         except (OSError, IOError):
21ab4e
@@ -249,7 +249,7 @@ class GConffile(object):
21ab4e
            sres[ST_INO] != self.ino or self.mtime != sres[ST_MTIME]:
21ab4e
             self._load()
21ab4e
 
21ab4e
-        return self.get(opt, printValue=False)
21ab4e
+        return self.get(opt, printValue=False, default_value=default_value)
21ab4e
 
21ab4e
     def section(self, rx=False):
21ab4e
         """get the section name of the section representing .peers
21ab4e
@@ -348,7 +348,7 @@ class GConffile(object):
21ab4e
         if self.config.has_section(self.section()):
21ab4e
             update_from_sect(self.section(), MultiDict(dct, *self.auxdicts))
21ab4e
 
21ab4e
-    def get(self, opt=None, printValue=True):
21ab4e
+    def get(self, opt=None, printValue=True, default_value=None):
21ab4e
         """print the matching key/value pairs from .config,
21ab4e
            or if @opt given, the value for @opt (according to the
21ab4e
            logic described in .update_to)
21ab4e
@@ -357,12 +357,13 @@ class GConffile(object):
21ab4e
         self.update_to(d, allow_unresolved=True)
21ab4e
         if opt:
21ab4e
             opt = norm(opt)
21ab4e
-            v = d.get(opt)
21ab4e
-            if v:
21ab4e
-                if printValue:
21ab4e
+            v = d.get(opt, default_value)
21ab4e
+
21ab4e
+            if printValue:
21ab4e
+                if v is not None:
21ab4e
                     print(v)
21ab4e
-                else:
21ab4e
-                    return v
21ab4e
+            else:
21ab4e
+                return v
21ab4e
         else:
21ab4e
             for k, v in d.iteritems():
21ab4e
                 if k == '__name__':
21ab4e
diff --git a/geo-replication/syncdaemon/resource.py b/geo-replication/syncdaemon/resource.py
21ab4e
index be663e4..9c7a70a 100644
21ab4e
--- a/geo-replication/syncdaemon/resource.py
21ab4e
+++ b/geo-replication/syncdaemon/resource.py
21ab4e
@@ -1001,8 +1001,10 @@ class SlaveRemote(object):
21ab4e
             (boolify(gconf.sync_acls) and ['--acls'] or []) + \
21ab4e
             ['.'] + list(args)
21ab4e
 
21ab4e
-        if boolify(gconf.configinterface.get_realtime(
21ab4e
-                "log_rsync_performance")):
21ab4e
+        log_rsync_performance = boolify(gconf.configinterface.get_realtime(
21ab4e
+            "log_rsync_performance", default_value=False))
21ab4e
+
21ab4e
+        if log_rsync_performance:
21ab4e
             # use stdout=PIPE only when log_rsync_performance enabled
21ab4e
             # Else rsync will write to stdout and nobody is their
21ab4e
             # to consume. If PIPE is full rsync hangs.
21ab4e
@@ -1021,8 +1023,7 @@ class SlaveRemote(object):
21ab4e
             for errline in stderr.strip().split("\n")[:-1]:
21ab4e
                 logging.error("SYNC Error(Rsync): %s" % errline)
21ab4e
 
21ab4e
-        if boolify(gconf.configinterface.get_realtime(
21ab4e
-                "log_rsync_performance")):
21ab4e
+        if log_rsync_performance:
21ab4e
             rsync_msg = []
21ab4e
             for line in stdout.split("\n"):
21ab4e
                 if line.startswith("Number of files:") or \
21ab4e
-- 
21ab4e
1.8.3.1
21ab4e