Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extra way to check OOM of a command ran inside Docker #3294

Merged
merged 2 commits into from
Nov 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions readthedocs/doc_builder/environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,12 @@ def run(self):
self.exit_code = cmd_ret['ExitCode']

# Docker will exit with a special exit code to signify the command
# was killed due to memory usage, make the error code nicer.
if (self.exit_code == DOCKER_OOM_EXIT_CODE and
self.output == 'Killed\n'):
# was killed due to memory usage, make the error code
# nicer. Sometimes the kernel kills the command and Docker doesn't
# not use the specific exit code, so we check if the word `Killed`
# is in the last 15 lines of the command's output
killed_in_output = 'Killed' in '\n'.join(self.output.splitlines()[-15:])
if self.exit_code == DOCKER_OOM_EXIT_CODE or (self.exit_code == 1 and killed_in_output):
self.output = _('Command killed due to excessive memory '
'consumption\n')
except DockerAPIError:
Expand Down