if self.inst is None:
raise RuntimeError("cannot find client session")
- def is_mounted(self):
+ def check_mounted_state(self):
proc = self.client_remote.run(
args=[
'stat',
sleep for 5 seconds and check again.
"""
- while not self.is_mounted():
+ while not self.check_mounted_state():
# Even if it's not mounted, it should at least
# be running: catch simple failures where it has terminated.
assert not self.fuse_daemon.poll()
time.sleep(5)
+ self.mounted = True
+
# Now that we're mounted, set permissions so that the rest of the test will have
# unrestricted access to the filesystem mount.
try:
def umount(self):
try:
log.info('Running fusermount -u on {name}...'.format(name=self.client_remote.name))
+ stderr = BytesIO()
self.client_remote.run(
args = [
'sudo',
self.mountpoint,
],
cwd=self.test_dir,
+ stderr=stderr,
timeout=(30*60),
)
except run.CommandFailedError:
- log.info('Failed to unmount ceph-fuse on {name}, aborting...'.format(name=self.client_remote.name))
-
- self.client_remote.run(args=[
- 'sudo',
- run.Raw('PATH=/usr/sbin:$PATH'),
- 'lsof',
- run.Raw(';'),
- 'ps',
- 'auxf',
- ], timeout=(60*15))
-
- # abort the fuse mount, killing all hung processes
- if self._fuse_conn:
- self.run_python(dedent("""
- import os
- path = "/sys/fs/fuse/connections/{0}/abort"
- if os.path.exists(path):
- open(path, "w").write("1")
- """).format(self._fuse_conn))
- self._fuse_conn = None
+ if "mountpoint not found" in stderr.getvalue():
+ # This happens if the mount directory doesn't exist
+ log.info('mount point does not exist: %s', self.mountpoint)
+ elif "not mounted" in stderr.getvalue():
+ # This happens if the mount directory already unmouted
+ log.info('mount point not mounted: %s', self.mountpoint)
+ else:
+ log.info('Failed to unmount ceph-fuse on {name}, aborting...'.format(name=self.client_remote.name))
- stderr = BytesIO()
- try:
+ self.client_remote.run(args=[
+ 'sudo',
+ run.Raw('PATH=/usr/sbin:$PATH'),
+ 'lsof',
+ run.Raw(';'),
+ 'ps',
+ 'auxf',
+ ], timeout=(60*15))
+
+ # abort the fuse mount, killing all hung processes
+ if self._fuse_conn:
+ self.run_python(dedent("""
+ import os
+ path = "/sys/fs/fuse/connections/{0}/abort"
+ if os.path.exists(path):
+ open(path, "w").write("1")
+ """).format(self._fuse_conn))
+ self._fuse_conn = None
+
+ stderr = BytesIO()
# make sure its unmounted
- self.client_remote.run(
- args=[
- 'sudo',
- 'umount',
- '-l',
- '-f',
- self.mountpoint,
- ],
- stderr=stderr,
- timeout=(60*15)
- )
- except CommandFailedError:
- if self.is_mounted():
- raise
+ try:
+ self.client_remote.run(
+ args=[
+ 'sudo',
+ 'umount',
+ '-l',
+ '-f',
+ self.mountpoint,
+ ],
+ stderr=stderr,
+ timeout=(60*15)
+ )
+ except CommandFailedError:
+ if self.is_mounted():
+ raise
- assert not self.is_mounted()
+ self.mounted = False
self._fuse_conn = None
self.id = None
self.inst = None
def __init__(self, ctx, test_dir, client_id, client_remote, brxnet):
super(KernelMount, self).__init__(ctx, test_dir, client_id, client_remote, brxnet)
- self.mounted = False
-
def mount(self, mount_path=None, mount_fs_name=None, mountpoint=None, mount_options=[]):
if mountpoint is not None:
self.mountpoint = mountpoint
self.cleanup_netns()
self.cleanup()
- def is_mounted(self):
- return self.mounted
-
def wait_until_mounted(self):
"""
Unlike the fuse client, the kernel client is up and running as soon