Send output files on timeout

The unconventional use of callbacks to return both an error and data
after compilation created a subtle bug where the output files were
dropped by the LockManager in case of an error such as a timeout.

This prevented the frontend to show error logs when a timeout occurs,
creating confusion among users.

We now attach the output files to the error so that they reach the
controller and are sent back to the web service.
This commit is contained in:
Eric Mc Sween
2019-10-22 15:30:14 -04:00
parent a62ff6e248
commit 775306aa63
4 changed files with 22 additions and 17 deletions

View File

@@ -78,7 +78,7 @@ module.exports = DockerRunner =
_callback(args...)
# Only call the callback once
_callback = () ->
name = options.name
streamEnded = false
@@ -115,7 +115,7 @@ module.exports = DockerRunner =
_getContainerOptions: (command, image, volumes, timeout, environment) ->
timeoutInSeconds = timeout / 1000
dockerVolumes = {}
for hostVol, dockerVol of volumes
dockerVolumes[dockerVol] = {}
@@ -148,7 +148,7 @@ module.exports = DockerRunner =
"Ulimits": [{'Name': 'cpu', 'Soft': timeoutInSeconds+5, 'Hard': timeoutInSeconds+10}]
"CapDrop": "ALL"
"SecurityOpt": ["no-new-privileges"]
if Settings.path?.synctexBinHostPath?
options["HostConfig"]["Binds"].push("#{Settings.path.synctexBinHostPath}:/opt/synctex:ro")
@@ -276,7 +276,7 @@ module.exports = DockerRunner =
logger.log container_id: containerId, "timeout reached, killing container"
container.kill(() ->)
, timeout
logger.log container_id: containerId, "waiting for docker container"
container.wait (error, res) ->
if error?
@@ -355,4 +355,4 @@ module.exports = DockerRunner =
, oneHour = 60 * 60 * 1000
, randomDelay
DockerRunner.startContainerMonitor()
DockerRunner.startContainerMonitor()