Blob Blame History Raw
From eaa1f5a1f4d319d1fd2eec2e54abccc034aff326 Mon Sep 17 00:00:00 2001
From: Aravinda VK <avishwan@redhat.com>
Date: Tue, 6 Jun 2017 17:59:59 +0530
Subject: [PATCH 498/509] geo-rep: Fix ConfigInterface Template issue

ConfigParser uses string Template to substitute the dynamic values
for config. For some of the configurations, Geo-rep worker will
not restart. Due to this conf object may have non string values.

If val is not string in Template(val), then it fails with
"TypeError: expected string or buffer"

> Reviewed-on: https://review.gluster.org/17489
> 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: Kotresh HR <khiremat@redhat.com>

BUG: 1448386
Change-Id: I25b8bbc1df42f6f29e9563a55b3e27a228321c44
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/108895
Reviewed-by: Kotresh Hiremath Ravishankar <khiremat@redhat.com>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 geo-replication/syncdaemon/configinterface.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/geo-replication/syncdaemon/configinterface.py b/geo-replication/syncdaemon/configinterface.py
index 50e7aed..95c153e 100644
--- a/geo-replication/syncdaemon/configinterface.py
+++ b/geo-replication/syncdaemon/configinterface.py
@@ -337,12 +337,18 @@ class GConffile(object):
 
         def update_from_sect(sect, mud):
             for k, v in self.config._sections[sect].items():
+                # Template expects String to be passed
+                # if any config value is not string then it
+                # fails with ValueError
+                v = u"{0}".format(v)
+
                 if k == '__name__':
                     continue
                 if allow_unresolved:
                     dct[k] = Template(v).safe_substitute(mud)
                 else:
                     dct[k] = Template(v).substitute(mud)
+
         for sect in self.ord_sections():
             sp = self.parse_section(sect)
             if isinstance(sp[0], re_type) and len(sp) == len(self.peers):
-- 
1.8.3.1