From 4a19f022fc3d90201868d318b1b95b73c4b3bbcd Mon Sep 17 00:00:00 2001 From: Jakob Ackermann Date: Fri, 27 Mar 2020 10:39:45 +0100 Subject: [PATCH] [misc] keep up with the error signature of dockerode/docker-modem https://github.com/apocas/docker-modem/blob/v2.1.1/lib/modem.js#L296 --- services/clsi/app/js/DockerRunner.js | 6 +----- services/clsi/test/unit/js/DockerRunnerTests.js | 6 +++--- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/services/clsi/app/js/DockerRunner.js b/services/clsi/app/js/DockerRunner.js index 393ce3df37..3594b3a6d4 100644 --- a/services/clsi/app/js/DockerRunner.js +++ b/services/clsi/app/js/DockerRunner.js @@ -99,11 +99,7 @@ module.exports = DockerRunner = { error, output ) { - if ( - __guard__(error != null ? error.message : undefined, x => - x.match('HTTP code is 500') - ) - ) { + if (error && error.statusCode === 500) { logger.log( { err: error, project_id }, 'error running container so destroying and retrying' diff --git a/services/clsi/test/unit/js/DockerRunnerTests.js b/services/clsi/test/unit/js/DockerRunnerTests.js index eea66b12c1..83992833f3 100644 --- a/services/clsi/test/unit/js/DockerRunnerTests.js +++ b/services/clsi/test/unit/js/DockerRunnerTests.js @@ -202,9 +202,9 @@ describe('DockerRunner', function() { } if (firstTime) { firstTime = false - return callback( - new Error('HTTP code is 500 which indicates error: server error') - ) + const error = new Error('(HTTP code 500) server error - ...') + error.statusCode = 500 + return callback(error) } else { return callback(null, this.output) }