From 95041325852d40a2ed0f3ce25c3da2ec9601b39e Mon Sep 17 00:00:00 2001 From: Florent BEAUCHAMP Date: Tue, 10 Sep 2024 12:19:13 +0200 Subject: [PATCH] feat(backups/CBT): retry data_destroy when error is VDI_IN USE (#7960) Fixes #7826 Sometimes XAPI takes too long to detach the VDI, in this case, the timeout is fixed at 4s, non modifiable when the timeout is reached the xapi raise a VDI_IN_USE error This commit adds a retry on XO side to give more room for XAPI to work through this process, as XO already does it on VDI destroy --- .../backups/_runners/_vmRunners/_AbstractXapi.mjs | 2 +- @xen-orchestra/xapi/vdi.mjs | 11 +++++++++++ CHANGELOG.unreleased.md | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/@xen-orchestra/backups/_runners/_vmRunners/_AbstractXapi.mjs b/@xen-orchestra/backups/_runners/_vmRunners/_AbstractXapi.mjs index 8151cd251ce..a7dcc6340a0 100644 --- a/@xen-orchestra/backups/_runners/_vmRunners/_AbstractXapi.mjs +++ b/@xen-orchestra/backups/_runners/_vmRunners/_AbstractXapi.mjs @@ -290,7 +290,7 @@ export const AbstractXapi = class AbstractXapiVmBackupRunner extends Abstract { for (const vdiRef of vdiRefs) { try { // data_destroy will fail with a VDI_NO_CBT_METADATA error if CBT is not enabled on this VDI - await this._xapi.call('VDI.data_destroy', vdiRef) + await this._xapi.VDI_dataDestroy(vdiRef) Task.info(`Snapshot data has been deleted`, { vdiRef }) } catch (error) { Task.warning(`Couldn't deleted snapshot data`, { error, vdiRef }) diff --git a/@xen-orchestra/xapi/vdi.mjs b/@xen-orchestra/xapi/vdi.mjs index c32191cda9a..c65b9f39985 100644 --- a/@xen-orchestra/xapi/vdi.mjs +++ b/@xen-orchestra/xapi/vdi.mjs @@ -28,6 +28,10 @@ class Vdi { ) } + async dataDestroy(vdiRef) { + await this.callAsync('VDI.data_destroy', vdiRef) + } + async create( { name_description, @@ -290,5 +294,12 @@ decorateClass(Vdi, { return this._vdiDestroyRetryWhenInUse }, ], + // same condition when destroying data of a VDI + dataDestroy: [ + pRetry.wrap, + function () { + return this._vdiDestroyRetryWhenInUse + }, + ], exportContent: defer, }) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index b05bcc316ba..77f2951d05f 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -25,6 +25,8 @@ > Users must be able to say: “I had this issue, happy to know it's fixed” +- [Incremental Backup & Replication] Remove most of `Couldn't delete snapshot data` errors when using _Purge snapshot data when using CBT_ [#7826](https://github.com/vatesfr/xen-orchestra/pull/7826) (PR [#7960](https://github.com/vatesfr/xen-orchestra/pull/7960)) + ### Packages to release > When modifying a package, add it here with its release type. @@ -41,9 +43,11 @@ +- @xen-orchestra/backups patch - @xen-orchestra/lite minor - @xen-orchestra/web minor - @xen-orchestra/web-core minor +- @xen-orchestra/xapi minor - xo-server minor - xo-server-perf-alert minor - xo-server-sdn-controller patch