From: Sage Weil Date: Fri, 8 Oct 2021 18:43:56 +0000 (-0500) Subject: qa/tasks/nvme_loop: loop until 'nvme list' shows new devs X-Git-Tag: v17.1.0~717^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F43455%2Fhead;p=ceph.git qa/tasks/nvme_loop: loop until 'nvme list' shows new devs Sometimes this doesn't happen immediately. Signed-off-by: Sage Weil --- diff --git a/qa/tasks/nvme_loop.py b/qa/tasks/nvme_loop.py index 7cb483d1fcf8..c4a027633343 100644 --- a/qa/tasks/nvme_loop.py +++ b/qa/tasks/nvme_loop.py @@ -60,13 +60,20 @@ def task(ctx, config): # identify nvme_loops devices old_scratch_by_remote[remote] = remote.read_file('/scratch_devs') - p = remote.run(args=['sudo', 'nvme', 'list'], stdout=StringIO()) - new_devs = [] - for line in p.stdout.getvalue().splitlines(): - dev, _, vendor = line.split()[0:3] - if dev.startswith('/dev/') and vendor == 'Linux': - new_devs.append(dev) - log.info(f'new_devs {new_devs}') + + with contextutil.safe_while(sleep=1, tries=15) as proceed: + while proceed(): + p = remote.run(args=['sudo', 'nvme', 'list'], stdout=StringIO()) + new_devs = [] + for line in p.stdout.getvalue().splitlines(): + dev, _, vendor = line.split()[0:3] + if dev.startswith('/dev/') and vendor == 'Linux': + new_devs.append(dev) + log.info(f'new_devs {new_devs}') + assert len(new_devs) <= len(devs) + if len(new_devs) == len(devs): + break + remote.write_file( path='/scratch_devs', data='\n'.join(new_devs) + '\n',