From: Loic Dachary Date: Thu, 15 Sep 2016 08:42:24 +0000 (+0200) Subject: cli: retry when the mon is not configured X-Git-Tag: v11.0.1~124^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d5a3c8d6844ba632767baf3c2c790fa4d947a95e;p=ceph.git cli: retry when the mon is not configured The mon may return on error if a command is sent to it while it is still in configuring state. Fixes: http://tracker.ceph.com/issues/16477 Signed-off-by: Loic Dachary --- diff --git a/src/pybind/ceph_argparse.py b/src/pybind/ceph_argparse.py index 49e69296819c..580566a42d8e 100644 --- a/src/pybind/ceph_argparse.py +++ b/src/pybind/ceph_argparse.py @@ -1191,6 +1191,17 @@ def run_in_thread(target, *args, **kwargs): return t.retval +def send_command_retry(*args, **kwargs): + while True: + try: + return send_command(*args, **kwargs) + except Exception as e: + if ('get_command_descriptions' in str(e) and + 'object in state configuring' in str(e)): + continue + else: + raise + def send_command(cluster, target=('mon', ''), cmd=None, inbuf=b'', timeout=0, verbose=False): """ @@ -1304,8 +1315,9 @@ def json_command(cluster, target=('mon', ''), prefix=None, argdict=None, # use the target we were originally given pass - ret, outbuf, outs = send_command(cluster, target, [json.dumps(cmddict)], - inbuf, timeout, verbose) + ret, outbuf, outs = send_command_retry(cluster, + target, [json.dumps(cmddict)], + inbuf, timeout, verbose) except Exception as e: if not isinstance(e, ArgumentError):