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