fix(xo-server): limit number of VDI exports (#2673)

Fixes #2672
This commit is contained in:
Julien Fontanet 2018-02-21 19:26:39 +01:00 committed by GitHub
parent ede12b6732
commit 2ff25d1f61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 9 deletions

View File

@ -869,13 +869,8 @@ export default class Xapi extends XapiBase {
...vdi,
$SR$uuid: vdi.$SR.uuid,
}
const stream = (streams[`${vdiRef}.vhd`] = this._exportVdi(
$cancelToken,
vdi,
baseVdi,
VDI_FORMAT_VHD
))
$defer.onFailure(stream.cancel)
streams[`${vdiRef}.vhd`] = () =>
this._exportVdi($cancelToken, vdi, baseVdi, VDI_FORMAT_VHD)
})
const vifs = {}
@ -905,7 +900,7 @@ export default class Xapi extends XapiBase {
},
'streams',
{
value: await streams::pAll(),
value: streams,
}
)
}
@ -1029,7 +1024,10 @@ export default class Xapi extends XapiBase {
// Import VDI contents.
asyncMap(newVdis, async (vdi, id) => {
for (const stream of ensureArray(streams[`${id}.vhd`])) {
for (let stream of ensureArray(streams[`${id}.vhd`])) {
if (typeof stream === 'function') {
stream = await stream()
}
await this._importVdiContent(vdi, stream, VDI_FORMAT_VHD)
}
}),
@ -1847,6 +1845,7 @@ export default class Xapi extends XapiBase {
return snap
}
@concurrency(12, stream => stream.then(stream => fromEvent(stream, 'end')))
@cancellable
_exportVdi ($cancelToken, vdi, base, format = VDI_FORMAT_VHD) {
const host = vdi.$SR.$PBDs[0].$host

View File

@ -652,6 +652,10 @@ export default class {
xapi,
{ vdiParent, isFull, handler, stream, dir, retention }
) {
if (typeof stream === 'function') {
stream = await stream()
}
const backupDirectory = `vdi_${vdiParent.uuid}`
dir = `${dir}/${backupDirectory}`