diff options
Diffstat (limited to 'geo-replication')
| -rw-r--r-- | geo-replication/syncdaemon/gsyncd.py | 3 | ||||
| -rw-r--r-- | geo-replication/syncdaemon/resource.py | 9 | ||||
| -rw-r--r-- | geo-replication/syncdaemon/syncdutils.py | 12 | 
3 files changed, 20 insertions, 4 deletions
diff --git a/geo-replication/syncdaemon/gsyncd.py b/geo-replication/syncdaemon/gsyncd.py index 1fd475dfba1..adc48f146a6 100644 --- a/geo-replication/syncdaemon/gsyncd.py +++ b/geo-replication/syncdaemon/gsyncd.py @@ -269,6 +269,7 @@ def main_i():                    type=str, action='callback', callback=store_abs)      op.add_option('--georep-session-working-dir', metavar='STATF',                    type=str, action='callback', callback=store_abs) +    op.add_option('--access-mount', default=False, action='store_true')      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') @@ -415,7 +416,7 @@ def main_i():                      o.get_opt_string() not in ('--version', '--help'))]      remote_tunables = ['listen', 'go_daemon', 'timeout',                         'session_owner', 'config_file', 'use_rsync_xattrs', -                       'local_id', 'local_node'] +                       'local_id', 'local_node', 'access_mount']      rq_remote_tunables = {'listen': True}      # precedence for sources of values: 1) commandline, 2) cfg file, 3) diff --git a/geo-replication/syncdaemon/resource.py b/geo-replication/syncdaemon/resource.py index 977496318da..306742e53fc 100644 --- a/geo-replication/syncdaemon/resource.py +++ b/geo-replication/syncdaemon/resource.py @@ -41,6 +41,7 @@ from syncdutils import get_changelog_log_level  from syncdutils import CHANGELOG_AGENT_CLIENT_VERSION  from gsyncdstatus import GeorepStatus  from syncdutils import get_master_and_slave_data_from_args +from syncdutils import mntpt_list  UrlRX = re.compile('\A(\w+)://([^ *?[]*)\Z')  HostRX = re.compile('[a-zA-Z\d](?:[a-zA-Z\d.-]*[a-zA-Z\d])?', re.I) @@ -1014,6 +1015,8 @@ class SlaveRemote(object):              extra_opts += ['--local-node', ln]          if boolify(gconf.use_rsync_xattrs):              extra_opts.append('--use-rsync-xattrs') +        if boolify(gconf.access_mount): +            extra_opts.append('--access-mount')          po = Popen(rargs + gconf.remote_gsyncd.split() + extra_opts +                     ['-N', '--listen', '--timeout', str(gconf.timeout),                      slave], @@ -1373,13 +1376,14 @@ class GLUSTER(AbstractUrl, SlaveLocal, SlaveRemote):                          assert(mntdata[-1] == '\0')                          mntpt = mntdata[:-1]                          assert(mntpt) -                        if mounted: +                        if mounted and not boolify(gconf.access_mount):                              po = self.umount_l(mntpt)                              po.terminate_geterr(fail_on_err=False)                              if po.returncode != 0:                                  po.errlog()                                  rv = po.returncode -                        self.cleanup_mntpt(mntpt) +                        if not boolify(gconf.access_mount): +                            self.cleanup_mntpt(mntpt)                  except:                      logging.exception('mount cleanup failure:')                      rv = 200 @@ -1399,6 +1403,7 @@ class GLUSTER(AbstractUrl, SlaveLocal, SlaveRemote):          def make_mount_argv(self):              self.mntpt = tempfile.mkdtemp(prefix='gsyncd-aux-mount-') +            mntpt_list.append(self.mntpt)              return [self.get_glusterprog()] + \                  ['--' + p for p in self.params] + [self.mntpt] diff --git a/geo-replication/syncdaemon/syncdutils.py b/geo-replication/syncdaemon/syncdutils.py index 292cd0aea19..4d981f9fe53 100644 --- a/geo-replication/syncdaemon/syncdutils.py +++ b/geo-replication/syncdaemon/syncdutils.py @@ -16,6 +16,7 @@ import fcntl  import shutil  import logging  import socket +import subprocess  from threading import Lock, Thread as baseThread  from errno import EACCES, EAGAIN, EPIPE, ENOTCONN, ECONNABORTED  from errno import EINTR, ENOENT, EPERM, ESTALE, errorcode @@ -189,12 +190,13 @@ def grabpidfile(fname=None, setpid=True):  final_lock = Lock() - +mntpt_list = []  def finalize(*a, **kw):      """all those messy final steps we go trough upon termination      Do away with pidfile, ssh control dir and logging.      """ +      final_lock.acquire()      if getattr(gconf, 'pid_file', None):          rm_pidf = gconf.pid_file_owned @@ -234,6 +236,13 @@ def finalize(*a, **kw):              if sys.exc_info()[0] == OSError:                  pass +    """ Unmount if not done """ +    for mnt in mntpt_list: +        p0 = subprocess.Popen (["umount", "-l", mnt], stderr=subprocess.PIPE) +        _, errdata = p0.communicate() +        if p0.returncode == 0: +            os.rmdir(mnt) +      if gconf.log_exit:          logging.info("exiting.")      sys.stdout.flush() @@ -241,6 +250,7 @@ def finalize(*a, **kw):      os._exit(kw.get('exval', 0)) +  def log_raise_exception(excont):      """top-level exception handler  | 
