summaryrefslogtreecommitdiffstats
path: root/geo-replication
diff options
context:
space:
mode:
authorMilind Changire <mchangir@redhat.com>2016-04-22 16:56:47 +0530
committerAravinda VK <avishwan@redhat.com>2016-06-28 23:41:54 -0700
commit70fd68d94f768c098b3178c151fa92c5079a8cfd (patch)
tree84b94505ceadc9aa99754a5e08ffd99908b1cc08 /geo-replication
parent1e60f9746cf7cb8ce34e2b1572410c39b11d7664 (diff)
downloadglusterfs-70fd68d94f768c098b3178c151fa92c5079a8cfd.tar.gz
glusterfs-70fd68d94f768c098b3178c151fa92c5079a8cfd.tar.xz
glusterfs-70fd68d94f768c098b3178c151fa92c5079a8cfd.zip
georep: add reset-sync-time option for session delete
Set the stime xattr at all the brick roots to (0,0) if the argument reset-sync-time has been provided on the command-line. To avoid testing against directory specific stime, the remote stime is assumed to be minus_infinity, if the root directory stime is set to (0,0), before the directory scan begins. This triggers a full volume resync to slave in the case of a geo-rep session recreation with the same master-slave volume pair. Command synopsis: gluster volume geo-replication <MASTERVOL> <SLAVE>::<SLAVEVOL> delete \ [reset-sync-time] Update gluster cli man page to include new sub-command reset-sync-time. Change-Id: Ie4ce03b9425ed9bb81eda8681058c0fc6f990948 BUG: 1311926 Signed-off-by: Milind Changire <mchangir@redhat.com> Reviewed-on: http://review.gluster.org/14051 Reviewed-by: Kotresh HR <khiremat@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Aravinda VK <avishwan@redhat.com>
Diffstat (limited to 'geo-replication')
-rw-r--r--geo-replication/syncdaemon/gsyncd.py29
-rw-r--r--geo-replication/syncdaemon/master.py3
-rw-r--r--geo-replication/syncdaemon/monitor.py10
3 files changed, 39 insertions, 3 deletions
diff --git a/geo-replication/syncdaemon/gsyncd.py b/geo-replication/syncdaemon/gsyncd.py
index da5de0f40f..f41756a0b9 100644
--- a/geo-replication/syncdaemon/gsyncd.py
+++ b/geo-replication/syncdaemon/gsyncd.py
@@ -27,7 +27,7 @@ from ipaddr import IPAddress, IPNetwork
from gconf import gconf
from syncdutils import FreeObject, norm, grabpidfile, finalize
-from syncdutils import log_raise_exception, privileged
+from syncdutils import log_raise_exception, privileged, boolify
from syncdutils import GsyncdError, select, set_term_handler
from configinterface import GConffile, upgrade_config_file
import resource
@@ -37,6 +37,8 @@ from subprocess import PIPE
import subprocess
from changelogagent import agent, Changelog
from gsyncdstatus import set_monitor_status, GeorepStatus
+from libcxattr import Xattr
+import struct
ParseError = XET.ParseError if hasattr(XET, 'ParseError') else SyntaxError
@@ -253,9 +255,9 @@ def main_i():
action='callback', callback=store_abs)
op.add_option('-l', '--log-file', metavar='LOGF', type=str,
action='callback', callback=store_abs)
- op.add_option('--iprefix', metavar='LOGD', type=str,
+ op.add_option('--iprefix', metavar='LOGD', type=str,
action='callback', callback=store_abs)
- op.add_option('--changelog-log-file', metavar='LOGF', type=str,
+ op.add_option('--changelog-log-file', metavar='LOGF', type=str,
action='callback', callback=store_abs)
op.add_option('--log-file-mbr', metavar='LOGF', type=str,
action='callback', callback=store_abs)
@@ -355,6 +357,9 @@ def main_i():
action='callback', callback=store_local)
op.add_option('--delete', dest='delete', action='callback',
callback=store_local_curry(True))
+ op.add_option('--path-list', dest='path_list', action='callback',
+ type=str, callback=store_local)
+ op.add_option('--reset-sync-time', default=False, action='store_true')
op.add_option('--status-get', dest='status_get', action='callback',
callback=store_local_curry(True))
op.add_option('--debug', dest="go_daemon", action='callback',
@@ -572,6 +577,10 @@ def main_i():
delete = rconf.get('delete')
if delete:
logging.info('geo-replication delete')
+ # remove the stime xattr from all the brick paths so that
+ # a re-create of a session will start sync all over again
+ stime_xattr_name = getattr(gconf, 'master.stime_xattr_name', None)
+
# Delete pid file, status file, socket file
cleanup_paths = []
if getattr(gconf, 'pid_file', None):
@@ -604,6 +613,20 @@ def main_i():
# To delete temp files
for f in glob.glob(path + "*"):
_unlink(f)
+
+ reset_sync_time = boolify(gconf.reset_sync_time)
+ if reset_sync_time and stime_xattr_name:
+ path_list = rconf.get('path_list')
+ paths = []
+ for p in path_list.split('--path='):
+ stripped_path = p.strip()
+ if stripped_path != "":
+ # set stime to (0,0) to trigger full volume content resync
+ # to slave on session recreation
+ # look at master.py::Xcrawl hint: zero_zero
+ Xattr.lsetxattr(stripped_path, stime_xattr_name,
+ struct.pack("!II", 0, 0))
+
return
if restricted and gconf.allow_network:
diff --git a/geo-replication/syncdaemon/master.py b/geo-replication/syncdaemon/master.py
index be68a7fd7b..80c4d9d8b9 100644
--- a/geo-replication/syncdaemon/master.py
+++ b/geo-replication/syncdaemon/master.py
@@ -1377,6 +1377,9 @@ class GMasterXsyncMixin(GMasterChangelogMixin):
"correct xtime for %s (%d)" % (path, xtr))
xtr = self.minus_infinity
xtr = max(xtr, xtr_root)
+ zero_zero = (0, 0)
+ if xtr_root == zero_zero:
+ xtr = self.minus_infinity
if not self.need_sync(path, xtl, xtr):
if path == '.':
self.sync_done([(path, xtl)], True)
diff --git a/geo-replication/syncdaemon/monitor.py b/geo-replication/syncdaemon/monitor.py
index 050218b6d1..a26de0c9cf 100644
--- a/geo-replication/syncdaemon/monitor.py
+++ b/geo-replication/syncdaemon/monitor.py
@@ -165,6 +165,7 @@ class Volinfo(object):
else:
return 0
+
class Monitor(object):
"""class which spawns and manages gsyncd workers"""
@@ -428,6 +429,15 @@ def distribute(*resources):
suuid = svol.uuid
slave_host = slave.remote_addr.split('@')[-1]
slave_vol = si.volume
+
+ # save this xattr for the session delete command
+ old_stime_xattr_name = getattr(gconf, "master.stime_xattr_name", None)
+ new_stime_xattr_name = "trusted.glusterfs." + mvol.uuid + "." + \
+ svol.uuid + ".stime"
+ if not old_stime_xattr_name or \
+ old_stime_xattr_name != new_stime_xattr_name:
+ gconf.configinterface.set("master.stime_xattr_name",
+ new_stime_xattr_name)
else:
raise GsyncdError("unknown slave type " + slave.url)
logging.info('slave bricks: ' + repr(sbricks))