mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge branch 'master' into bg-use-lodash
This commit is contained in:
commit
f41b4daca2
2 changed files with 14 additions and 81 deletions
|
@ -26,7 +26,7 @@ const LockManager = require('./DockerLockManager')
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const Path = require('path')
|
const Path = require('path')
|
||||||
const _ = require('lodash')
|
const _ = require('lodash')
|
||||||
const metrics = require('metrics-sharelatex')
|
|
||||||
|
|
||||||
logger.info('using docker runner')
|
logger.info('using docker runner')
|
||||||
|
|
||||||
|
@ -412,28 +412,19 @@ module.exports = DockerRunner = {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
var inspectContainer = isRetry =>
|
return container.inspect(function(error, stats) {
|
||||||
container.inspect(function(error, stats) {
|
if ((error != null ? error.statusCode : undefined) === 404) {
|
||||||
if ((error != null ? error.statusCode : undefined) === 404) {
|
return createAndStartContainer()
|
||||||
return createAndStartContainer()
|
} else if (error != null) {
|
||||||
} else if (error != null) {
|
logger.err(
|
||||||
if (error.message.match(/EPIPE/)) {
|
{ container_name: name, error },
|
||||||
if (!isRetry) {
|
'unable to inspect container to start'
|
||||||
metrics.inc('container-inspect-epipe-retry')
|
)
|
||||||
return inspectContainer(true)
|
return callback(error)
|
||||||
}
|
} else {
|
||||||
metrics.inc('container-inspect-epipe-error')
|
return startExistingContainer()
|
||||||
}
|
}
|
||||||
logger.err(
|
})
|
||||||
{ container_name: name, error },
|
|
||||||
'unable to inspect container to start'
|
|
||||||
)
|
|
||||||
return callback(error)
|
|
||||||
} else {
|
|
||||||
return startExistingContainer()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
inspectContainer(false)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
attachToContainer(containerId, attachStreamHandler, attachStartCallback) {
|
attachToContainer(containerId, attachStreamHandler, attachStartCallback) {
|
||||||
|
|
|
@ -36,7 +36,6 @@ describe('DockerRunner', function() {
|
||||||
'logger-sharelatex': (this.logger = {
|
'logger-sharelatex': (this.logger = {
|
||||||
log: sinon.stub(),
|
log: sinon.stub(),
|
||||||
error: sinon.stub(),
|
error: sinon.stub(),
|
||||||
err: sinon.stub(),
|
|
||||||
info: sinon.stub(),
|
info: sinon.stub(),
|
||||||
warn: sinon.stub()
|
warn: sinon.stub()
|
||||||
}),
|
}),
|
||||||
|
@ -389,63 +388,6 @@ describe('DockerRunner', function() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('when inspect always fails with EPIPE error', function() {
|
|
||||||
beforeEach(function() {
|
|
||||||
this.error = new Error('write EPIPE')
|
|
||||||
this.container.inspect = sinon.stub().yields(this.error)
|
|
||||||
this.container.start = sinon.stub().yields()
|
|
||||||
|
|
||||||
this.DockerRunner.startContainer(
|
|
||||||
this.options,
|
|
||||||
this.volumes,
|
|
||||||
() => {},
|
|
||||||
this.callback
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should retry once', function() {
|
|
||||||
sinon.assert.callOrder(
|
|
||||||
this.container.inspect,
|
|
||||||
this.container.inspect,
|
|
||||||
this.callback
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should call back with error', function() {
|
|
||||||
sinon.assert.calledWith(this.callback, this.error)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('when inspect fails once with EPIPE error', function() {
|
|
||||||
beforeEach(function() {
|
|
||||||
this.container.inspect = sinon.stub()
|
|
||||||
this.container.inspect.onFirstCall().yields(new Error('write EPIPE'))
|
|
||||||
this.container.inspect.onSecondCall().yields()
|
|
||||||
this.container.start = sinon.stub().yields()
|
|
||||||
|
|
||||||
this.DockerRunner.startContainer(
|
|
||||||
this.options,
|
|
||||||
this.volumes,
|
|
||||||
() => {},
|
|
||||||
this.callback
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should retry once and start container', function() {
|
|
||||||
sinon.assert.callOrder(
|
|
||||||
this.container.inspect,
|
|
||||||
this.container.inspect,
|
|
||||||
this.DockerRunner.attachToContainer,
|
|
||||||
this.container.start,
|
|
||||||
this.callback
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should call back without error', function() {
|
|
||||||
sinon.assert.calledWith(this.callback, null)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('when the container does not exist', function() {
|
describe('when the container does not exist', function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
const exists = false
|
const exists = false
|
||||||
|
|
Loading…
Reference in a new issue