From ac55baf18b2e284dc217cc1bc9dd5f08c954c6a6 Mon Sep 17 00:00:00 2001 From: mathieuRA Date: Mon, 3 Mar 2025 19:26:33 +0100 Subject: [PATCH] fix(xo-server/createVm): fix OTHER_OPERATION_IN_PROGRESS --- CHANGELOG.unreleased.md | 4 +++- packages/xo-server/src/xapi/mixins/vm.mjs | 21 +++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 6f1f1cada21..3713174d8b2 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -12,12 +12,14 @@ - **XO6**: - [Pool/Network]: Display networks and host internal networks information in side panel (PR [#8286](https://github.com/vatesfr/xen-orchestra/pull/8286)) - [Changed Block Tracking] Disabling CBT now cleanup the full disk and snapshot chains (PR [#8313](https://github.com/vatesfr/xen-orchestra/pull/8313)) -> Users must be able to say: “Nice enhancement, I'm eager to test it” + > Users must be able to say: “Nice enhancement, I'm eager to test it” ### Bug fixes > Users must be able to say: “I had this issue, happy to know it's fixed” +- [VM/New] Fix _OTHER_OPERATION_IN_PROGRESS_ when creating a VM that requires a VDI migration + ### Packages to release > When modifying a package, add it here with its release type. diff --git a/packages/xo-server/src/xapi/mixins/vm.mjs b/packages/xo-server/src/xapi/mixins/vm.mjs index 69990057274..6894cf5e513 100644 --- a/packages/xo-server/src/xapi/mixins/vm.mjs +++ b/packages/xo-server/src/xapi/mixins/vm.mjs @@ -210,9 +210,9 @@ const methods = { } // TODO: set vm.suspend_SR - await Promise.all([ - // Creates the user defined VDIs. - ..._vdisToCreate.map(async (vdi, i) => { + // Creates the user defined VDIs. + await Promise.all( + _vdisToCreate.map(async (vdi, i) => { const vdiRef = await this.VDI_create({ name_description: vdi.name_description, name_label: vdi.name_label, @@ -232,9 +232,14 @@ const methods = { VDI: vdiRef, VM: vm.$ref, }) - }), - // Modify existing (previous template) disks if necessary - ..._vdisToUpdate.map(async ({ $ref, sr, size, userdevice, ...properties }) => { + }) + ) + + // Modify existing (previous template) disks if necessary + // Wait until all VDIs are created, otherwise VBD_create may throw an OTHER_OPERATION_IN_PROGRESS error + // in case a VDI is migrating + await Promise.all( + _vdisToUpdate.map(async ({ $ref, sr, size, userdevice, ...properties }) => { await this._setObjectProperties({ $ref, $type: 'VDI' }, properties) let _vdi = this.getObject($ref) @@ -252,8 +257,8 @@ const methods = { } await this.resizeVdi(_vdi.$id, size) } - }), - ]) + }) + ) } if (destroyAllVifs) {