From 2b2fcca39ce8dee0fdc0c342aa0d6c822592bcec Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Fri, 10 Apr 2020 13:25:40 +0200 Subject: [PATCH] [DockerRunner] fix metric incrementing and error logging - do not log on first EPIPE - inc 'container-inspect-epipe-error' on permanent error only Co-Authored-By: Tim Alby --- app/js/DockerRunner.js | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/app/js/DockerRunner.js b/app/js/DockerRunner.js index 552f65e..6a603d8 100644 --- a/app/js/DockerRunner.js +++ b/app/js/DockerRunner.js @@ -408,31 +408,28 @@ module.exports = DockerRunner = { }) } ) - - const callbackWithRetry = error => { - if (error.message.match(/EPIPE/)) { - metrics.inc('container-inspect-epipe-retry') - return inspectContainer(container, callback) - } - callback(error) - } - - var inspectContainer = (container, innerCallback) => + var inspectContainer = (isRetry) => container.inspect(function(error, stats) { if ((error != null ? error.statusCode : undefined) === 404) { return createAndStartContainer() } else if (error != null) { - metrics.inc('container-inspect-epipe-error') + if (error.message.match(/EPIPE/)) { + if (!isRetry) { + metrics.inc('container-inspect-epipe-retry') + return inspectContainer(true) + } + metrics.inc('container-inspect-epipe-error') + } logger.err( { container_name: name, error }, 'unable to inspect container to start' ) - return innerCallback(error) + return callback(error) } else { return startExistingContainer() } }) - inspectContainer(container, callbackWithRetry) + inspectContainer(false) }, attachToContainer(containerId, attachStreamHandler, attachStartCallback) {