]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: avoid using ceph.dir.entries for empty check 37899/head
authorPatrick Donnelly <pdonnell@redhat.com>
Tue, 3 Nov 2020 18:01:55 +0000 (10:01 -0800)
committerPatrick Donnelly <pdonnell@redhat.com>
Tue, 3 Nov 2020 23:43:04 +0000 (15:43 -0800)
This avoids a bug [1] in the kernel client.

[1] https://tracker.ceph.com/issues/48104

Fixes: https://tracker.ceph.com/issues/23718
Signed-off-by: Patrick Donnelly <pdonnell@redhat.com>
qa/tasks/cephfs/mount.py

index 1e739201811d29418ef070f1af4bfbf7085d7179..0cc86f906a0dc5ca07cf2b2468446fd3f9fd14b3 100644 (file)
@@ -10,6 +10,7 @@ from contextlib import contextmanager
 from textwrap import dedent
 from IPy import IP
 
+from teuthology.contextutil import safe_while
 from teuthology.misc import get_file, sudo_write_file
 from teuthology.orchestra import run
 from teuthology.orchestra.run import CommandFailedError, ConnectionLostError, Raw
@@ -804,20 +805,13 @@ class CephFSMount(object):
         return rproc
 
     def wait_for_dir_empty(self, dirname, timeout=30):
-        i = 0
         dirpath = os.path.join(self.hostfs_mntpt, dirname)
-        while i < timeout:
-            nr_entries = int(self.getfattr(dirpath, "ceph.dir.entries"))
-            if nr_entries == 0:
-                log.debug("Directory {0} seen empty from {1} after {2}s ".format(
-                    dirname, self.client_id, i))
-                return
-            else:
-                time.sleep(1)
-                i += 1
-
-        raise RuntimeError("Timed out after {0}s waiting for {1} to become empty from {2}".format(
-            i, dirname, self.client_id))
+        with safe_while(sleep=5, tries=(timeout//5)) as proceed:
+            while proceed():
+                p = self.run_shell_payload(f"stat -c %h {dirpath}")
+                nr_links = int(p.stdout.getvalue().strip())
+                if nr_links == 2:
+                    return
 
     def wait_for_visible(self, basename="background_file", timeout=30):
         i = 0