From: Patrick Donnelly Date: Tue, 3 Nov 2020 18:01:55 +0000 (-0800) Subject: qa: avoid using ceph.dir.entries for empty check X-Git-Tag: v16.1.0~689^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=093962553083c1e55d36def57f4fe0804f9b65da;p=ceph.git qa: avoid using ceph.dir.entries for empty check 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 --- diff --git a/qa/tasks/cephfs/mount.py b/qa/tasks/cephfs/mount.py index 1e739201811d2..0cc86f906a0dc 100644 --- a/qa/tasks/cephfs/mount.py +++ b/qa/tasks/cephfs/mount.py @@ -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