mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 20:03:43 -05:00
Merge pull request #141 from das7pad/hotfix-container-deletion-locking
[DockerRunner] destroyOldContainers: normalize the container name
This commit is contained in:
commit
5937a20c05
2 changed files with 6 additions and 3 deletions
|
@ -632,6 +632,9 @@ module.exports = DockerRunner = {
|
|||
ttl
|
||||
) {
|
||||
if (name.slice(0, 9) === '/project-' && ttl <= 0) {
|
||||
// strip the / prefix
|
||||
// the LockManager uses the plain container name
|
||||
name = name.slice(1)
|
||||
return jobs.push(cb =>
|
||||
DockerRunner.destroyContainer(name, id, false, () => cb())
|
||||
)
|
||||
|
|
|
@ -630,19 +630,19 @@ describe('DockerRunner', function() {
|
|||
it('should destroy old containers', function() {
|
||||
this.DockerRunner.destroyContainer.callCount.should.equal(1)
|
||||
return this.DockerRunner.destroyContainer
|
||||
.calledWith('/project-old-container-name', 'old-container-id')
|
||||
.calledWith('project-old-container-name', 'old-container-id')
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should not destroy new containers', function() {
|
||||
return this.DockerRunner.destroyContainer
|
||||
.calledWith('/project-new-container-name', 'new-container-id')
|
||||
.calledWith('project-new-container-name', 'new-container-id')
|
||||
.should.equal(false)
|
||||
})
|
||||
|
||||
it('should not destroy non-project containers', function() {
|
||||
return this.DockerRunner.destroyContainer
|
||||
.calledWith('/totally-not-a-project-container', 'some-random-id')
|
||||
.calledWith('totally-not-a-project-container', 'some-random-id')
|
||||
.should.equal(false)
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue