summaryrefslogtreecommitdiffstats
path: root/geo-replication
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2017-03-17 13:03:57 -0400
committerVijay Bellur <vbellur@redhat.com>2017-03-19 23:33:36 -0400
commite2a652ca6ba56235e6d64bf7df110afdc5f6ca27 (patch)
tree543703ded623cca89254a9b2ecc5ba03785e8f52 /geo-replication
parent78222bff29f27fc3b4f500ff2f7bd323c418d09e (diff)
geo-rep: Optionally allow access to mounts
In order to improve debuggability, it is important to have access to geo-rep master and slave mounts. With the default behaviour, geo-rep lazy unmounts the mounts after changing the current working directory into the mount point. It also cleans up the mount points. So only geo-rep worker has the access and it becomes impossible to take the client profile info and do any other client statck analysis. Hence the following new config is being introduced to allow access to mounts. gluster vol geo-rep <mastervol> <slavehost>::<slavevol> \ config access_mount true The default value of 'access_mount' is false. Change-Id: I53dce4ea86a6ffc979c82f9330e8954327180ca3 BUG: 1433506 Signed-off-by: Kotresh HR <khiremat@redhat.com> Reviewed-on: https://review.gluster.org/16912 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: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'geo-replication')
-rw-r--r--geo-replication/syncdaemon/gsyncd.py3
-rw-r--r--geo-replication/syncdaemon/resource.py9
-rw-r--r--geo-replication/syncdaemon/syncdutils.py12
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