fix(xo-server/snapshotVm): dont retry and unconditionaly clean (#4075)
Fixes #4074
This commit is contained in:
parent
2af1207702
commit
b7e14ebf2a
@ -7,6 +7,7 @@
|
|||||||
- [Advanced] Configurable cookie validity (PR [#4059](https://github.com/vatesfr/xen-orchestra/pull/4059))
|
- [Advanced] Configurable cookie validity (PR [#4059](https://github.com/vatesfr/xen-orchestra/pull/4059))
|
||||||
- [Plugins] Display number of installed plugins [#4008](https://github.com/vatesfr/xen-orchestra/issues/4008) (PR [#4050](https://github.com/vatesfr/xen-orchestra/pull/4050))
|
- [Plugins] Display number of installed plugins [#4008](https://github.com/vatesfr/xen-orchestra/issues/4008) (PR [#4050](https://github.com/vatesfr/xen-orchestra/pull/4050))
|
||||||
- [Continuous Replication] Opt-in mode to guess VHD size, should help with XenServer 7.1 CU2 and various `VDI_IO_ERROR` errors (PR [#3726](https://github.com/vatesfr/xen-orchestra/pull/3726))
|
- [Continuous Replication] Opt-in mode to guess VHD size, should help with XenServer 7.1 CU2 and various `VDI_IO_ERROR` errors (PR [#3726](https://github.com/vatesfr/xen-orchestra/pull/3726))
|
||||||
|
- [VM/Snapshots] Always delete broken quiesced snapshots [#4074](https://github.com/vatesfr/xen-orchestra/issues/4074) (PR [#4075](https://github.com/vatesfr/xen-orchestra/pull/4075))
|
||||||
|
|
||||||
### Bug fixes
|
### Bug fixes
|
||||||
|
|
||||||
|
@ -1567,47 +1567,28 @@ export default class Xapi extends XapiBase {
|
|||||||
}`
|
}`
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// see https://github.com/vatesfr/xen-orchestra/issues/4074
|
||||||
|
const snapshotNameLabelPrefix = `Snapshot of ${vm.uuid} [`
|
||||||
|
ignoreErrors.call(
|
||||||
|
Promise.all(
|
||||||
|
vm.snapshots.map(async ref => {
|
||||||
|
const nameLabel = await this.getField('VM', ref, 'name_label')
|
||||||
|
if (nameLabel.startsWith(snapshotNameLabelPrefix)) {
|
||||||
|
return this._deleteVm(ref)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
let ref
|
let ref
|
||||||
do {
|
do {
|
||||||
if (!vm.tags.includes('xo-disable-quiesce')) {
|
if (!vm.tags.includes('xo-disable-quiesce')) {
|
||||||
try {
|
try {
|
||||||
ref = await pRetry(
|
ref = await this.callAsync(
|
||||||
async bail => {
|
$cancelToken,
|
||||||
try {
|
'VM.snapshot_with_quiesce',
|
||||||
return await this.callAsync(
|
vmRef,
|
||||||
$cancelToken,
|
nameLabel
|
||||||
'VM.snapshot_with_quiesce',
|
|
||||||
vmRef,
|
|
||||||
nameLabel
|
|
||||||
)
|
|
||||||
} catch (error) {
|
|
||||||
if (error?.code !== 'VM_SNAPSHOT_WITH_QUIESCE_FAILED') {
|
|
||||||
throw bail(error)
|
|
||||||
}
|
|
||||||
|
|
||||||
// detect and remove new broken snapshots
|
|
||||||
//
|
|
||||||
// see https://github.com/vatesfr/xen-orchestra/issues/3936
|
|
||||||
const prevSnapshotRefs = new Set(vm.snapshots)
|
|
||||||
const snapshotNameLabelPrefix = `Snapshot of ${vm.uuid} [`
|
|
||||||
vm.snapshots = await this.getField('VM', vmRef, 'snapshots')
|
|
||||||
const createdSnapshots = (await this.getRecords(
|
|
||||||
'VM',
|
|
||||||
vm.snapshots.filter(_ => !prevSnapshotRefs.has(_))
|
|
||||||
)).filter(_ => _.name_label.startsWith(snapshotNameLabelPrefix))
|
|
||||||
|
|
||||||
// be safe: only delete if there was a single match
|
|
||||||
if (createdSnapshots.length === 1) {
|
|
||||||
ignoreErrors.call(this._deleteVm(createdSnapshots[0]))
|
|
||||||
}
|
|
||||||
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
delay: 60e3,
|
|
||||||
tries: 3,
|
|
||||||
}
|
|
||||||
).then(extractOpaqueRef)
|
).then(extractOpaqueRef)
|
||||||
ignoreErrors.call(this.call('VM.add_tags', ref, 'quiesce'))
|
ignoreErrors.call(this.call('VM.add_tags', ref, 'quiesce'))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user