From ca1f5bef9aed3c6b5fd062695c21ca1bb95a8f24 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Fri, 17 Jan 2020 11:21:29 +0100 Subject: [PATCH 1/3] feat(xo-server/Xapi): make built-in concurrency limits configurable See xoa-support#2075 --- packages/xo-server/config.toml | 3 +++ packages/xo-server/src/xapi/index.js | 24 ++++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/packages/xo-server/config.toml b/packages/xo-server/config.toml index db5d782d25d..4b1fba48ed2 100644 --- a/packages/xo-server/config.toml +++ b/packages/xo-server/config.toml @@ -120,4 +120,7 @@ timeout = 600e3 #numWorkers = 2 [xapiOptions] +exportVdiConcurrency = 12 +exportVmConcurrency = 2 +snapshotVmConcurrency = 2 maxUncoalescedVdis = 1 diff --git a/packages/xo-server/src/xapi/index.js b/packages/xo-server/src/xapi/index.js index 097cacb219f..36ab416b2ff 100644 --- a/packages/xo-server/src/xapi/index.js +++ b/packages/xo-server/src/xapi/index.js @@ -94,12 +94,31 @@ export const IPV6_CONFIG_MODES = ['None', 'DHCP', 'Static', 'Autoconf'] @mixin(mapToArray(mixins)) export default class Xapi extends XapiBase { - constructor({ guessVhdSizeOnImport, maxUncoalescedVdis, ...opts }) { + constructor({ + exportVdiConcurrency, + exportVmConcurrency, + snapshotVmConcurrency, + guessVhdSizeOnImport, + maxUncoalescedVdis, + ...opts + }) { super(opts) this._guessVhdSizeOnImport = guessVhdSizeOnImport this._maxUncoalescedVdis = maxUncoalescedVdis + const waitStreamEnd = async stream => fromEvent(await stream, 'end') + this._exportVdi = concurrency( + exportVdiConcurrency, + waitStreamEnd + )(this._exportVdi) + this.exportVm = concurrency( + exportVmConcurrency, + waitStreamEnd + )(this.exportVm) + + this._snapshotVm = concurrency(snapshotVmConcurrency)(this._snapshotVm) + // Patch getObject to resolve _xapiId property. this.getObject = (getObject => (...args) => { let tmp @@ -689,7 +708,6 @@ export default class Xapi extends XapiBase { } // Returns a stream to the exported VM. - @concurrency(2, stream => stream.then(stream => fromEvent(stream, 'end'))) @cancelable async exportVm($cancelToken, vmId, { compress = false } = {}) { const vm = this.getObject(vmId) @@ -1459,7 +1477,6 @@ export default class Xapi extends XapiBase { } } - @concurrency(2) @cancelable async _snapshotVm($cancelToken, { $ref: vmRef }, nameLabel) { const vm = await this.getRecord('VM', vmRef) @@ -1916,7 +1933,6 @@ export default class Xapi extends XapiBase { return snap } - @concurrency(12, stream => stream.then(stream => fromEvent(stream, 'end'))) @cancelable _exportVdi($cancelToken, vdi, base, format = VDI_FORMAT_VHD) { const query = { From c3e5912c696017c3aa23869b39dd160d052f1e12 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Fri, 17 Jan 2020 11:49:35 +0100 Subject: [PATCH 2/3] better names --- packages/xo-server/config.toml | 6 +++--- packages/xo-server/src/xapi/index.js | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/xo-server/config.toml b/packages/xo-server/config.toml index 4b1fba48ed2..3d8ab05619f 100644 --- a/packages/xo-server/config.toml +++ b/packages/xo-server/config.toml @@ -120,7 +120,7 @@ timeout = 600e3 #numWorkers = 2 [xapiOptions] -exportVdiConcurrency = 12 -exportVmConcurrency = 2 -snapshotVmConcurrency = 2 maxUncoalescedVdis = 1 +vdiExportConcurrency = 12 +vmExportConcurrency = 2 +vmSnapshotConcurrency = 2 diff --git a/packages/xo-server/src/xapi/index.js b/packages/xo-server/src/xapi/index.js index 36ab416b2ff..6186e476550 100644 --- a/packages/xo-server/src/xapi/index.js +++ b/packages/xo-server/src/xapi/index.js @@ -95,11 +95,11 @@ export const IPV6_CONFIG_MODES = ['None', 'DHCP', 'Static', 'Autoconf'] @mixin(mapToArray(mixins)) export default class Xapi extends XapiBase { constructor({ - exportVdiConcurrency, - exportVmConcurrency, - snapshotVmConcurrency, guessVhdSizeOnImport, maxUncoalescedVdis, + vdiExportConcurrency, + vmExportConcurrency, + vmSnapshotConcurrency, ...opts }) { super(opts) @@ -109,15 +109,15 @@ export default class Xapi extends XapiBase { const waitStreamEnd = async stream => fromEvent(await stream, 'end') this._exportVdi = concurrency( - exportVdiConcurrency, + vdiExportConcurrency, waitStreamEnd )(this._exportVdi) this.exportVm = concurrency( - exportVmConcurrency, + vmExportConcurrency, waitStreamEnd )(this.exportVm) - this._snapshotVm = concurrency(snapshotVmConcurrency)(this._snapshotVm) + this._snapshotVm = concurrency(vmSnapshotConcurrency)(this._snapshotVm) // Patch getObject to resolve _xapiId property. this.getObject = (getObject => (...args) => { From 9b1e1192287b1cbf7c2a20a272b799a57cefd95e Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Fri, 17 Jan 2020 11:53:14 +0100 Subject: [PATCH 3/3] changelog --- CHANGELOG.unreleased.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index f33f268380e..632b61ab9a2 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -10,6 +10,11 @@ - [Snapshot] Fallback to normal snapshot if quiesce is not available [#4735](https://github.com/vatesfr/xen-orchestra/issues/4735) (PR [#4736](https://github.com/vatesfr/xen-orchestra/pull/4736)) \ Fixes compatibility with **Citrix Hypervisor 8.1**. - [Uncompressed full backup] Quick healthcheck of downloaded XVAs in case there was an undetected issue (PR [#4741](https://github.com/vatesfr/xen-orchestra/pull/4741)) +- [Backup] Make built-in concurrency limits configurable (PR [#4743](https://github.com/vatesfr/xen-orchestra/pull/4743)) \ + Via the following entries in `xo-server`'s configuration file: + - `xapiOptions.vdiExportConcurrency` + - `xapiOptions.vmExportConcurrency` + - `xapiOptions.vmSnapshotConcurrency` ### Bug fixes