chore(xapi/VDI_destroy): decorate with retry.wrap()
- more efficient than creating a function at each call - better logging
This commit is contained in:
parent
8f15a4c29d
commit
dbb4f34015
@ -1,6 +1,7 @@
|
|||||||
const CancelToken = require('promise-toolbox/CancelToken.js')
|
const CancelToken = require('promise-toolbox/CancelToken.js')
|
||||||
const pCatch = require('promise-toolbox/catch.js')
|
const pCatch = require('promise-toolbox/catch.js')
|
||||||
const pRetry = require('promise-toolbox/retry.js')
|
const pRetry = require('promise-toolbox/retry.js')
|
||||||
|
const { decorateWith } = require('@vates/decorate-with')
|
||||||
|
|
||||||
const extractOpaqueRef = require('./_extractOpaqueRef.js')
|
const extractOpaqueRef = require('./_extractOpaqueRef.js')
|
||||||
|
|
||||||
@ -11,10 +12,13 @@ module.exports = class Vdi {
|
|||||||
return extractOpaqueRef(await this.callAsync('VDI.clone', vdiRef))
|
return extractOpaqueRef(await this.callAsync('VDI.clone', vdiRef))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// work around a race condition in XCP-ng/XenServer where the disk is not fully unmounted yet
|
||||||
|
@decorateWith(pRetry.wrap, function () {
|
||||||
|
return this._vdiDestroyRetryWhenInUse
|
||||||
|
})
|
||||||
async destroy(vdiRef) {
|
async destroy(vdiRef) {
|
||||||
await pCatch.call(
|
await pCatch.call(
|
||||||
// work around a race condition in XCP-ng/XenServer where the disk is not fully unmounted yet
|
this.callAsync('VDI.destroy', vdiRef),
|
||||||
pRetry(() => this.callAsync('VDI.destroy', vdiRef), this._vdiDestroyRetryWhenInUse),
|
|
||||||
// if this VDI is not found, consider it destroyed
|
// if this VDI is not found, consider it destroyed
|
||||||
{ code: 'HANDLE_INVALID' },
|
{ code: 'HANDLE_INVALID' },
|
||||||
noop
|
noop
|
||||||
|
Loading…
Reference in New Issue
Block a user