]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: move `json_loads_retry` func
authorMichael Fritch <mfritch@suse.com>
Tue, 18 May 2021 16:21:23 +0000 (10:21 -0600)
committerMichael Fritch <mfritch@suse.com>
Thu, 27 May 2021 13:34:27 +0000 (07:34 -0600)
move inner func `json_loads_retry` so it can be mocked during unit tests

Signed-off-by: Michael Fritch <mfritch@suse.com>
src/cephadm/cephadm

index ce73fe0d50a46fb45cb1f7598ee369a9ec1ba185..ae67122af75b78fda168f0642165d37dc3f6d835 100755 (executable)
@@ -1474,6 +1474,16 @@ def call_timeout(ctx, command, timeout):
 ##################################
 
 
+def json_loads_retry(cli_func):
+    for sleep_secs in [1, 4, 4]:
+        try:
+            return json.loads(cli_func())
+        except json.JSONDecodeError:
+            logger.debug('Invalid JSON. Retrying in %s seconds...' % sleep_secs)
+            time.sleep(sleep_secs)
+    return json.loads(cli_func())
+
+
 def is_available(ctx, what, func):
     # type: (CephadmContext, str, Callable[[], bool]) -> None
     """
@@ -4118,15 +4128,6 @@ def command_bootstrap(ctx):
                  '-i', '/var/lib/ceph/user.conf'],
                 {tmp.name: '/var/lib/ceph/user.conf:z'})
 
-    def json_loads_retry(cli_func):
-        for sleep_secs in [1, 4, 4]:
-            try:
-                return json.loads(cli_func())
-            except json.JSONDecodeError:
-                logger.debug('Invalid JSON. Retrying in %s seconds...' % sleep_secs)
-                time.sleep(sleep_secs)
-        return json.loads(cli_func())
-
     # wait for mgr to restart (after enabling a module)
     def wait_for_mgr_restart():
         # first get latest mgrmap epoch from the mon.  try newer 'mgr