]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm/bootstrap: spin-off waiting for mon
authorJoao Eduardo Luis <joao@suse.com>
Wed, 30 Dec 2020 19:29:19 +0000 (19:29 +0000)
committerJoao Eduardo Luis <joao@suse.com>
Wed, 20 Jan 2021 14:20:45 +0000 (13:20 -0100)
Signed-off-by: Joao Eduardo Luis <joao@suse.com>
src/cephadm/cephadm

index 0b7ab263c78ee74e2914ae7e26222c3f71745dac..31c341ec16609749ca402286d4037e577e2e195b 100755 (executable)
@@ -3261,6 +3261,37 @@ def create_mon(
     return (mon_dir, log_dir)
 
 
+def wait_for_mon(
+    ctx: CephadmContext,
+    mon_id: str, mon_dir: str,
+    admin_keyring_path: str, config_path: str
+):
+    logger.info('Waiting for mon to start...')
+    c = CephContainer(
+        ctx,
+        image=ctx.args.image,
+        entrypoint='/usr/bin/ceph',
+        args=[
+            'status'],
+        volume_mounts={
+            mon_dir: '/var/lib/ceph/mon/ceph-%s:z' % (mon_id),
+            admin_keyring_path: '/etc/ceph/ceph.client.admin.keyring:z',
+            config_path: '/etc/ceph/ceph.conf:z',
+        },
+    )
+
+    # wait for the service to become available
+    def is_mon_available():
+        # type: () -> bool
+        timeout=ctx.args.timeout if ctx.args.timeout else 60 # seconds
+        out, err, ret = call(ctx, c.run_cmd(),
+                             desc=c.entrypoint,
+                             timeout=timeout)
+        return ret == 0
+
+    is_available(ctx, 'mon', is_mon_available)
+
+
 @default_image
 def command_bootstrap(ctx):
     # type: (CephadmContext) -> int
@@ -3393,29 +3424,7 @@ def command_bootstrap(ctx):
             volume_mounts=mounts,
         ).run(timeout=timeout)
 
-    logger.info('Waiting for mon to start...')
-    c = CephContainer(
-        ctx,
-        image=ctx.args.image,
-        entrypoint='/usr/bin/ceph',
-        args=[
-            'status'],
-        volume_mounts={
-            mon_dir: '/var/lib/ceph/mon/ceph-%s:z' % (mon_id),
-            admin_keyring.name: '/etc/ceph/ceph.client.admin.keyring:z',
-            tmp_config.name: '/etc/ceph/ceph.conf:z',
-        },
-    )
-
-    # wait for the service to become available
-    def is_mon_available():
-        # type: () -> bool
-        timeout=ctx.args.timeout if ctx.args.timeout else 60 # seconds
-        out, err, ret = call(ctx, c.run_cmd(),
-                             desc=c.entrypoint,
-                             timeout=timeout)
-        return ret == 0
-    is_available(ctx, 'mon', is_mon_available)
+    wait_for_mon(ctx, mon_id, mon_dir, admin_keyring.name, tmp_config.name)
 
     # assimilate and minimize config
     if not ctx.args.no_minimize_config:
@@ -7483,4 +7492,5 @@ def main():
     sys.exit(r)
 
 if __name__ == "__main__":
-    main()
\ No newline at end of file
+    main()
+