diff options
author | Kotresh H R <khiremat@redhat.com> | 2014-06-18 13:30:26 +0530 |
---|---|---|
committer | Venky Shankar <vshankar@redhat.com> | 2014-06-20 01:17:22 -0700 |
commit | 124ba991069099258e4e69ccf3eefae1c88ebb8c (patch) | |
tree | 7a4ff3ec03cf8aa6c5ee25288237184a53809aa3 /geo-replication/syncdaemon | |
parent | 3fe1a14a82f3894e6b9e9d3004a185c48ea4bf6b (diff) |
feature/geo-rep: Fix to retain pause state of gsyncd on restart
On soft reboot, geo-rep monitor is writing 'faulty' into status
file. It should not do it if previous state is paused as
glusterd depend on the state file on node restart.
Change-Id: Idd45abf13350b087371935f1b4f6e1a346433d27
BUG: 1101410
Signed-off-by: Kotresh H R <khiremat@redhat.com>
Reviewed-on: http://review.gluster.org/8097
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Venky Shankar <vshankar@redhat.com>
Tested-by: Venky Shankar <vshankar@redhat.com>
Diffstat (limited to 'geo-replication/syncdaemon')
-rw-r--r-- | geo-replication/syncdaemon/monitor.py | 25 | ||||
-rw-r--r-- | geo-replication/syncdaemon/resource.py | 7 |
2 files changed, 18 insertions, 14 deletions
diff --git a/geo-replication/syncdaemon/monitor.py b/geo-replication/syncdaemon/monitor.py index 0bde216d761..5f4745501ec 100644 --- a/geo-replication/syncdaemon/monitor.py +++ b/geo-replication/syncdaemon/monitor.py @@ -73,11 +73,10 @@ 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_INIT_PAUSE, ST_FAULTY, ST_INCON] + _ST_ORD = [ST_STABLE, ST_INIT, ST_FAULTY, ST_INCON] def __init__(self): self.lock = Lock() @@ -97,8 +96,17 @@ class Monitor(object): if state != old_state: self.set_state(state) else: - logging.info('new state: %s' % state) if getattr(gconf, 'state_file', None): + # If previous state is paused, suffix the + # new state with '(Paused)' + try: + with open(gconf.state_file, "r") as f: + content = f.read() + if "paused" in content.lower(): + state = state + '(Paused)' + except IOError: + pass + logging.info('new state: %s' % state) update_file(gconf.state_file, lambda f: f.write(state + '\n')) @staticmethod @@ -129,10 +137,7 @@ class Monitor(object): due to the keep-alive thread) """ - if gconf.pause_on_start: - self.set_state(self.ST_INIT_PAUSE, w) - else: - self.set_state(self.ST_INIT, w) + self.set_state(self.ST_INIT, w) ret = 0 @@ -310,5 +315,11 @@ def distribute(*resources): def monitor(*resources): + # 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.getpid(), signal.SIGSTOP) + """oh yeah, actually Monitor is used as singleton, too""" return Monitor().multiplex(*distribute(*resources)) diff --git a/geo-replication/syncdaemon/resource.py b/geo-replication/syncdaemon/resource.py index eb6c87b102b..b537ff65003 100644 --- a/geo-replication/syncdaemon/resource.py +++ b/geo-replication/syncdaemon/resource.py @@ -1294,13 +1294,6 @@ 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 |