From b5848ed21b9e718011a8f3f3870c4ed978ff17a5 Mon Sep 17 00:00:00 2001 From: Csaba Henk Date: Thu, 21 Apr 2011 08:56:09 +0000 Subject: syncdaemon: handle errors in glusterfs mount more carefully Signed-off-by: Csaba Henk Signed-off-by: Anand Avati BUG: 2826 (stale auxiliary mounts are left over) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2826 --- xlators/features/marker/utils/syncdaemon/resource.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/xlators/features/marker/utils/syncdaemon/resource.py b/xlators/features/marker/utils/syncdaemon/resource.py index 3987b7ae9..800d297ba 100644 --- a/xlators/features/marker/utils/syncdaemon/resource.py +++ b/xlators/features/marker/utils/syncdaemon/resource.py @@ -364,7 +364,12 @@ class GLUSTER(AbstractUrl, SlaveLocal, SlaveRemote): return True def connect(self): + def umount_l(d): + time.sleep(0.2) # XXX temporary workaround + argv = ['umount', '-l', d] + return os.spawnvp(os.P_WAIT, argv[0], argv) d = tempfile.mkdtemp(prefix='gsyncd-aux-mount-') + mounted = False try: argv = gconf.gluster_command.split() + \ (gconf.gluster_log_level and ['-L', gconf.gluster_log_level] or []) + \ @@ -372,14 +377,16 @@ class GLUSTER(AbstractUrl, SlaveLocal, SlaveRemote): '--volfile-id', self.volume, '--client-pid=-1', d] if os.spawnvp(os.P_WAIT, argv[0], argv): raise RuntimeError("command failed: " + " ".join(argv)) + mounted = True logging.debug('auxiliary glusterfs mount in place') os.chdir(d) - time.sleep(0.2) # XXX temporary workaround - argv = ['umount', '-l', d] - if os.spawnvp(os.P_WAIT, argv[0], argv): - raise RuntimeError("command failed: " + " ".join(argv)) + if umount_l(d) != 0: + raise RuntimeError("umounting %s failed" % d) + mounted = False finally: try: + if mounted: + umount_l(d) os.rmdir(d) except: logging.warn('stale mount possibly left behind on ' + d) -- cgit