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: v17.0.0~8^2~13 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=6cab3f02aadf8e20bb3064a1a52fa5892ff38f85;p=ceph.git cephadm/bootstrap: spin-off waiting for mon Signed-off-by: Joao Eduardo Luis --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 0b7ab263c78ee..31c341ec16609 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -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() +