feat(backups-cli/clean-vms): limit VHD merging concurrency to 1

This commit is contained in:
Julien Fontanet 2020-09-29 10:43:48 +02:00
parent aed09b152a
commit d1db616d1e
2 changed files with 4 additions and 2 deletions

View File

@ -8,6 +8,7 @@ let force
const assert = require('assert')
const flatten = require('lodash/flatten')
const getopts = require('getopts')
const limitConcurrency = require('limit-concurrency-decorator')
const lockfile = require('proper-lockfile')
const pipe = require('promise-toolbox/pipe')
const { default: Vhd, mergeVhd } = require('vhd-lib')
@ -26,7 +27,7 @@ const handler = require('@xen-orchestra/fs').getHandler({ url: 'file://' })
//
// the whole chain will be merged into parent, parent will be renamed to child
// and all the others will deleted
async function mergeVhdChain(chain) {
const mergeVhdChain = limitConcurrency(1)(async function mergeVhdChain(chain) {
assert(chain.length >= 2)
let child = chain[0]
@ -87,7 +88,7 @@ async function mergeVhdChain(chain) {
return force && handler.unlink(child)
}),
])
}
})
const listVhds = pipe([
vmDir => vmDir + '/vdis',

View File

@ -10,6 +10,7 @@
"@xen-orchestra/fs": "^0.11.0",
"filenamify": "^4.1.0",
"getopts": "^2.2.5",
"limit-concurrency-decorator": "^0.4.0",
"lodash": "^4.17.15",
"promise-toolbox": "^0.15.0",
"proper-lockfile": "^4.1.1",