Decaf cleanup: convert async function to sync
The examineOldContainer() function doesn't need to use callbacks since it only does synchronous work.
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
/* eslint-disable
|
/* eslint-disable
|
||||||
handle-callback-err,
|
|
||||||
no-return-assign,
|
no-return-assign,
|
||||||
no-unused-vars,
|
no-unused-vars,
|
||||||
*/
|
*/
|
||||||
@@ -574,7 +573,7 @@ module.exports = DockerRunner = {
|
|||||||
{ containerName: name, created, now, age, maxAge, ttl },
|
{ containerName: name, created, now, age, maxAge, ttl },
|
||||||
'checking whether to destroy container'
|
'checking whether to destroy container'
|
||||||
)
|
)
|
||||||
callback(null, name, container.Id, ttl)
|
return { name, id: container.Id, ttl }
|
||||||
},
|
},
|
||||||
|
|
||||||
destroyOldContainers(callback) {
|
destroyOldContainers(callback) {
|
||||||
@@ -584,21 +583,15 @@ module.exports = DockerRunner = {
|
|||||||
}
|
}
|
||||||
const jobs = []
|
const jobs = []
|
||||||
for (const container of containers) {
|
for (const container of containers) {
|
||||||
DockerRunner.examineOldContainer(container, function (
|
const { name, id, ttl } = DockerRunner.examineOldContainer(container)
|
||||||
err,
|
|
||||||
name,
|
|
||||||
id,
|
|
||||||
ttl
|
|
||||||
) {
|
|
||||||
if (name.slice(0, 9) === '/project-' && ttl <= 0) {
|
if (name.slice(0, 9) === '/project-' && ttl <= 0) {
|
||||||
// strip the / prefix
|
// strip the / prefix
|
||||||
// the LockManager uses the plain container name
|
// the LockManager uses the plain container name
|
||||||
name = name.slice(1)
|
const plainName = name.slice(1)
|
||||||
jobs.push((cb) =>
|
jobs.push((cb) =>
|
||||||
DockerRunner.destroyContainer(name, id, false, () => cb())
|
DockerRunner.destroyContainer(plainName, id, false, () => cb())
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
})
|
|
||||||
}
|
}
|
||||||
// Ignore errors because some containers get stuck but
|
// Ignore errors because some containers get stuck but
|
||||||
// will be destroyed next time
|
// will be destroyed next time
|
||||||
|
|||||||
Reference in New Issue
Block a user