From: Kristoffer Grönlund Date: Fri, 21 Feb 2020 22:26:46 +0000 (+0100) Subject: cephadm: Simplify is_available X-Git-Tag: v15.1.1~301^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F33461%2Fhead;p=ceph.git cephadm: Simplify is_available There is no need to return a closure to call from is_available, it can just do the work directly. Signed-off-by: Kristoffer Grönlund --- diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index 518f62bc0e30..b58deb0360c5 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -556,7 +556,7 @@ def call_timeout(command, timeout): ################################## def is_available(what, func): - # type: (str, Callable[..., bool]) -> Callable[..., None] + # type: (str, Callable[[], bool]) -> None """ Wait for a service to become available @@ -564,23 +564,21 @@ def is_available(what, func): :param func: the callable object that determines availability """ retry = args.retry - @wraps(func) - def func_wrapper(*args, **kwargs): - logger.info('Waiting for %s...' % (what)) - num = 1 - while True: - if func(*args, **kwargs): - break - elif num > retry: - raise Error('%s not available after %s tries' - % (what, retry)) + logger.info('Waiting for %s...' % (what)) + num = 1 + while True: + if func(): + break + elif num > retry: + raise Error('%s not available after %s tries' + % (what, retry)) + + logger.info('%s not available, waiting (%s/%s)...' + % (what, num, retry)) - logger.info('%s not available, waiting (%s/%s)...' - % (what, num, retry)) + num += 1 + time.sleep(1) - num += 1 - time.sleep(1) - return func_wrapper def read_config(fn): # type: (Optional[str]) -> ConfigParser @@ -1876,7 +1874,7 @@ def command_bootstrap(): desc=c.entrypoint, timeout=timeout) return ret == 0 - is_available('mon', is_mon_available)() + is_available('mon', is_mon_available) # assimilate and minimize config if not args.no_minimize_config: @@ -1934,7 +1932,7 @@ def command_bootstrap(): out = cli(['status', '-f', 'json-pretty'], timeout=timeout) j = json.loads(out) return j.get('mgrmap', {}).get('available', False) - is_available('mgr', is_mgr_available)() + is_available('mgr', is_mgr_available) # ssh if not args.skip_ssh: @@ -1984,7 +1982,7 @@ def command_bootstrap(): timeout=args.timeout if args.timeout else 30 # seconds out = cli(['-h'], timeout=timeout) return 'dashboard' in out - is_available('Dashboard', is_dashboard_available)() + is_available('Dashboard', is_dashboard_available) logger.info('Generating a dashboard self-signed certificate...') cli(['dashboard', 'create-self-signed-cert'])