From 6633c1ecca9afb4a0b01edc1d0ec6a25b47703bf Mon Sep 17 00:00:00 2001 From: Vasu Kulkarni Date: Tue, 11 Apr 2017 13:34:13 -0700 Subject: [PATCH] Add option to use sudo to check ceph health when required Signed-off-by: Vasu Kulkarni --- teuthology/misc.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/teuthology/misc.py b/teuthology/misc.py index 909988826c..9bbf97eee8 100644 --- a/teuthology/misc.py +++ b/teuthology/misc.py @@ -885,22 +885,24 @@ def get_scratch_devices(remote): return retval -def wait_until_healthy(ctx, remote, ceph_cluster='ceph'): +def wait_until_healthy(ctx, remote, ceph_cluster='ceph', use_sudo=False): """ Wait until a Ceph cluster is healthy. Give up after 15min. """ testdir = get_testdir(ctx) + # when cluster is setup using ceph-deploy or ansible + # access to admin key is readonly for ceph user + cmd = ['ceph', '--cluster', ceph_cluster, 'health'] + if use_sudo: + cmd.insert(0, 'sudo') + args = ['adjust-ulimits', + 'ceph-coverage', + '{tdir}/archive/coverage'.format(tdir=testdir)] + args.extend(cmd) with safe_while(tries=(900 / 6), action="wait_until_healthy") as proceed: while proceed(): r = remote.run( - args=[ - 'adjust-ulimits', - 'ceph-coverage', - '{tdir}/archive/coverage'.format(tdir=testdir), - 'ceph', - '--cluster', ceph_cluster, - 'health', - ], + args=args, stdout=StringIO(), logger=log.getChild('health'), ) -- 2.39.5