Decaf cleanup: camel-case variables

This commit is contained in:
Eric Mc Sween
2020-09-03 14:58:37 -04:00
parent 2a31f8c8d7
commit d86a856997

View File

@@ -1,5 +1,4 @@
/* eslint-disable /* eslint-disable
camelcase,
handle-callback-err, handle-callback-err,
no-return-assign, no-return-assign,
no-unused-vars, no-unused-vars,
@@ -33,7 +32,7 @@ module.exports = DockerRunner = {
ERR_TIMED_OUT: new Error('container timed out'), ERR_TIMED_OUT: new Error('container timed out'),
run( run(
project_id, projectId,
command, command,
directory, directory,
image, image,
@@ -90,18 +89,18 @@ module.exports = DockerRunner = {
compileGroup compileGroup
) )
const fingerprint = DockerRunner._fingerprintContainer(options) const fingerprint = DockerRunner._fingerprintContainer(options)
options.name = name = `project-${project_id}-${fingerprint}` options.name = name = `project-${projectId}-${fingerprint}`
// logOptions = _.clone(options) // logOptions = _.clone(options)
// logOptions?.HostConfig?.SecurityOpt = "secomp used, removed in logging" // logOptions?.HostConfig?.SecurityOpt = "secomp used, removed in logging"
logger.log({ project_id }, 'running docker container') logger.log({ projectId }, 'running docker container')
DockerRunner._runAndWaitForContainer(options, volumes, timeout, function ( DockerRunner._runAndWaitForContainer(options, volumes, timeout, function (
error, error,
output output
) { ) {
if (error && error.statusCode === 500) { if (error && error.statusCode === 500) {
logger.log( logger.log(
{ err: error, project_id }, { err: error, projectId },
'error running container so destroying and retrying' 'error running container so destroying and retrying'
) )
DockerRunner.destroyContainer(name, null, true, function (error) { DockerRunner.destroyContainer(name, null, true, function (error) {
@@ -124,9 +123,9 @@ module.exports = DockerRunner = {
return name return name
}, },
kill(container_id, callback) { kill(containerId, callback) {
logger.log({ container_id }, 'sending kill signal to container') logger.log({ containerId }, 'sending kill signal to container')
const container = dockerode.getContainer(container_id) const container = dockerode.getContainer(containerId)
container.kill(function (error) { container.kill(function (error) {
if ( if (
error != null && error != null &&
@@ -134,13 +133,13 @@ module.exports = DockerRunner = {
error.message.match(/Cannot kill container .* is not running/) error.message.match(/Cannot kill container .* is not running/)
) { ) {
logger.warn( logger.warn(
{ err: error, container_id }, { err: error, containerId },
'container not running, continuing' 'container not running, continuing'
) )
error = null error = null
} }
if (error != null) { if (error != null) {
logger.error({ err: error, container_id }, 'error killing container') logger.error({ err: error, containerId }, 'error killing container')
callback(error) callback(error)
} else { } else {
callback() callback()
@@ -424,7 +423,7 @@ module.exports = DockerRunner = {
) { ) {
if (error != null) { if (error != null) {
logger.error( logger.error(
{ err: error, container_id: containerId }, { err: error, containerId },
'error attaching to container' 'error attaching to container'
) )
return attachStartCallback(error) return attachStartCallback(error)
@@ -432,7 +431,7 @@ module.exports = DockerRunner = {
attachStartCallback() attachStartCallback()
} }
logger.log({ container_id: containerId }, 'attached to container') logger.log({ containerId }, 'attached to container')
const MAX_OUTPUT = 1024 * 1024 // limit output to 1MB const MAX_OUTPUT = 1024 * 1024 // limit output to 1MB
const createStringOutputStream = function (name) { const createStringOutputStream = function (name) {
@@ -448,7 +447,7 @@ module.exports = DockerRunner = {
} else { } else {
logger.error( logger.error(
{ {
container_id: containerId, containerId,
length: this.data.length, length: this.data.length,
maxLen: MAX_OUTPUT maxLen: MAX_OUTPUT
}, },
@@ -470,7 +469,7 @@ module.exports = DockerRunner = {
stream.on('error', (err) => stream.on('error', (err) =>
logger.error( logger.error(
{ err, container_id: containerId }, { err, containerId },
'error reading from container stream' 'error reading from container stream'
) )
) )
@@ -493,21 +492,15 @@ module.exports = DockerRunner = {
let timedOut = false let timedOut = false
const timeoutId = setTimeout(function () { const timeoutId = setTimeout(function () {
timedOut = true timedOut = true
logger.log( logger.log({ containerId }, 'timeout reached, killing container')
{ container_id: containerId },
'timeout reached, killing container'
)
container.kill(function () {}) container.kill(function () {})
}, timeout) }, timeout)
logger.log({ container_id: containerId }, 'waiting for docker container') logger.log({ containerId }, 'waiting for docker container')
container.wait(function (error, res) { container.wait(function (error, res) {
if (error != null) { if (error != null) {
clearTimeout(timeoutId) clearTimeout(timeoutId)
logger.error( logger.error({ err: error, containerId }, 'error waiting for container')
{ err: error, container_id: containerId },
'error waiting for container'
)
return callback(error) return callback(error)
} }
if (timedOut) { if (timedOut) {
@@ -518,7 +511,7 @@ module.exports = DockerRunner = {
} else { } else {
clearTimeout(timeoutId) clearTimeout(timeoutId)
logger.log( logger.log(
{ container_id: containerId, exitCode: res.StatusCode }, { containerId, exitCode: res.StatusCode },
'docker container returned' 'docker container returned'
) )
callback(null, res.StatusCode) callback(null, res.StatusCode)
@@ -546,23 +539,20 @@ module.exports = DockerRunner = {
}, },
_destroyContainer(containerId, shouldForce, callback) { _destroyContainer(containerId, shouldForce, callback) {
logger.log({ container_id: containerId }, 'destroying docker container') logger.log({ containerId }, 'destroying docker container')
const container = dockerode.getContainer(containerId) const container = dockerode.getContainer(containerId)
container.remove({ force: shouldForce === true }, function (error) { container.remove({ force: shouldForce === true }, function (error) {
if (error != null && error.statusCode === 404) { if (error != null && error.statusCode === 404) {
logger.warn( logger.warn(
{ err: error, container_id: containerId }, { err: error, containerId },
'container not found, continuing' 'container not found, continuing'
) )
error = null error = null
} }
if (error != null) { if (error != null) {
logger.error( logger.error({ err: error, containerId }, 'error destroying container')
{ err: error, container_id: containerId },
'error destroying container'
)
} else { } else {
logger.log({ container_id: containerId }, 'destroyed container') logger.log({ containerId }, 'destroyed container')
} }
callback(error) callback(error)
}) })