From 3915ba4ac1e226e687539e664ba1b8370a71ede9 Mon Sep 17 00:00:00 2001 From: mathieuRA Date: Mon, 3 Mar 2025 19:26:33 +0100 Subject: [PATCH 1/2] fix(xo-server/createVm): fix OTHER_OPERATION_IN_PROGRESS --- CHANGELOG.unreleased.md | 2 ++ packages/xo-server/src/xapi/mixins/vm.mjs | 21 +++++++++++++-------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 380c7171fff..76d8c7c7799 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -21,6 +21,8 @@ > 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) { From 489ccf3001144fc454665307a9701646e8d8a18a Mon Sep 17 00:00:00 2001 From: mathieuRA Date: Mon, 3 Mar 2025 19:31:45 +0100 Subject: [PATCH 2/2] changelog --- CHANGELOG.unreleased.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 76d8c7c7799..1219eadc044 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -21,7 +21,7 @@ > 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 +- [VM/New] Fix _OTHER_OPERATION_IN_PROGRESS_ when creating a VM that requires a VDI migration (PR [#8399](https://github.com/vatesfr/xen-orchestra/pull/8399)) ### Packages to release