From b454b995cbfc658e116eed23832ebe029eb553ef Mon Sep 17 00:00:00 2001 From: Michael Fritch Date: Thu, 23 Apr 2020 15:09:03 -0600 Subject: [PATCH] cephadm: catch Exception during is_mgr_available Traceback (most recent call last): File "test_tmp/tmp.ykMmPiFqIT/cephadm", line 4578, in r = args.func() File "test_tmp/tmp.ykMmPiFqIT/cephadm", line 1121, in _default_image return func() File "test_tmp/tmp.ykMmPiFqIT/cephadm", line 2489, in command_bootstrap is_available('mgr', is_mgr_available) File "test_tmp/tmp.ykMmPiFqIT/cephadm", line 895, in is_available if func(): File "test_tmp/tmp.ykMmPiFqIT/cephadm", line 2486, in is_mgr_available out = cli(['status', '-f', 'json-pretty'], timeout=timeout) File "test_tmp/tmp.ykMmPiFqIT/cephadm", line 2403, in cli return CephContainer( File "test_tmp/tmp.ykMmPiFqIT/cephadm", line 2140, in run out, _, _ = call_throws( File "test_tmp/tmp.ykMmPiFqIT/cephadm", line 838, in call_throws raise RuntimeError('Failed command: %s' % ' '.join(command)) Signed-off-by: Michael Fritch --- src/cephadm/cephadm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cephadm/cephadm b/src/cephadm/cephadm index dca6ad273ef..d8c44434d3d 100755 --- a/src/cephadm/cephadm +++ b/src/cephadm/cephadm @@ -892,6 +892,8 @@ def is_available(what, func): num = 1 while True: if func(): + logger.info('%s is available' + % (what)) break elif num > retry: raise Error('%s not available after %s tries' @@ -2482,9 +2484,13 @@ def command_bootstrap(): def is_mgr_available(): # type: () -> bool timeout=args.timeout if args.timeout else 30 # seconds - out = cli(['status', '-f', 'json-pretty'], timeout=timeout) - j = json.loads(out) - return j.get('mgrmap', {}).get('available', False) + 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('mgr', is_mgr_available) # wait for mgr to restart (after enabling a module) -- 2.39.5