fix(xo-server/backup NG): delete interrupted replications (#3923)

Fixes xoa-support#1215
This commit is contained in:
Julien Fontanet 2019-01-31 15:12:22 +01:00 committed by GitHub
parent dfb6d1b58e
commit 1b12aa90de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 1 deletions

View File

@ -34,6 +34,7 @@
- [Legacy Backup] Fix error when restoring a backup
- [Home] Fix `user.getAll` error when user is not admin [#3573](https://github.com/vatesfr/xen-orchestra/issues/3573) (PR [#3918](https://github.com/vatesfr/xen-orchestra/pull/3918))
- [Backup NG] Fix restore issue when a disk has grown [#3910](https://github.com/vatesfr/xen-orchestra/issues/3910) (PR [#3920](https://github.com/vatesfr/xen-orchestra/pull/3920))
- [Backup NG] Delete _importing_ VMs due to interrupted CR/DR (PR [#3923](https://github.com/vatesfr/xen-orchestra/pull/3923))
### Released packages

View File

@ -183,7 +183,7 @@ const getJobCompression = ({ compression: c }) =>
const listReplicatedVms = (
xapi: Xapi,
scheduleId: string,
srId: string,
srId?: string,
vmUuid?: string
): Vm[] => {
const { all } = xapi.objects
@ -918,6 +918,7 @@ export default class BackupNg {
// - [x] possibility to (re-)run a single VM in a backup?
// - [x] validate VHDs after exports and before imports, how?
// - [x] check merge/transfert duration/size are what we want for delta
// - [x] delete interrupted *importing* VMs
@defer
async _backupVm(
$defer: any,
@ -1236,6 +1237,14 @@ export default class BackupNg {
const { $id: srId, xapi } = sr
// delete previous interrupted copies
ignoreErrors.call(
this._deleteVms(
xapi,
listReplicatedVms(xapi, scheduleId, undefined, vmUuid)
)
)
const oldVms = getOldEntries(
copyRetention - 1,
listReplicatedVms(xapi, scheduleId, srId, vmUuid)
@ -1572,6 +1581,14 @@ export default class BackupNg {
const { $id: srId, xapi } = sr
// delete previous interrupted copies
ignoreErrors.call(
this._deleteVms(
xapi,
listReplicatedVms(xapi, scheduleId, undefined, vmUuid)
)
)
const oldVms = getOldEntries(
copyRetention - 1,
listReplicatedVms(xapi, scheduleId, srId, vmUuid)