-
from StringIO import StringIO
import json
import time
from teuthology.orchestra import run
from teuthology.orchestra.run import CommandFailedError
from .mount import CephFSMount
-from tasks.cephfs.filesystem import Filesystem
log = logging.getLogger(__name__)
self.inst = None
self.addr = None
- def mount(self, mount_path=None, mount_fs_name=None):
+ def mount(self, mount_path=None, mount_fs_name=None, mountpoint=None, mount_options=[]):
+ if mountpoint is not None:
+ self.mountpoint = mountpoint
self.setupfs(name=mount_fs_name)
try:
- return self._mount(mount_path, mount_fs_name)
+ return self._mount(mount_path, mount_fs_name, mount_options)
except RuntimeError:
# Catch exceptions by the mount() logic (i.e. not remote command
# failures) and ensure the mount is not left half-up.
self.umount_wait(force=True)
raise
- def _mount(self, mount_path, mount_fs_name):
+ def _mount(self, mount_path, mount_fs_name, mount_options):
log.info("Client client.%s config is %s" % (self.client_id, self.client_config))
daemon_signal = 'kill'
log.info('Mounting ceph-fuse client.{id} at {remote} {mnt}...'.format(
id=self.client_id, remote=self.client_remote, mnt=self.mountpoint))
- self.client_remote.run(
- args=[
- 'mkdir',
- '--',
- self.mountpoint,
- ],
- timeout=(15*60)
- )
+ self.client_remote.run(args=['mkdir', '-p', self.mountpoint],
+ timeout=(15*60), cwd=self.test_dir)
run_cmd = [
'sudo',
fuse_cmd += ["--client_mountpoint={0}".format(mount_path)]
if mount_fs_name is not None:
- fuse_cmd += ["--client_mds_namespace={0}".format(mount_fs_name)]
+ fuse_cmd += ["--client_fs={0}".format(mount_fs_name)]
+
+ fuse_cmd += mount_options
fuse_cmd += [
'--name', 'client.{id}'.format(id=self.client_id),
self.mountpoint,
]
+ cwd = self.test_dir
if self.client_config.get('valgrind') is not None:
run_cmd = misc.get_valgrind_args(
self.test_dir,
run_cmd,
self.client_config.get('valgrind'),
)
+ cwd = None # misc.get_valgrind_args chdir for us
run_cmd.extend(fuse_cmd)
proc = self.client_remote.run(
args=run_cmd,
+ cwd=cwd,
logger=log.getChild('ceph-fuse.{id}'.format(id=self.client_id)),
stdin=run.PIPE,
wait=False,
try:
self.inst = status['inst_str']
self.addr = status['addr_str']
- except KeyError as e:
+ except KeyError:
sessions = self.fs.rank_asok(['session', 'ls'])
for s in sessions:
if s['id'] == self.id:
'--',
self.mountpoint,
],
+ cwd=self.test_dir,
stdout=StringIO(),
stderr=StringIO(),
wait=False,
# unrestricted access to the filesystem mount.
try:
stderr = StringIO()
- self.client_remote.run(args=['sudo', 'chmod', '1777', self.mountpoint], timeout=(15*60), stderr=stderr)
+ self.client_remote.run(args=['sudo', 'chmod', '1777', self.mountpoint], timeout=(15*60), cwd=self.test_dir, stderr=stderr)
except run.CommandFailedError:
stderr = stderr.getvalue()
if "Read-only file system".lower() in stderr.lower():
raise
def _mountpoint_exists(self):
- return self.client_remote.run(args=["ls", "-d", self.mountpoint], check_status=False, timeout=(15*60)).exitstatus == 0
+ return self.client_remote.run(args=["ls", "-d", self.mountpoint], check_status=False, cwd=self.test_dir, timeout=(15*60)).exitstatus == 0
def umount(self):
try:
'-u',
self.mountpoint,
],
+ cwd=self.test_dir,
timeout=(30*60),
)
except run.CommandFailedError:
"""
:param force: Complete cleanly even if the MDS is offline
"""
+ if not (self.is_mounted() and self.fuse_daemon):
+ log.debug('ceph-fuse client.{id} is not mounted at {remote} {mnt}'.format(id=self.client_id,
+ remote=self.client_remote,
+ mnt=self.mountpoint))
+ return
+
if force:
assert not require_clean # mutually exclusive
self.umount()
try:
- if self.fuse_daemon:
- # Permit a timeout, so that we do not block forever
- run.wait([self.fuse_daemon], timeout)
+ # Permit a timeout, so that we do not block forever
+ run.wait([self.fuse_daemon], timeout)
except MaxWhileTries:
log.error("process failed to terminate after unmount. This probably"
" indicates a bug within ceph-fuse.")
'--',
self.mountpoint,
],
+ cwd=self.test_dir,
stderr=stderr,
- timeout=(60*5)
+ timeout=(60*5),
+ check_status=False,
)
except CommandFailedError:
if "No such file or directory" in stderr.getvalue():
'-rf',
self.mountpoint,
],
+ cwd=self.test_dir,
timeout=(60*5)
)
return f
raise RuntimeError("Client socket {{0}} not found".format(client_name))
-print find_socket("{client_name}")
+print(find_socket("{client_name}"))
""".format(
asok_path=self._asok_path(),
client_name="client.{0}".format(self.client_id))
# Find the admin socket
p = self.client_remote.run(args=[
- 'sudo', 'python2', '-c', pyscript
+ 'sudo', 'python3', '-c', pyscript
], stdout=StringIO(), timeout=(15*60))
asok_path = p.stdout.getvalue().strip()
log.info("Found client admin socket at {0}".format(asok_path))