From 3e615f725b1d53e39bdbcb196b896fc0e704b28d Mon Sep 17 00:00:00 2001 From: Mathieu <70369997+MathieuRA@users.noreply.github.com> Date: Thu, 23 Jan 2025 13:09:43 +0100 Subject: [PATCH] fix(xapi): VDI_destroyCloudInitConfig wait 5 minutes before removing the VDI (#8247) --- @xen-orchestra/xapi/index.mjs | 3 +++ @xen-orchestra/xapi/package.json | 1 + @xen-orchestra/xapi/vdi.mjs | 3 +++ CHANGELOG.unreleased.md | 1 + packages/xo-server/config.toml | 1 + 5 files changed, 9 insertions(+) diff --git a/@xen-orchestra/xapi/index.mjs b/@xen-orchestra/xapi/index.mjs index d6c72c974b3..d35a68997fe 100644 --- a/@xen-orchestra/xapi/index.mjs +++ b/@xen-orchestra/xapi/index.mjs @@ -1,5 +1,6 @@ import assert from 'assert' import pRetry from 'promise-toolbox/retry' +import { parseDuration } from '@vates/parse-duration' import { utcFormat, utcParse } from 'd3-time-format' import { Xapi as Base } from 'xen-api' import { createLogger } from '@xen-orchestra/log' @@ -151,6 +152,7 @@ export class Xapi extends Base { syncHookSecret, syncHookTimeout, vdiDestroyRetryWhenInUse = { delay: 5e3, tries: 10 }, + vdiDelayBeforeRemovingCloudConfigDrive = '5 min', ...opts }) { super(opts) @@ -169,6 +171,7 @@ export class Xapi extends Base { onRetry: disconnectBeforeRetry, when: { code: 'VDI_IN_USE' }, } + this._vdiDelayBeforeRemovingCloudConfigDrive = parseDuration(vdiDelayBeforeRemovingCloudConfigDrive) const genericWatchers = (this._genericWatchers = new Set()) const objectWatchers = (this._objectWatchers = { __proto__: null }) diff --git a/@xen-orchestra/xapi/package.json b/@xen-orchestra/xapi/package.json index 042accad62d..d49596bb452 100644 --- a/@xen-orchestra/xapi/package.json +++ b/@xen-orchestra/xapi/package.json @@ -26,6 +26,7 @@ "@vates/async-each": "^1.0.0", "@vates/decorate-with": "^2.1.0", "@vates/nbd-client": "^3.1.2", + "@vates/parse-duration": "^0.1.1", "@vates/read-chunk": "^1.2.0", "@vates/task": "^0.6.0", "@xen-orchestra/async-map": "^0.1.2", diff --git a/@xen-orchestra/xapi/vdi.mjs b/@xen-orchestra/xapi/vdi.mjs index 864153eb1bf..912a6155282 100644 --- a/@xen-orchestra/xapi/vdi.mjs +++ b/@xen-orchestra/xapi/vdi.mjs @@ -76,6 +76,9 @@ class Vdi { }) }) + // See https://github.com/vatesfr/xen-orchestra/issues/8219 + await new Promise(resolve => setTimeout(resolve, this._vdiDelayBeforeRemovingCloudConfigDrive)) + await this.VBD_unplug(vbdRef) await this.VDI_destroy(vdiRef) } diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index fb375b6ac59..481b6453665 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -28,6 +28,7 @@ - [Backups/Logs] Display mirror backup transfer size (PR [#8224](https://github.com/vatesfr/xen-orchestra/pull/8224)) - [Settings/Remotes] Only allow using encryption when using data block storage to prevent errors during backups (PR [#8244](https://github.com/vatesfr/xen-orchestra/pull/8244)) - Fix _Rolling Pool Update_ and _Install Patches_ for XenServer >= 8.4 [Forum#9550](https://xcp-ng.org/forum/topic/9550/xenserver-8-patching/27?_=1736774010376) (PR [#8241](https://github.com/vatesfr/xen-orchestra/pull/8241)) +- [New/VM] Fix premature destruction of the cloudConfig VDI when using the option _destroyCloudConfigVdiAfterBoot_ [#8219](https://github.com/vatesfr/xen-orchestra/issues/8219) (PR [#8247](https://github.com/vatesfr/xen-orchestra/pull/8247)) ### Packages to release diff --git a/packages/xo-server/config.toml b/packages/xo-server/config.toml index d5ba51557ba..7f97fd0b451 100644 --- a/packages/xo-server/config.toml +++ b/packages/xo-server/config.toml @@ -193,6 +193,7 @@ vdiExportConcurrency = 12 vmEvacuationConcurrency = 3 vmExportConcurrency = 2 vmSnapshotConcurrency = 2 +vdiDelayBeforeRemovingCloudConfigDrive = '5 min' poolMarkingInterval = '6 hours' poolMarkingMaxAge = '48 hours'