admin_socket: loop until the socket command succeeds

Sometimes the thing we're talking to is slow to start, or to register the
command we are running.  Loop in that case, at least for a while.

Signed-off-by: Sage Weil <sage@inktank.com>
This commit is contained in:
Sage Weil 2013-07-19 15:10:43 -07:00
parent 37a662442d
commit 222b296019

View File

@ -68,18 +68,26 @@ def _socket_command(ctx, remote, socket_path, command, args):
"""
json_fp = StringIO()
testdir = teuthology.get_testdir(ctx)
remote.run(
args=[
'sudo',
'{tdir}/adjust-ulimits'.format(tdir=testdir),
'ceph-coverage',
'{tdir}/archive/coverage'.format(tdir=testdir),
'ceph',
'--admin-daemon', socket_path,
command,
] + args,
stdout=json_fp,
)
max_tries = 60
while True:
proc = remote.run(
args=[
'sudo',
'{tdir}/adjust-ulimits'.format(tdir=testdir),
'ceph-coverage',
'{tdir}/archive/coverage'.format(tdir=testdir),
'ceph',
'--admin-daemon', socket_path,
command,
] + args,
stdout=json_fp,
)
if proc.exitstatus == 0:
break
assert max_tries > 0
max_tries -= 1
log.info('ceph cli returned an error, command not registered yet? sleeping and retrying ...')
time.sleep(1)
out = json_fp.getvalue()
json_fp.close()
log.debug('admin socket command %s returned %s', command, out)