fix(xo-server/backups-ng): don't remove startable VMs (#2840)

Fixes #2724
This commit is contained in:
Julien Fontanet 2018-04-06 17:12:36 +02:00 committed by GitHub
parent 172ce2c7a1
commit a251f8ca75
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -145,6 +145,7 @@ const listReplicatedVms = (
const oc = object.other_config const oc = object.other_config
if ( if (
object.$type === 'vm' && object.$type === 'vm' &&
'start' in object.blocked_operations &&
oc['xo:backup:schedule'] === scheduleId && oc['xo:backup:schedule'] === scheduleId &&
oc['xo:backup:sr'] === srId && oc['xo:backup:sr'] === srId &&
(oc['xo:backup:vm'] === vmUuid || (oc['xo:backup:vm'] === vmUuid ||
@ -558,9 +559,6 @@ export default class BackupNg {
} }
// High: // High:
// - [ ] clones of replicated VMs should not be garbage collected
// - if storing uuids in source VM, how to detect them if the source is
// lost?
// - [ ] validate VHDs after exports and before imports, how? // - [ ] validate VHDs after exports and before imports, how?
// - [ ] in case of merge failure // - [ ] in case of merge failure
// 1. delete (or isolate) the tainted VHD // 1. delete (or isolate) the tainted VHD
@ -597,6 +595,7 @@ export default class BackupNg {
// - [x] do not delete rolling snapshot in case of failure! // - [x] do not delete rolling snapshot in case of failure!
// - [x] do not create snapshot if unhealthy vdi chain // - [x] do not create snapshot if unhealthy vdi chain
// - [x] replicated VMs should be discriminated by VM (vatesfr/xen-orchestra#2807) // - [x] replicated VMs should be discriminated by VM (vatesfr/xen-orchestra#2807)
// - [x] clones of replicated VMs should not be garbage collected
@defer @defer
async _backupVm ( async _backupVm (
$defer: any, $defer: any,
@ -700,10 +699,10 @@ export default class BackupNg {
nTargets === 0 nTargets === 0
? () => xva ? () => xva
: () => { : () => {
const fork = xva.pipe(new PassThrough()) const fork = xva.pipe(new PassThrough())
fork.task = exportTask fork.task = exportTask
return fork return fork
} }
const dataBasename = `${basename}.xva` const dataBasename = `${basename}.xva`
@ -854,51 +853,51 @@ export default class BackupNg {
nTargets === 1 nTargets === 1
? () => deltaExport ? () => deltaExport
: (() => { : (() => {
// replace the stream factories by fork factories // replace the stream factories by fork factories
const streams: any = mapValues( const streams: any = mapValues(
deltaExport.streams, deltaExport.streams,
lazyStream => { lazyStream => {
let forks = [] let forks = []
return () => { return () => {
if (forks === undefined) { if (forks === undefined) {
throw new Error( throw new Error(
'cannot fork the stream after it has been created' 'cannot fork the stream after it has been created'
) )
}
if (forks.length === 0) {
lazyStream().then(
stream => {
// $FlowFixMe
forks.forEach(({ resolve }) => {
const fork: any = stream.pipe(new PassThrough())
fork.task = stream.task
resolve(fork)
})
forks = undefined
},
error => {
// $FlowFixMe
forks.forEach(({ reject }) => {
reject(error)
})
forks = undefined
}
)
}
return new Promise((resolve, reject) => {
// $FlowFixMe
forks.push({ reject, resolve })
})
} }
if (forks.length === 0) { }
lazyStream().then( )
stream => { return () => {
// $FlowFixMe return {
forks.forEach(({ resolve }) => { __proto__: deltaExport,
const fork: any = stream.pipe(new PassThrough()) streams,
fork.task = stream.task
resolve(fork)
})
forks = undefined
},
error => {
// $FlowFixMe
forks.forEach(({ reject }) => {
reject(error)
})
forks = undefined
}
)
}
return new Promise((resolve, reject) => {
// $FlowFixMe
forks.push({ reject, resolve })
})
} }
} }
) })()
return () => {
return {
__proto__: deltaExport,
streams,
}
}
})()
const mergeStart = 0 const mergeStart = 0
const mergeEnd = 0 const mergeEnd = 0