Merge PR #34951 into master

* refs/pull/34951/head:
	qa/cephfs: run() cleanup whether FS was mounted or not

Reviewed-by: Patrick Donnelly <pdonnell@redhat.com>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
This commit is contained in:
Patrick Donnelly 2020-05-18 14:57:20 -07:00
commit 5ea3a9a1f7
No known key found for this signature in database
GPG Key ID: 3A2A7E25BEA8AADB
3 changed files with 17 additions and 8 deletions

View File

@ -258,8 +258,14 @@ class FuseMount(CephFSMount):
def _mountpoint_exists(self):
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):
def umount(self, cleanup=True):
"""
umount() must not run cleanup() when it's called by umount_wait()
since "run.wait([self.fuse_daemon], timeout)" would hang otherwise.
"""
if not self.is_mounted():
if cleanup:
self.cleanup()
return
try:
@ -328,6 +334,8 @@ class FuseMount(CephFSMount):
self.id = None
self.inst = None
self.addr = None
if cleanup:
self.cleanup()
def umount_wait(self, force=False, require_clean=False, timeout=900):
"""
@ -337,6 +345,7 @@ class FuseMount(CephFSMount):
log.debug('ceph-fuse client.{id} is not mounted at {remote} {mnt}'.format(id=self.client_id,
remote=self.client_remote,
mnt=self.mountpoint))
self.cleanup()
return
if force:
@ -351,7 +360,9 @@ class FuseMount(CephFSMount):
# mount -o remount (especially if the remount is stuck because MDSs
# are unavailable)
self.umount()
# cleanup is set to to fail since clieanup must happen after umount is
# complete; otherwise following call to run.wait hangs.
self.umount(cleanup=False)
try:
# Permit a timeout, so that we do not block forever
@ -365,7 +376,6 @@ class FuseMount(CephFSMount):
if require_clean:
raise
self.cleanup_netns()
self.mounted = False
self.cleanup()
@ -384,7 +394,6 @@ class FuseMount(CephFSMount):
except CommandFailedError:
pass
self.cleanup_netns()
self.mounted = False
# Indiscriminate, unlike the touchier cleanup()

View File

@ -71,6 +71,7 @@ class KernelMount(CephFSMount):
def umount(self, force=False):
if not self.is_mounted():
self.cleanup()
return
log.debug('Unmounting client client.{id}...'.format(id=self.client_id))
@ -92,7 +93,6 @@ class KernelMount(CephFSMount):
raise e
self.mounted = False
self.cleanup_netns()
self.cleanup()
def umount_wait(self, force=False, require_clean=False, timeout=900):
@ -100,6 +100,7 @@ class KernelMount(CephFSMount):
Unlike the fuse client, the kernel client's umount is immediate
"""
if not self.is_mounted():
self.cleanup()
return
try:
@ -109,7 +110,6 @@ class KernelMount(CephFSMount):
raise
# force delete the netns and umount
self.cleanup_netns()
self.client_remote.run(
args=['sudo',
'umount',
@ -120,7 +120,6 @@ class KernelMount(CephFSMount):
timeout=(15*60))
self.mounted = False
self.cleanup_netns()
self.cleanup()
def wait_until_mounted(self):

View File

@ -369,7 +369,6 @@ class CephFSMount(object):
"""
log.info('Cleaning up killed connection on {0}'.format(self.client_remote.name))
self.umount_wait(force=True)
self.cleanup()
def cleanup(self):
"""
@ -396,6 +395,8 @@ class CephFSMount(object):
else:
raise
self.cleanup_netns()
def wait_until_mounted(self):
raise NotImplementedError()