From 77498fdbbca8554880eae4b8f559b9d6876e35b7 Mon Sep 17 00:00:00 2001 From: Kotresh H R Date: Sun, 25 May 2014 23:41:48 +0530 Subject: feature/geo-rep: Fix to retain pause state of gsyncd on restart. A new gsyncd options '--pause-on-start' is introduced. When node reboots, if the status is paused, gsyncd is started with this option. After gsyncd spawns worker and agent, worker will send SIGSTOP to negative pid of monitor to enter pause mode. Change-Id: I5aad82c9a9fc8c243f384940b77d25e26e520d6d BUG: 1101410 Signed-off-by: Kotresh H R Reviewed-on: http://review.gluster.org/7885 Reviewed-by: Aravinda VK Reviewed-by: Venky Shankar Tested-by: Venky Shankar --- geo-replication/syncdaemon/gsyncd.py | 1 + geo-replication/syncdaemon/monitor.py | 9 +++++++-- geo-replication/syncdaemon/resource.py | 8 ++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) (limited to 'geo-replication/syncdaemon') diff --git a/geo-replication/syncdaemon/gsyncd.py b/geo-replication/syncdaemon/gsyncd.py index 7d463ad23f3..7ddd51267a6 100644 --- a/geo-replication/syncdaemon/gsyncd.py +++ b/geo-replication/syncdaemon/gsyncd.py @@ -227,6 +227,7 @@ def main_i(): op.add_option('--ignore-deletes', default=False, action='store_true') op.add_option('--isolated-slave', default=False, action='store_true') op.add_option('--use-rsync-xattrs', default=False, action='store_true') + op.add_option('--pause-on-start', default=False, action='store_true') op.add_option('-L', '--log-level', metavar='LVL') op.add_option('-r', '--remote-gsyncd', metavar='CMD', default=os.path.abspath(sys.argv[0])) diff --git a/geo-replication/syncdaemon/monitor.py b/geo-replication/syncdaemon/monitor.py index f485fe18605..f3700c1a390 100644 --- a/geo-replication/syncdaemon/monitor.py +++ b/geo-replication/syncdaemon/monitor.py @@ -73,10 +73,11 @@ class Monitor(object): """class which spawns and manages gsyncd workers""" ST_INIT = 'Initializing...' + ST_INIT_PAUSE = 'Initializing...(Paused)' ST_STABLE = 'Stable' ST_FAULTY = 'faulty' ST_INCON = 'inconsistent' - _ST_ORD = [ST_STABLE, ST_INIT, ST_FAULTY, ST_INCON] + _ST_ORD = [ST_STABLE, ST_INIT, ST_INIT_PAUSE, ST_FAULTY, ST_INCON] def __init__(self): self.lock = Lock() @@ -128,7 +129,11 @@ class Monitor(object): due to the keep-alive thread) """ - self.set_state(self.ST_INIT, w) + if gconf.pause_on_start: + self.set_state(self.ST_INIT_PAUSE, w) + else: + self.set_state(self.ST_INIT, w) + ret = 0 def nwait(p, o=0): diff --git a/geo-replication/syncdaemon/resource.py b/geo-replication/syncdaemon/resource.py index dadfc965336..8192a54b0d4 100644 --- a/geo-replication/syncdaemon/resource.py +++ b/geo-replication/syncdaemon/resource.py @@ -13,6 +13,7 @@ import os import sys import stat import time +import signal import fcntl import errno import types @@ -1290,6 +1291,13 @@ class GLUSTER(AbstractUrl, SlaveLocal, SlaveRemote): logging.debug("Changelog register failed: %s - %s" % (e.errno, e.strerror)) + # Check if gsyncd restarted in pause state. If + # yes, send SIGSTOP to negative of monitor pid + # to go back to pause state. + if gconf.pause_on_start: + os.kill(-os.getppid(), signal.SIGSTOP) + gconf.pause_on_start = False + # oneshot: Try to use changelog history api, if not # available switch to FS crawl # Note: if config.change_detector is xsync then -- cgit