Show docker build errors (#6695)

This commit is contained in:
Christopher Pereira 2025-02-15 02:58:16 -03:00 committed by GitHub
parent 4443417c75
commit 30e39e85d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 1 deletions

View File

@ -156,11 +156,13 @@ class RollingLogger:
max_lines: int
char_limit: int
log_lines: list[str]
all_lines: str
def __init__(self, max_lines=10, char_limit=80):
self.max_lines = max_lines
self.char_limit = char_limit
self.log_lines = [''] * self.max_lines
self.all_lines = ''
def is_enabled(self):
return DEBUG and sys.stdout.isatty()
@ -175,6 +177,7 @@ class RollingLogger:
self.log_lines.pop(0)
self.log_lines.append(line[: self.char_limit])
self.print_lines()
self.all_lines += line + '\n'
def write_immediately(self, line):
self._write(line)

View File

@ -168,8 +168,10 @@ class DockerRuntimeBuilder(RuntimeBuilder):
)
except subprocess.CalledProcessError as e:
logger.error(f'Image build failed:\n{e}')
logger.error(f'Image build failed:\n{e}') # TODO: {e} is empty
logger.error(f'Command output:\n{e.output}')
if self.rolling_logger.is_enabled():
logger.error("Docker build output:\n" + self.rolling_logger.all_lines) # Show the error
raise
except subprocess.TimeoutExpired: