]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
orchestra: add a method to check if given path is mounted 1786/head
authorRishabh Dave <ridave@redhat.com>
Fri, 19 Aug 2022 15:40:04 +0000 (21:10 +0530)
committerRishabh Dave <ridave@redhat.com>
Wed, 14 Sep 2022 12:40:47 +0000 (18:10 +0530)
Add a method mount() that checks if the given path is mounted or
unmounted without using "mount" of "findmnt" commands.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
teuthology/orchestra/remote.py

index df269c740b49aa422ebda890e7b52e52334b9c1c..963f82da795b1bd17c4f35d9c2026e6de389d710 100644 (file)
@@ -300,6 +300,21 @@ class RemoteShell(object):
         """
         self.write_file(path, data, sudo=True, **kwargs)
 
+    def is_mounted(self, path):
+        """
+        Check if the given path is mounted on the remote machine.
+
+        This method checks the contents of "/proc/self/mounts" instead of
+        using "mount" or "findmnt" command since these commands hang when a
+        CephFS client is blocked and its mount point on the remote machine
+        is left unhandled/unmounted.
+
+        :param path: path on remote host
+        """
+        # XXX: matching newline too is crucial so that "/mnt" does not match
+        # "/mnt/cephfs" if it's present in the output.
+        return f'{path}\n' in self.sh("cat /proc/self/mounts | awk '{print $2}'")
+
     @property
     def os(self):
         if not hasattr(self, '_os'):