mgr/orch: re-raise to make debugging easier

Signed-off-by: Sebastian Wagner <sewagner@redhat.com>
This commit is contained in:
Sebastian Wagner 2021-09-22 14:20:24 +02:00
parent d0c17ee1c4
commit 38b52f715f
No known key found for this signature in database
GPG Key ID: 8D2442807E6979F8
2 changed files with 11 additions and 8 deletions

View File

@ -1386,10 +1386,10 @@ class TestCephadm(object):
_get_daemon_types.return_value = ['crash']
_hosts.return_value = [hostname, 'other_host']
cephadm_module.inventory.add_host(HostSpec(hostname))
# should raise an error which will get stored in OrchResult object
retval = cephadm_module.enter_host_maintenance(hostname)
assert retval.exception_str
assert not retval.result_str()
with pytest.raises(OrchestratorError, match='Failed to place host1 into maintenance for cluster fsid'):
cephadm_module.enter_host_maintenance(hostname)
assert not cephadm_module.inventory._inventory[hostname]['status']
@mock.patch("cephadm.serve.CephadmServe._run_cephadm")
@ -1418,10 +1418,10 @@ class TestCephadm(object):
_get_daemon_types.return_value = ['crash']
_hosts.return_value = [hostname, 'other_host']
cephadm_module.inventory.add_host(HostSpec(hostname, status='maintenance'))
# should raise an error which will get stored in OrchResult object
retval = cephadm_module.exit_host_maintenance(hostname)
assert retval.exception_str
assert not retval.result_str()
with pytest.raises(OrchestratorError, match='Failed to exit maintenance state for host host1, cluster fsid'):
cephadm_module.exit_host_maintenance(hostname)
assert cephadm_module.inventory._inventory[hostname]['status'] == 'maintenance'
@mock.patch("cephadm.ssh.SSHManager._remote_connection")

View File

@ -125,6 +125,9 @@ def handle_orch_error(f: Callable[..., T]) -> Callable[..., 'OrchResult[T]']:
return OrchResult(f(*args, **kwargs))
except Exception as e:
logger.exception(e)
import os
if 'UNITTEST' in os.environ:
raise # This makes debugging of Tracebacks from unittests a bit easier
return OrchResult(None, exception=e)
return cast(Callable[..., OrchResult[T]], wrapper)