]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/cephfs: run() cleanup whether FS was mounted or not 34951/head
authorRishabh Dave <ridave@redhat.com>
Thu, 7 May 2020 12:33:41 +0000 (18:03 +0530)
committerRishabh Dave <ridave@redhat.com>
Thu, 14 May 2020 04:36:21 +0000 (10:06 +0530)
In case the mount command in mount() fails, it would still have created
the mountpoint and network namespace for the FS's mount. Therefore, run
cleanup() and cleanup_netns() in umount() and umount_wait() even when
self.mounted is set to False.

Also, move the call to cleanup_netns() in cleanup().

Fixes: https://tracker.ceph.com/issues/45430
Signed-off-by: Rishabh Dave <ridave@redhat.com>
qa/tasks/cephfs/fuse_mount.py
qa/tasks/cephfs/kernel_mount.py
qa/tasks/cephfs/mount.py

index f46689b5b06f4fda8a46d74e4a1a5a857aade70f..50975981d9dff0e0ad112e7d52bd2b8191f88212 100644 (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()
index 9eb41622407e92d167afc69b108a3a62d8232740..3362885d621c9b8b3af79ee23c3eaae5ae176f63 100644 (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):
index 91146695af08a7f8ced3880f8bc3d2e6549d2fb1..75e136e09272a208a257b2f0d58fa28d1faac2cf 100644 (file)
@@ -449,7 +449,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):
         """
@@ -476,6 +475,8 @@ class CephFSMount(object):
             else:
                 raise
 
+        self.cleanup_netns()
+
     def wait_until_mounted(self):
         raise NotImplementedError()