|
|
14f8ab |
From 76921775b0a6760276060409882c0556f19d8d01 Mon Sep 17 00:00:00 2001
|
|
|
14f8ab |
From: Shwetha K Acharya <sacharya@redhat.com>
|
|
|
14f8ab |
Date: Wed, 29 May 2019 16:49:01 +0530
|
|
|
14f8ab |
Subject: [PATCH 214/221] geo-rep: Upgrading config file to new version
|
|
|
14f8ab |
|
|
|
14f8ab |
- configuration handling is enhanced with patch
|
|
|
14f8ab |
https://review.gluster.org/#/c/glusterfs/+/18257/
|
|
|
14f8ab |
- hence, the old configurations are not applied when
|
|
|
14f8ab |
Geo-rep session is created in the old version and upgraded.
|
|
|
14f8ab |
|
|
|
14f8ab |
This patch solves the issue. It,
|
|
|
14f8ab |
- checks if the config file is old.
|
|
|
14f8ab |
- parses required values from old config file and stores in new
|
|
|
14f8ab |
config file, which ensures that configurations are applied on
|
|
|
14f8ab |
upgrade.
|
|
|
14f8ab |
- stores old config file as backup.
|
|
|
14f8ab |
- handles changes in options introduced in
|
|
|
14f8ab |
https://review.gluster.org/#/c/glusterfs/+/18257/
|
|
|
14f8ab |
|
|
|
14f8ab |
>fixes: bz#1707731
|
|
|
14f8ab |
>Change-Id: Iad8da6c1e1ae8ecf7c84dfdf8ea3ac6966d8a2a0
|
|
|
14f8ab |
>Signed-off-by: Shwetha K Acharya <sacharya@redhat.com>
|
|
|
14f8ab |
|
|
|
14f8ab |
backport of https://review.gluster.org/#/c/glusterfs/+/22894/
|
|
|
14f8ab |
|
|
|
14f8ab |
Bug: 1708064
|
|
|
14f8ab |
Change-Id: Iad8da6c1e1ae8ecf7c84dfdf8ea3ac6966d8a2a0
|
|
|
14f8ab |
Signed-off-by: Shwetha K Acharya <sacharya@redhat.com>
|
|
|
14f8ab |
Reviewed-on: https://code.engineering.redhat.com/gerrit/174743
|
|
|
14f8ab |
Tested-by: RHGS Build Bot <nigelb@redhat.com>
|
|
|
14f8ab |
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
|
|
|
14f8ab |
---
|
|
|
14f8ab |
geo-replication/syncdaemon/gsyncd.py | 5 ++++
|
|
|
14f8ab |
geo-replication/syncdaemon/gsyncdconfig.py | 41 ++++++++++++++++++++++++++++++
|
|
|
14f8ab |
2 files changed, 46 insertions(+)
|
|
|
14f8ab |
|
|
|
14f8ab |
diff --git a/geo-replication/syncdaemon/gsyncd.py b/geo-replication/syncdaemon/gsyncd.py
|
|
|
14f8ab |
index effe0ce..a4c6f32 100644
|
|
|
14f8ab |
--- a/geo-replication/syncdaemon/gsyncd.py
|
|
|
14f8ab |
+++ b/geo-replication/syncdaemon/gsyncd.py
|
|
|
14f8ab |
@@ -253,6 +253,11 @@ def main():
|
|
|
14f8ab |
if args.subcmd == "slave":
|
|
|
14f8ab |
override_from_args = True
|
|
|
14f8ab |
|
|
|
14f8ab |
+ if args.subcmd == "monitor":
|
|
|
14f8ab |
+ ret = gconf.is_config_file_old(config_file, args.master, extra_tmpl_args["slavevol"])
|
|
|
14f8ab |
+ if ret is not None:
|
|
|
14f8ab |
+ gconf.config_upgrade(config_file, ret)
|
|
|
14f8ab |
+
|
|
|
14f8ab |
# Load Config file
|
|
|
14f8ab |
gconf.load(GLUSTERFS_CONFDIR + "/gsyncd.conf",
|
|
|
14f8ab |
config_file,
|
|
|
14f8ab |
diff --git a/geo-replication/syncdaemon/gsyncdconfig.py b/geo-replication/syncdaemon/gsyncdconfig.py
|
|
|
14f8ab |
index 23a1c57..7edc582 100644
|
|
|
14f8ab |
--- a/geo-replication/syncdaemon/gsyncdconfig.py
|
|
|
14f8ab |
+++ b/geo-replication/syncdaemon/gsyncdconfig.py
|
|
|
14f8ab |
@@ -14,6 +14,7 @@ try:
|
|
|
14f8ab |
except ImportError:
|
|
|
14f8ab |
from configparser import ConfigParser, NoSectionError
|
|
|
14f8ab |
import os
|
|
|
14f8ab |
+import shutil
|
|
|
14f8ab |
from string import Template
|
|
|
14f8ab |
from datetime import datetime
|
|
|
14f8ab |
|
|
|
14f8ab |
@@ -325,6 +326,46 @@ class Gconf(object):
|
|
|
14f8ab |
|
|
|
14f8ab |
return False
|
|
|
14f8ab |
|
|
|
14f8ab |
+def is_config_file_old(config_file, mastervol, slavevol):
|
|
|
14f8ab |
+ cnf = ConfigParser()
|
|
|
14f8ab |
+ cnf.read(config_file)
|
|
|
14f8ab |
+ session_section = "peers %s %s" % (mastervol, slavevol)
|
|
|
14f8ab |
+ try:
|
|
|
14f8ab |
+ return dict(cnf.items(session_section))
|
|
|
14f8ab |
+ except NoSectionError:
|
|
|
14f8ab |
+ return None
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+def config_upgrade(config_file, ret):
|
|
|
14f8ab |
+ config_file_backup = os.path.join(os.path.dirname(config_file), "gsyncd.conf.bkp")
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ #copy old config file in a backup file
|
|
|
14f8ab |
+ shutil.copyfile(config_file, config_file_backup)
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ #write a new config file
|
|
|
14f8ab |
+ config = ConfigParser()
|
|
|
14f8ab |
+ config.add_section('vars')
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ for key, value in ret.items():
|
|
|
14f8ab |
+ #handle option name changes
|
|
|
14f8ab |
+ if key == "use_tarssh":
|
|
|
14f8ab |
+ new_key = "sync-method"
|
|
|
14f8ab |
+ if value == "true":
|
|
|
14f8ab |
+ new_value = "tarssh"
|
|
|
14f8ab |
+ else:
|
|
|
14f8ab |
+ new_value = "rsync"
|
|
|
14f8ab |
+ config.set('vars', new_key, new_value)
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ if key == "timeout":
|
|
|
14f8ab |
+ new_key = "slave-timeout"
|
|
|
14f8ab |
+ config.set('vars', new_key, value)
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ #for changes like: ignore_deletes to ignore-deletes
|
|
|
14f8ab |
+ new_key = key.replace("_", "-")
|
|
|
14f8ab |
+ config.set('vars', new_key, value)
|
|
|
14f8ab |
+
|
|
|
14f8ab |
+ with open(config_file, 'w') as configfile:
|
|
|
14f8ab |
+ config.write(configfile)
|
|
|
14f8ab |
+
|
|
|
14f8ab |
|
|
|
14f8ab |
def validate_unixtime(value):
|
|
|
14f8ab |
try:
|
|
|
14f8ab |
--
|
|
|
14f8ab |
1.8.3.1
|
|
|
14f8ab |
|