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