]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
cephadm: split-off mgr creation
authorJoao Eduardo Luis <joao@suse.com>
Thu, 31 Dec 2020 01:07:55 +0000 (01:07 +0000)
committerJuan Miguel Olmo Martínez <jolmomar@redhat.com>
Mon, 25 Jan 2021 17:32:53 +0000 (18:32 +0100)
Signed-off-by: Joao Eduardo Luis <joao@suse.com>
(cherry picked from commit 60329c6be3bc2cefe32108068597ecb6dff39220)

src/cephadm/cephadm

index d885b752afe633604c246b84cf62e023b3e5d10e..236f2d2d69d3b5d51e4faaef3651204faa3cd540 100755 (executable)
@@ -3305,6 +3305,34 @@ def wait_for_mon(
     is_available(ctx, 'mon', is_mon_available)
 
 
+def create_mgr(
+    ctx: CephadmContext,
+    uid: int, gid: int,
+    fsid: str, mgr_id: str, mgr_key: str,
+    config: str, clifunc: Callable
+) -> None:
+    logger.info('Creating mgr...')
+    mgr_keyring = '[mgr.%s]\n\tkey = %s\n' % (mgr_id, mgr_key)
+    mgr_c = get_container(ctx, fsid, 'mgr', mgr_id)
+    # Note:the default port used by the Prometheus node exporter is opened in fw
+    deploy_daemon(ctx, fsid, 'mgr', mgr_id, mgr_c, uid, gid,
+                  config=config, keyring=mgr_keyring, ports=[9283])
+
+    # wait for the service to become available
+    logger.info('Waiting for mgr to start...')
+    def is_mgr_available():
+        # type: () -> bool
+        timeout=ctx.args.timeout if ctx.args.timeout else 60 # seconds
+        try:
+            out = clifunc(['status', '-f', 'json-pretty'], timeout=timeout)
+            j = json.loads(out)
+            return j.get('mgrmap', {}).get('available', False)
+        except Exception as e:
+            logger.debug('status failed: %s' % e)
+            return False
+    is_available(ctx, 'mgr', is_mgr_available)
+
+
 @default_image
 def command_bootstrap(ctx):
     # type: (CephadmContext) -> int
@@ -3483,26 +3511,7 @@ def command_bootstrap(ctx):
     logger.info('Wrote config to %s' % ctx.args.output_config)
 
     # create mgr
-    logger.info('Creating mgr...')
-    mgr_keyring = '[mgr.%s]\n\tkey = %s\n' % (mgr_id, mgr_key)
-    mgr_c = get_container(ctx, fsid, 'mgr', mgr_id)
-    # Note:the default port used by the Prometheus node exporter is opened in fw
-    deploy_daemon(ctx, fsid, 'mgr', mgr_id, mgr_c, uid, gid,
-                  config=config, keyring=mgr_keyring, ports=[9283])
-
-    # wait for the service to become available
-    logger.info('Waiting for mgr to start...')
-    def is_mgr_available():
-        # type: () -> bool
-        timeout=ctx.args.timeout if ctx.args.timeout else 60 # seconds
-        try:
-            out = cli(['status', '-f', 'json-pretty'], timeout=timeout)
-            j = json.loads(out)
-            return j.get('mgrmap', {}).get('available', False)
-        except Exception as e:
-            logger.debug('status failed: %s' % e)
-            return False
-    is_available(ctx, 'mgr', is_mgr_available)
+    create_mgr(ctx, uid, gid, fsid, mgr_id, mgr_key, config, cli)
 
     # wait for mgr to restart (after enabling a module)
     def wait_for_mgr_restart():