]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cli: retry when the mon is not configured
authorLoic Dachary <ldachary@redhat.com>
Thu, 15 Sep 2016 08:42:24 +0000 (10:42 +0200)
committerLoic Dachary <ldachary@redhat.com>
Fri, 16 Sep 2016 07:04:36 +0000 (09:04 +0200)
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 <loic@dachary.org>
src/pybind/ceph_argparse.py

index 49e69296819c29d1b69beba075b17d61a645b927..580566a42d8e82755cd94733ea9dca143f660314 100644 (file)
@@ -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):