summaryrefslogtreecommitdiffstats
path: root/geo-replication
diff options
context:
space:
mode:
authorAravinda VK <avishwan@redhat.com>2017-07-03 14:51:21 +0530
committerAravinda VK <avishwan@redhat.com>2017-07-21 04:44:30 +0000
commite01783d871fbbf5a598d3bbf984ea98bafa5c10f (patch)
tree75c59aeed006ae002b7a0ce4a4637abc9d722e46 /geo-replication
parent5353389faf77bb2edb54e785c3d8aca323188dad (diff)
geo-rep: Fix changelog encoding to encode only space and newline
libgfchangelog was encoding path using spec rfc3986, but encoding only required for SPACE and NEWLINE chars since the NEWLINE char is used as record separator and SPACE as field separator in the parsed changelogs output. Changed the encoding function to encode only SPACE and NEWLINE. BUG: 1451724 Change-Id: I1936efad31788a9e636f912c832ed7d7efea4fe2 Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on: https://review.gluster.org/17787 Reviewed-by: Prashanth Pai <ppai@redhat.com> Reviewed-by: Kotresh HR <khiremat@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.org>
Diffstat (limited to 'geo-replication')
-rw-r--r--geo-replication/syncdaemon/master.py31
-rw-r--r--geo-replication/syncdaemon/syncdutils.py15
2 files changed, 33 insertions, 13 deletions
diff --git a/geo-replication/syncdaemon/master.py b/geo-replication/syncdaemon/master.py
index 9bd6721eab5..372717e36f2 100644
--- a/geo-replication/syncdaemon/master.py
+++ b/geo-replication/syncdaemon/master.py
@@ -22,8 +22,8 @@ from errno import ENOENT, ENODATA, EEXIST, EACCES, EAGAIN, ESTALE
from threading import Condition, Lock
from datetime import datetime
from gconf import gconf
-from syncdutils import Thread, GsyncdError, boolify, escape
-from syncdutils import unescape, gauxpfx, md5hex, selfkill
+from syncdutils import Thread, GsyncdError, boolify, escape_space_newline
+from syncdutils import unescape_space_newline, gauxpfx, md5hex, selfkill
from syncdutils import lstat, errno_wrap, FreeObject, lf
from syncdutils import NoStimeAvailable, PartialHistoryAvailable
@@ -852,7 +852,8 @@ class GMasterChangelogMixin(GMasterCommon):
self.update_fop_batch_stats(ec[self.POS_TYPE])
# PARGFID/BNAME
- en = unescape(os.path.join(pfx, ec[self.POS_ENTRY1]))
+ en = unescape_space_newline(
+ os.path.join(pfx, ec[self.POS_ENTRY1]))
# GFID of the entry
gfid = ec[self.POS_GFID]
@@ -860,7 +861,8 @@ class GMasterChangelogMixin(GMasterCommon):
# The index of PARGFID/BNAME for UNLINK, RMDIR
# is no more the last index. It varies based on
# changelog.capture-del-path is enabled or not.
- en = unescape(os.path.join(pfx, ec[self.UNLINK_ENTRY]))
+ en = unescape_space_newline(
+ os.path.join(pfx, ec[self.UNLINK_ENTRY]))
# Remove from DATA list, so that rsync will
# not fail
@@ -918,7 +920,8 @@ class GMasterChangelogMixin(GMasterCommon):
if isinstance(rl, int):
rl = None
- e1 = unescape(os.path.join(pfx, ec[self.POS_ENTRY1 - 1]))
+ e1 = unescape_space_newline(
+ os.path.join(pfx, ec[self.POS_ENTRY1 - 1]))
entries.append(edct(ty, gfid=gfid, entry=e1, entry1=en,
stat=st, link=rl))
else:
@@ -1583,8 +1586,10 @@ class GMasterXsyncMixin(GMasterChangelogMixin):
self.sync_done(self.stimes, False)
self.stimes = []
if stat.S_ISDIR(mo):
- self.write_entry_change("E", [gfid, 'MKDIR', str(mo),
- str(0), str(0), escape(os.path.join(pargfid, bname))])
+ self.write_entry_change("E",
+ [gfid, 'MKDIR', str(mo),
+ str(0), str(0), escape_space_newline(
+ os.path.join(pargfid, bname))])
self.write_entry_change("M", [gfid, "SETATTR", str(st.st_uid),
str(st.st_gid), str(st.st_mode),
str(st.st_atime),
@@ -1603,8 +1608,8 @@ class GMasterXsyncMixin(GMasterChangelogMixin):
self.stimes.append((e, stime_to_update))
elif stat.S_ISLNK(mo):
self.write_entry_change(
- "E", [gfid, 'SYMLINK', escape(os.path.join(pargfid,
- bname))])
+ "E", [gfid, 'SYMLINK', escape_space_newline(
+ os.path.join(pargfid, bname))])
elif stat.S_ISREG(mo):
nlink = st.st_nlink
nlink -= 1 # fixup backend stat link count
@@ -1615,12 +1620,12 @@ class GMasterXsyncMixin(GMasterChangelogMixin):
self.write_entry_change("E",
[gfid, 'MKNOD', str(mo),
str(0), str(0),
- escape(os.path.join(
- pargfid, bname))])
+ escape_space_newline(
+ os.path.join(pargfid, bname))])
else:
self.write_entry_change(
- "E", [gfid, 'LINK', escape(os.path.join(pargfid,
- bname))])
+ "E", [gfid, 'LINK', escape_space_newline(
+ os.path.join(pargfid, bname))])
self.write_entry_change("D", [gfid])
if path == '.':
stime_to_update = xtl
diff --git a/geo-replication/syncdaemon/syncdutils.py b/geo-replication/syncdaemon/syncdutils.py
index b5f09459c57..43b21668a46 100644
--- a/geo-replication/syncdaemon/syncdutils.py
+++ b/geo-replication/syncdaemon/syncdutils.py
@@ -70,6 +70,9 @@ CHANGELOG_AGENT_SERVER_VERSION = 1.0
CHANGELOG_AGENT_CLIENT_VERSION = 1.0
NodeID = None
rsync_version = None
+SPACE_ESCAPE_CHAR = "%20"
+NEWLINE_ESCAPE_CHAR = "%0A"
+PERCENTAGE_ESCAPE_CHAR = "%25"
def escape(s):
@@ -83,6 +86,18 @@ def unescape(s):
return urllib.unquote_plus(s)
+def escape_space_newline(s):
+ return s.replace("%", PERCENTAGE_ESCAPE_CHAR)\
+ .replace(" ", SPACE_ESCAPE_CHAR)\
+ .replace("\n", NEWLINE_ESCAPE_CHAR)
+
+
+def unescape_space_newline(s):
+ return s.replace(SPACE_ESCAPE_CHAR, " ")\
+ .replace(NEWLINE_ESCAPE_CHAR, "\n")\
+ .replace(PERCENTAGE_ESCAPE_CHAR, "%")
+
+
def norm(s):
if s:
return s.replace('-', '_')