Compare commits

...

1 Commits

Author SHA1 Message Date
Julien Fontanet
30f6ca187d WiP: feat(xo-server/delta backup): handle VDI migration
Fixes #2896

Store its UUID in metadata to avoid a delta afteter a migration.
2019-09-25 11:31:08 +02:00

View File

@@ -498,6 +498,13 @@ const disableVmHighAvailability = async (xapi: Xapi, vm: Vm) => {
// - for copies/replications only, added after complete transfer // - for copies/replications only, added after complete transfer
// - `other_config[xo:backup:sr]` = sr.uuid // - `other_config[xo:backup:sr]` = sr.uuid
// //
// Attributes on the VDIs of the backed-up VMs:
//
// - `other_config`:
// - `xo:backup:diskId`: identifier used for the disk`
// this is automatically filled with its `uuid` if missing
// this is used to keep the identity of the VDI accross migrations
//
// Task logs emitted in a backup execution: // Task logs emitted in a backup execution:
// //
// job.start(data: { mode: Mode, reportWhen: ReportWhen }) // job.start(data: { mode: Mode, reportWhen: ReportWhen })
@@ -1045,6 +1052,18 @@ export default class BackupNg {
xapi._assertHealthyVdiChains(vm) xapi._assertHealthyVdiChains(vm)
} }
{
const disks = getVmDisks(vm)
await Promise.all(
Object.keys(disks).map(ref => {
const disk = disks[ref]
if (!('xo:backup:diskId' in disk.other_config)) {
return disk.update_other_config('xo:backup:diskId', disk.uuid)
}
})
)
}
const offlineSnapshot: boolean = getSetting(settings, 'offlineSnapshot', [ const offlineSnapshot: boolean = getSetting(settings, 'offlineSnapshot', [
vmUuid, vmUuid,
'', '',
@@ -1423,8 +1442,9 @@ export default class BackupNg {
await asyncMap(remotes, ({ handler }) => { await asyncMap(remotes, ({ handler }) => {
return asyncMap(vdis, async vdi => { return asyncMap(vdis, async vdi => {
const snapshotOf = vdi.$snapshot_of const dir = `${vmDir}/vdis/${jobId}/${
const dir = `${vmDir}/vdis/${jobId}/${snapshotOf.uuid}` vdi.other_config['xo:backup:diskId']
}`
const files = await handler const files = await handler
.list(dir, { filter: isVhd }) .list(dir, { filter: isVhd })
.catch(_ => []) .catch(_ => [])
@@ -1455,7 +1475,7 @@ export default class BackupNg {
await handler.unlink(`${dir}/${file}`) await handler.unlink(`${dir}/${file}`)
}) })
if (full) { if (full) {
fullRequired[snapshotOf.$id] = true fullRequired[vdi.$snapshot_of.$id] = true
} }
}) })
}) })
@@ -1486,7 +1506,7 @@ export default class BackupNg {
deltaExport.vdis, deltaExport.vdis,
vdi => vdi =>
`vdis/${jobId}/${ `vdis/${jobId}/${
(xapi.getObject(vdi.snapshot_of): Object).uuid vdi.other_config['xo:backup:diskId']
}/${basename}.vhd` }/${basename}.vhd`
), ),
vm, vm,