wtsi-hgi/thrifty-builder

stderr/stdout not shown for failed RUN commands

Opened this issue · 2 comments

when a RUN step fails, only the command line and exit code are shown, but not any of the stderr/stdout from the failed task. this makes it very difficult to diagnose problems.

Building all...
Building Docker image: foo/bar
Traceback (most recent call last):
  File "/usr/local/bin/thrifty", line 10, in <module>
    sys.exit(entrypoint())
  File "/usr/local/lib/python3.6/site-packages/thriftybuilder/cli.py", line 156, in entrypoint
    main(sys.argv[1:], None if sys.stdin.isatty() else sys.stdin.read())
  File "/usr/local/lib/python3.6/site-packages/thriftybuilder/cli.py", line 99, in main
    build_results = docker_builder.build_all()
  File "/usr/local/lib/python3.6/site-packages/thriftybuilder/builders.py", line 188, in build_all
    build_results = self.build(build_configuration, left_to_build, _checksum_storage=checksum_storage)
  File "/usr/local/lib/python3.6/site-packages/thriftybuilder/builders.py", line 164, in build
    build_result = self._build(build_configuration)
  File "/usr/local/lib/python3.6/site-packages/thriftybuilder/builders.py", line 259, in _build
    raise BuildStepError(build_configuration.name, error_details["message"], error_details.get("code"))
thriftybuilder.builders.BuildStepError: Build for foo/bar failed with exit code 127: The command '/bin/sh -c ./setup-dev-env.sh' returned a non-zero code: 127

N.B. having reviewed the code, I see that this output (and all output) would be available via debug logging, and I can confirm that it does show up when using -vvv. Still, it would be helpful to have a compromise in which perhaps the last N lines of output leading up to an error were output at higher log levels.

Created patch (#21) that, at the moment, is printing all of the build logs. At the point in which a terminal failure has occurred, I feel that it's okey to be more verbose. However, it could be a bit much if the build has been very chatty! Looking for a sensible value of N.