14f8ab
From 98c9fc8d774ae153ca6b44d3337cf5d9f7a030e2 Mon Sep 17 00:00:00 2001
14f8ab
From: Kotresh HR <khiremat@redhat.com>
14f8ab
Date: Fri, 16 Aug 2019 16:07:03 +0530
14f8ab
Subject: [PATCH 282/284] geo-rep: Fix the name of changelog archive file
14f8ab
14f8ab
Background:
14f8ab
The processed changelogs are archived each month in a single tar file.
14f8ab
The default format is "archive_YYYYMM.tar" which is specified as "%%Y%%m"
14f8ab
in configuration file.
14f8ab
14f8ab
Problem:
14f8ab
The created changelog archive file didn't have corresponding year
14f8ab
and month. It created as "archive_%Y%m.tar" on python2 only systems.
14f8ab
14f8ab
Cause and Fix:
14f8ab
Geo-rep expects "%Y%m" after the ConfigParser reads it from config file.
14f8ab
Since it was "%%Y%%m" in config file, geo-rep used to get correct value
14f8ab
"%Y%m" in python3 and "%%Y%%m" in python2 which is incorrect.
14f8ab
The fix can be to use "%Y%m" in config file but that fails in python3.
14f8ab
So the fix is to use "RawConfigParser" in geo-rep and use "%Y%m". This
14f8ab
works both in python2 and python3.
14f8ab
14f8ab
Backport of:
14f8ab
 > Patch: https://review.gluster.org/23248
14f8ab
 > Change-Id: Ie5b7d2bc04d0d53cd1769e064c2d67aaf95d557c
14f8ab
 > fixes: bz#1741890
14f8ab
 > Signed-off-by: Kotresh HR <khiremat@redhat.com>
14f8ab
14f8ab
Change-Id: Ie5b7d2bc04d0d53cd1769e064c2d67aaf95d557c
14f8ab
BUG: 1743634
14f8ab
Signed-off-by: Kotresh HR <khiremat@redhat.com>
14f8ab
Reviewed-on: https://code.engineering.redhat.com/gerrit/179188
14f8ab
Tested-by: RHGS Build Bot <nigelb@redhat.com>
14f8ab
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
14f8ab
---
14f8ab
 geo-replication/gsyncd.conf.in             |  2 +-
14f8ab
 geo-replication/syncdaemon/gsyncdconfig.py | 14 +++++++-------
14f8ab
 2 files changed, 8 insertions(+), 8 deletions(-)
14f8ab
14f8ab
diff --git a/geo-replication/gsyncd.conf.in b/geo-replication/gsyncd.conf.in
14f8ab
index c2e4f0d..5ebd57a 100644
14f8ab
--- a/geo-replication/gsyncd.conf.in
14f8ab
+++ b/geo-replication/gsyncd.conf.in
14f8ab
@@ -109,7 +109,7 @@ type=int
14f8ab
 help=Minimum time interval in seconds for passive worker to become Active
14f8ab
 
14f8ab
 [changelog-archive-format]
14f8ab
-value=%%Y%%m
14f8ab
+value=%Y%m
14f8ab
 help=Processed changelogs will be archived in working directory. Pattern for archive file
14f8ab
 
14f8ab
 [use-meta-volume]
14f8ab
diff --git a/geo-replication/syncdaemon/gsyncdconfig.py b/geo-replication/syncdaemon/gsyncdconfig.py
14f8ab
index 38f3594..f823311 100644
14f8ab
--- a/geo-replication/syncdaemon/gsyncdconfig.py
14f8ab
+++ b/geo-replication/syncdaemon/gsyncdconfig.py
14f8ab
@@ -10,9 +10,9 @@
14f8ab
 #
14f8ab
 
14f8ab
 try:
14f8ab
-    from ConfigParser import ConfigParser, NoSectionError
14f8ab
+    from ConfigParser import RawConfigParser, NoSectionError
14f8ab
 except ImportError:
14f8ab
-    from configparser import ConfigParser, NoSectionError
14f8ab
+    from configparser import RawConfigParser, NoSectionError
14f8ab
 import os
14f8ab
 import shutil
14f8ab
 from string import Template
14f8ab
@@ -94,7 +94,7 @@ class Gconf(object):
14f8ab
         if name != "all" and not self._is_configurable(name):
14f8ab
             raise GconfNotConfigurable()
14f8ab
 
14f8ab
-        cnf = ConfigParser()
14f8ab
+        cnf = RawConfigParser()
14f8ab
         with open(self.custom_conf_file) as f:
14f8ab
             cnf.readfp(f)
14f8ab
 
14f8ab
@@ -138,7 +138,7 @@ class Gconf(object):
14f8ab
         if curr_val == value:
14f8ab
             return True
14f8ab
 
14f8ab
-        cnf = ConfigParser()
14f8ab
+        cnf = RawConfigParser()
14f8ab
         with open(self.custom_conf_file) as f:
14f8ab
             cnf.readfp(f)
14f8ab
 
14f8ab
@@ -178,7 +178,7 @@ class Gconf(object):
14f8ab
         self.session_conf_items = []
14f8ab
         self.default_values = {}
14f8ab
 
14f8ab
-        conf = ConfigParser()
14f8ab
+        conf = RawConfigParser()
14f8ab
         # Default Template config file
14f8ab
         with open(self.default_conf_file) as f:
14f8ab
             conf.readfp(f)
14f8ab
@@ -342,7 +342,7 @@ class Gconf(object):
14f8ab
         return False
14f8ab
 
14f8ab
 def is_config_file_old(config_file, mastervol, slavevol):
14f8ab
-    cnf = ConfigParser()
14f8ab
+    cnf = RawConfigParser()
14f8ab
     cnf.read(config_file)
14f8ab
     session_section = "peers %s %s" % (mastervol, slavevol)
14f8ab
     try:
14f8ab
@@ -357,7 +357,7 @@ def config_upgrade(config_file, ret):
14f8ab
     shutil.copyfile(config_file, config_file_backup)
14f8ab
 
14f8ab
     #write a new config file
14f8ab
-    config = ConfigParser()
14f8ab
+    config = RawConfigParser()
14f8ab
     config.add_section('vars')
14f8ab
 
14f8ab
     for key, value in ret.items():
14f8ab
-- 
14f8ab
1.8.3.1
14f8ab