From: Michael Fritch Date: Thu, 19 Aug 2021 21:21:06 +0000 (-0600) Subject: mgr/cephadm: show unhandled exceptions during `host add` X-Git-Tag: v16.2.7~67^2~74 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=7de8a406551421229ad09b97a41902e249461d0d;p=ceph.git mgr/cephadm: show unhandled exceptions during `host add` 138700e59bcd assumes stderr will always have a line containing the prefix 'ERROR', which leads to an empty error reason when `check-host` fails with an unhandled exception Fixes: https://tracker.ceph.com/issues/51818 Signed-off-by: Michael Fritch (cherry picked from commit dac9225085a1f6d2eeaf209fc3d77c54208db2e8) --- diff --git a/src/pybind/mgr/cephadm/module.py b/src/pybind/mgr/cephadm/module.py index 2e9704e2358a..c46cf6a9ae3d 100644 --- a/src/pybind/mgr/cephadm/module.py +++ b/src/pybind/mgr/cephadm/module.py @@ -1441,11 +1441,13 @@ Then run the following: addr=addr, error_ok=True, no_fsid=True) if code: + msg = 'check-host failed:\n' + '\n'.join(err) # err will contain stdout and stderr, so we filter on the message text to # only show the errors errors = [_i.replace("ERROR: ", "") for _i in err if _i.startswith('ERROR')] - raise OrchestratorError('Host %s (%s) failed check(s): %s' % ( - host, addr, errors)) + if errors: + msg = f'Host {host} ({addr}) failed check(s): {errors}' + raise OrchestratorError(msg) return ip_addr def _add_host(self, spec):