fix(xo-server/backup): restore VM from proxied remote (#6179)

This commit is contained in:
Pierre Donias
2022-04-06 16:32:43 +02:00
committed by GitHub
parent f6e1b95711
commit d331cd934a
3 changed files with 29 additions and 14 deletions

View File

@@ -13,6 +13,7 @@
- [Plugins] Automatically configure plugins when a configuration file is imported (PR [#6171](https://github.com/vatesfr/xen-orchestra/pull/6171))
- [VMDK Export] Fix `VBOX_E_FILE_ERROR (0x80BB0004)` when importing in VirtualBox (PR [#6163](https://github.com/vatesfr/xen-orchestra/pull/6163))
- [Backup] Fix "Cannot read properties of undefined" error when restoring from a proxied remote (PR [#6179](https://github.com/vatesfr/xen-orchestra/pull/6179))
### Packages to release

View File

@@ -1,7 +1,28 @@
function forwardResult(log) {
if (log.status === 'failure') {
throw log.result
}
return log.result
}
// it records logs generated by `@xen-orchestra/backups/Task#run`
export const handleBackupLog = (log, { logger, localTaskIds, runJobId, handleRootTaskId }) => {
export const handleBackupLog = (log, { logger, localTaskIds, rootTaskId, runJobId = rootTaskId, handleRootTaskId }) => {
const { event, message, taskId } = log
// If `runJobId` is defined, it means that the root task is already handled by `runJob`
if (runJobId !== undefined) {
// Ignore the start of the root task
if (event === 'start' && log.parentId === undefined) {
localTaskIds[taskId] = runJobId
return
}
// Return/throw the result of the root task
if (event === 'end' && localTaskIds[taskId] === runJobId) {
return forwardResult(log)
}
}
const common = {
data: log.data,
event: 'task.' + event,
@@ -9,19 +30,6 @@ export const handleBackupLog = (log, { logger, localTaskIds, runJobId, handleRoo
status: log.status,
}
// ignore root task (already handled by runJob)
if (runJobId !== undefined) {
if (event === 'start' && log.parentId === undefined) {
localTaskIds[taskId] = runJobId
return
} else if (event === 'end' && localTaskIds[taskId] === runJobId) {
if (log.status === 'failure') {
throw log.result
}
return log.result
}
}
if (event === 'start') {
const { parentId } = log
if (parentId === undefined) {
@@ -34,4 +42,9 @@ export const handleBackupLog = (log, { logger, localTaskIds, runJobId, handleRoo
common.taskId = localTaskIds[taskId]
logger.notice(message, common)
}
// special case for the end of the root task: return/throw the result
if (event === 'end' && localTaskIds[taskId] === rootTaskId) {
return forwardResult(log)
}
}

View File

@@ -423,6 +423,7 @@ export default class BackupNg {
result = handleBackupLog(log, {
logger,
localTaskIds,
rootTaskId,
handleRootTaskId: id => {
this._runningRestores.add(id)
rootTaskId = id