]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: fix race in Mount.open_background
authorJohn Spray <john.spray@redhat.com>
Thu, 26 Jan 2017 16:48:58 +0000 (16:48 +0000)
committerNathan Cutler <ncutler@suse.com>
Fri, 14 Apr 2017 21:49:21 +0000 (23:49 +0200)
Previously a later remote call could end up executing
before the remote python program in open_background
had actually got as far as opening the file.

Fixes: http://tracker.ceph.com/issues/18661
Signed-off-by: John Spray <john.spray@redhat.com>
(cherry picked from commit c6d91dd91252e703d08b8ac62ac6a47ee82c0bed)

qa/tasks/cephfs/mount.py

index f5d9d73c2fc696b8d318bb82e1cb88485fc19409..24a89d44a7dc53e9521a0ef0b9d17a809a38c546 100644 (file)
@@ -157,7 +157,10 @@ class CephFSMount(object):
     def open_background(self, basename="background_file"):
         """
         Open a file for writing, then block such that the client
-        will hold a capability
+        will hold a capability.
+
+        Don't return until the remote process has got as far as opening
+        the file, then return the RemoteProcess instance.
         """
         assert(self.is_mounted())
 
@@ -176,6 +179,12 @@ class CephFSMount(object):
 
         rproc = self._run_python(pyscript)
         self.background_procs.append(rproc)
+
+        # This wait would not be sufficient if the file had already
+        # existed, but it's simple and in practice users of open_background
+        # are not using it on existing files.
+        self.wait_for_visible(basename)
+
         return rproc
 
     def wait_for_visible(self, basename="background_file", timeout=30):