]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
qa/cephfs: look for mountpoint in cmdline file
authorRishabh Dave <ridave@redhat.com>
Tue, 26 May 2020 11:10:29 +0000 (16:40 +0530)
committerRishabh Dave <ridave@redhat.com>
Mon, 1 Jun 2020 18:23:02 +0000 (23:53 +0530)
Look for self.mountpoint in the contents of /proc/<pid>/cmdline file
when finding asok file for the client so that vstart_runner.py won't end
up picking asok file for a client not created in current run.

This usually never happens so far because PID of newly created processes
is higher than that of previously created processes and list of asok
files returned by "glob.glob(asok_path)" in find_socket() is in
descending order of PIDs.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
qa/tasks/cephfs/fuse_mount.py

index cc25bf99c5406618d72615fa2a5a2f33521c52e0..1fc7fd3e493adb0e72815aea5e9aab18ec9e12f2 100644 (file)
@@ -415,16 +415,17 @@ class FuseMount(CephFSMount):
     def _prefix(self):
         return ""
 
-    def admin_socket(self, args):
+    def find_admin_socket(self):
         pyscript = """
 import glob
 import re
 import os
 import subprocess
 
-def find_socket(client_name):
+def _find_admin_socket(client_name):
         asok_path = "{asok_path}"
         files = glob.glob(asok_path)
+        mountpoint = "{mountpoint}"
 
         # Given a non-glob path, it better be there
         if "*" not in asok_path:
@@ -434,20 +435,24 @@ def find_socket(client_name):
         for f in files:
                 pid = re.match(".*\.(\d+)\.asok$", f).group(1)
                 if os.path.exists("/proc/{{0}}".format(pid)):
-                        return f
+                    with open("/proc/{{0}}/cmdline".format(pid), 'r') as proc_f:
+                        contents = proc_f.read()
+                        if mountpoint in contents:
+                            return f
         raise RuntimeError("Client socket {{0}} not found".format(client_name))
 
-print(find_socket("{client_name}"))
+print(_find_admin_socket("{client_name}"))
 """.format(
             asok_path=self._asok_path(),
-            client_name="client.{0}".format(self.client_id))
+            client_name="client.{0}".format(self.client_id),
+            mountpoint=self.mountpoint)
 
-        # Find the admin socket
-        asok_path = self.client_remote.sh(
-            ['sudo', 'python3', '-c', pyscript],
-            stdout=StringIO(),
-            timeout=(15*60)).strip()
+        asok_path = self.run_python(pyscript)
         log.info("Found client admin socket at {0}".format(asok_path))
+        return asok_path
+
+    def admin_socket(self, args):
+        asok_path = self.find_admin_socket()
 
         # Query client ID from admin socket, wait 2 seconds
         # and retry 10 times if it is not ready