From: Joao Eduardo Luis Date: Wed, 30 Dec 2020 19:29:19 +0000 (+0000) Subject: cephadm/bootstrap: spin-off waiting for mon X-Git-Tag: v16.2.0~232^2~30 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=71af9b06ee4c914e1cee9d393e9f257bbd8ee2d0;p=ceph.git cephadm/bootstrap: spin-off waiting for mon Signed-off-by: Joao Eduardo Luis (cherry picked from commit 6cab3f02aadf8e20bb3064a1a52fa5892ff38f85) --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 8ea06f98b450..6981d021d61e 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -3264,6 +3264,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 @@ -3316,7 +3347,7 @@ def command_bootstrap(ctx): l.acquire() # ip - (base_ip, addr_arg) = obtain_mon_ip(ctx) + (base_ip, addr_arg) = obtain_mon_ip(ctx) mon_network = None if not ctx.args.skip_mon_network: @@ -3396,29 +3427,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: