From 284cd5065f871fc7aeb134d0f9dd48ba9d1f12bf Mon Sep 17 00:00:00 2001 From: John Spray Date: Thu, 26 Jan 2017 16:48:58 +0000 Subject: [PATCH] qa: fix race in Mount.open_background 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 (cherry picked from commit c6d91dd91252e703d08b8ac62ac6a47ee82c0bed) --- qa/tasks/cephfs/mount.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/qa/tasks/cephfs/mount.py b/qa/tasks/cephfs/mount.py index f5d9d73c2fc69..24a89d44a7dc5 100644 --- a/qa/tasks/cephfs/mount.py +++ b/qa/tasks/cephfs/mount.py @@ -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): -- 2.39.5