feat(xapi/VDI_destroy): dont fail if VDI not found
Aligned with xo-server/xapi/deleteVdi.
This commit is contained in:
@@ -1,19 +1,27 @@
|
||||
const CancelToken = require('promise-toolbox/CancelToken')
|
||||
const pCatch = require('promise-toolbox/catch')
|
||||
const pRetry = require('promise-toolbox/retry')
|
||||
|
||||
const extractOpaqueRef = require('./_extractOpaqueRef')
|
||||
|
||||
const noop = Function.prototype
|
||||
|
||||
module.exports = class Vdi {
|
||||
async clone(vdiRef) {
|
||||
return extractOpaqueRef(await this.callAsync('VDI.clone', vdiRef))
|
||||
}
|
||||
|
||||
async destroy(vdiRef) {
|
||||
// work around a race condition in XCP-ng/XenServer where the disk is not fully unmounted yet
|
||||
await pRetry(() => this.callAsync('VDI.destroy', vdiRef), {
|
||||
...this._vdiDestroyRetry,
|
||||
when: { code: 'VDI_IN_USE' },
|
||||
})
|
||||
await pCatch.call(
|
||||
// work around a race condition in XCP-ng/XenServer where the disk is not fully unmounted yet
|
||||
pRetry(() => this.callAsync('VDI.destroy', vdiRef), {
|
||||
...this._vdiDestroyRetry,
|
||||
when: { code: 'VDI_IN_USE' },
|
||||
}),
|
||||
// if this VDI is not found, consider it destroyed
|
||||
{ code: 'HANDLE_INVALID' },
|
||||
noop
|
||||
)
|
||||
}
|
||||
|
||||
async create(
|
||||
|
||||
Reference in New Issue
Block a user