mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-14 21:42:57 +00:00
Log errors on docker run/exec failure
This commit is contained in:
@@ -47,6 +47,9 @@ class DockerRunner:
|
|||||||
exec_result = container.exec_run(cmd)
|
exec_result = container.exec_run(cmd)
|
||||||
output = exec_result.output.decode().rstrip()
|
output = exec_result.output.decode().rstrip()
|
||||||
assert isinstance(output, str)
|
assert isinstance(output, str)
|
||||||
LOGGER.debug(f"Command output: {output}")
|
if exec_result.exit_code != 0:
|
||||||
assert exec_result.exit_code == 0, f"Command: `{cmd}` failed"
|
LOGGER.error(f"Command output:\n{output}")
|
||||||
|
raise AssertionError(f"Command: `{cmd}` failed")
|
||||||
|
else:
|
||||||
|
LOGGER.debug(f"Command output:\n{output}")
|
||||||
return output
|
return output
|
||||||
|
@@ -75,8 +75,11 @@ class TrackedContainer:
|
|||||||
exec_result = container.exec_run(cmd, **final_kwargs)
|
exec_result = container.exec_run(cmd, **final_kwargs)
|
||||||
output = exec_result.output.decode().rstrip()
|
output = exec_result.output.decode().rstrip()
|
||||||
assert isinstance(output, str)
|
assert isinstance(output, str)
|
||||||
LOGGER.debug(f"Command output: {output}")
|
if exec_result.exit_code != 0:
|
||||||
assert exec_result.exit_code == 0, f"Command: `{cmd}` failed"
|
LOGGER.error(f"Command output:\n{output}")
|
||||||
|
raise AssertionError(f"Command: `{cmd}` failed")
|
||||||
|
else:
|
||||||
|
LOGGER.debug(f"Command output:\n{output}")
|
||||||
return output
|
return output
|
||||||
|
|
||||||
def run_and_wait(
|
def run_and_wait(
|
||||||
@@ -91,10 +94,15 @@ class TrackedContainer:
|
|||||||
assert self.container is not None
|
assert self.container is not None
|
||||||
rv = self.container.wait(timeout=timeout)
|
rv = self.container.wait(timeout=timeout)
|
||||||
logs = self.get_logs()
|
logs = self.get_logs()
|
||||||
LOGGER.debug(logs)
|
failed = rv["StatusCode"] != 0
|
||||||
|
|
||||||
|
if failed:
|
||||||
|
LOGGER.error(f"Command output:\n{logs}")
|
||||||
|
else:
|
||||||
|
LOGGER.debug(f"Command output:\n{logs}")
|
||||||
|
assert no_failure != failed
|
||||||
assert no_warnings == (not self.get_warnings(logs))
|
assert no_warnings == (not self.get_warnings(logs))
|
||||||
assert no_errors == (not self.get_errors(logs))
|
assert no_errors == (not self.get_errors(logs))
|
||||||
assert no_failure == (rv["StatusCode"] == 0)
|
|
||||||
self.remove()
|
self.remove()
|
||||||
return logs
|
return logs
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user