From e08c600740f31197fd42515f771bbdddfe52c299 Mon Sep 17 00:00:00 2001 From: badrAZ Date: Tue, 9 Feb 2021 14:24:35 +0100 Subject: [PATCH] fix(xo-server/xapi): handle VM/VDI export stream close (#5538) --- CHANGELOG.unreleased.md | 2 ++ packages/xo-server/src/xapi/index.js | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 917be157d..f63860cfb 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -14,6 +14,8 @@ > Users must be able to say: “I had this issue, happy to know it's fixed” +- [VM/Snapshot export] Fix `Error: no available place in queue` on canceling an export via browser then starting a new one when the concurrency threshold is reached [#5535](https://github.com/vatesfr/xen-orchestra/issues/5535) (PR [#5538](https://github.com/vatesfr/xen-orchestra/pull/5538)) + ### Packages to release > Packages will be released in the order they are here, therefore, they should diff --git a/packages/xo-server/src/xapi/index.js b/packages/xo-server/src/xapi/index.js index 045033f4f..a3f910cd0 100644 --- a/packages/xo-server/src/xapi/index.js +++ b/packages/xo-server/src/xapi/index.js @@ -10,7 +10,7 @@ import ms from 'ms' import synchronized from 'decorator-synchronized' import tarStream from 'tar-stream' import { vmdkToVhd } from 'xo-vmdk-to-vhd' -import { cancelable, defer, fromEvent, ignoreErrors, pCatch, pRetry } from 'promise-toolbox' +import { cancelable, defer, fromEvents, ignoreErrors, pCatch, pRetry } from 'promise-toolbox' import { parseDuration } from '@vates/parse-duration' import { PassThrough } from 'stream' import { forbiddenOperation } from 'xo-common/api-errors' @@ -105,7 +105,8 @@ export default class Xapi extends XapiBase { this._maxUncoalescedVdis = maxUncoalescedVdis this._restartHostTimeout = parseDuration(restartHostTimeout) - const waitStreamEnd = async stream => fromEvent(await stream, 'end') + // close event is emitted when the export is canceled via browser. See https://github.com/vatesfr/xen-orchestra/issues/5535 + const waitStreamEnd = async stream => fromEvents(await stream, ['end', 'close']) this._exportVdi = concurrency(vdiExportConcurrency, waitStreamEnd)(this._exportVdi) this.exportVm = concurrency(vmExportConcurrency, waitStreamEnd)(this.exportVm)