fix(xo-server): limit number of VM exports (#2671)

Fixes #2669
This commit is contained in:
Julien Fontanet 2018-02-21 17:37:07 +01:00 committed by GitHub
parent 8a010f62fd
commit ede12b6732
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 9 deletions

View File

@ -78,7 +78,7 @@
"level": "^3.0.0",
"level-party": "^3.0.4",
"level-sublevel": "^6.6.1",
"limit-concurrency-decorator": "^0.3.0",
"limit-concurrency-decorator": "^0.4.0",
"lodash": "^4.17.4",
"make-error": "^1",
"micromatch": "^3.1.4",

View File

@ -9,6 +9,7 @@ import {
cancellable,
catchPlus as pCatch,
defer,
fromEvent,
ignoreErrors,
} from 'promise-toolbox'
import { PassThrough } from 'stream'
@ -84,9 +85,6 @@ export const VDI_FORMAT_RAW = 'raw'
export const IPV4_CONFIG_MODES = ['None', 'DHCP', 'Static']
export const IPV6_CONFIG_MODES = ['None', 'DHCP', 'Static', 'Autoconf']
// do not share the same limit for export and import, it could lead to deadlocks
const importLimit = concurrency(2)
// ===================================================================
@mixin(mapToArray(mixins))
@ -711,6 +709,7 @@ export default class Xapi extends XapiBase {
}
// Returns a stream to the exported VM.
@concurrency(2, stream => stream.then(stream => fromEvent(stream, 'end')))
async exportVm (vmId, { compress = true } = {}) {
const vm = this.getObject(vmId)
@ -1227,7 +1226,6 @@ export default class Xapi extends XapiBase {
)
}
@importLimit
async _importVm (stream, sr, onVmCreation = undefined) {
const taskRef = await this.createTask('VM import')
const query = {}
@ -1256,7 +1254,6 @@ export default class Xapi extends XapiBase {
return vmRef
}
@importLimit
@deferrable
async _importOvaVm (
$defer,

View File

@ -7208,9 +7208,9 @@ liftoff@^2.5.0:
rechoir "^0.6.2"
resolve "^1.1.7"
limit-concurrency-decorator@^0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/limit-concurrency-decorator/-/limit-concurrency-decorator-0.3.0.tgz#f01dc6ece361ecc2169400847bad45d80727c79e"
limit-concurrency-decorator@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/limit-concurrency-decorator/-/limit-concurrency-decorator-0.4.0.tgz#d79c4e97b6ef547df2d905cc3acaabbae1bfeed6"
livereload-js@^2.2.0:
version "2.3.0"