From 4d73205fee5bf99527c78ef6838b14e3a2fdd4e3 Mon Sep 17 00:00:00 2001 From: Saravanakumar Arumugam Date: Mon, 30 May 2016 17:34:24 +0530 Subject: geo-rep: update peers section in gsyncd conf Problem: Once Slave volume uuid is involved as part of a geo-rep session, it is possible to create the same geo-rep session with different (slave)host. But, it reflects default values for geo-rep configuration values originally configured for old geo-rep session. Reason is, slave host is used while saving config options in gsyncd.conf. With new slave host, it is not possible to retrieve those config values. Solution: Remove slave host related information from gsyncd.conf and have only master volume and slave volume as part of peers section. Also, during upgrade from old geo-rep session, update peers section to reflect only master volume and slave volume. Change-Id: I7debf35a09a28d030b706b0c3e5d82c9b0467d0e BUG: 1341121 Reviewed-on: http://review.gluster.org/#/c/14558/ Signed-off-by: Saravanakumar Arumugam Reviewed-on: http://review.gluster.org/14566 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System CentOS-regression: Gluster Build System Reviewed-by: Aravinda VK --- geo-replication/syncdaemon/configinterface.py.in | 34 +++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'geo-replication') diff --git a/geo-replication/syncdaemon/configinterface.py.in b/geo-replication/syncdaemon/configinterface.py.in index 0570061955f..5d67b8a471a 100644 --- a/geo-replication/syncdaemon/configinterface.py.in +++ b/geo-replication/syncdaemon/configinterface.py.in @@ -108,6 +108,35 @@ def upgrade_config_file(path): config_change = True config.set(sec, opt, newval) + # To convert from old peers section format to new peers section format. + # Old format: peers gluster://: \ + # ssh://root@:gluster://: + # New format: peers + for old_sect in config.sections(): + if old_sect.startswith("peers "): + peers_data = old_sect.split(" ") + mvol = peers_data[1].split("%3A")[-1] + svol = peers_data[2].split("%3A")[-1] + new_sect = "peers {0} {1}".format(mvol, svol) + + if old_sect == new_sect: + # Already in new format "peers mastervol slavevol" + continue + + # Create new section if not exists + try: + config.add_section(new_sect) + except ConfigParser.DuplicateSectionError: + pass + + config_change = True + # Add all the items of old_sect to new_sect + for key, val in config.items(old_sect): + config.set(new_sect, key, val) + + # Delete old section + config.remove_section(old_sect) + if config_change: tempConfigFile = tempfile.NamedTemporaryFile(mode="wb", delete=False) with open(tempConfigFile.name, 'wb') as configFile: @@ -215,10 +244,9 @@ class GConffile(object): peers = ['.', '.'] rx = True if rx: - st = 'peersrx' + return ' '.join(['peersrx'] + [escape(u) for u in peers]) else: - st = 'peers' - return ' '.join([st] + [escape(u) for u in peers]) + return ' '.join(['peers'] + [u.split(':')[-1] for u in peers]) @staticmethod def parse_section(section): -- cgit