fix(xo-server/metadata-backups): ensure cache reset at the end (#5529)

Introduced by 61c3057060
This commit is contained in:
badrAZ
2021-01-27 14:41:15 +01:00
committed by GitHub
parent 4f7e140737
commit 43933f4089

View File

@@ -476,50 +476,53 @@ export default class metadataBackup {
params.job.xoMetadata = await app.exportConfig()
}
const logsStream = await app.callProxyMethod(proxyId, 'backup.run', params, {
assertType: 'iterator',
})
try {
const logsStream = await app.callProxyMethod(proxyId, 'backup.run', params, {
assertType: 'iterator',
})
const localTaskIds = { __proto__: null }
for await (const log of logsStream) {
const { event, message, taskId } = log
const localTaskIds = { __proto__: null }
for await (const log of logsStream) {
const { event, message, taskId } = log
const common = {
data: log.data,
event: 'task.' + event,
result: log.result,
status: log.status,
}
if (event === 'start') {
const { parentId } = log
if (parentId === undefined) {
// ignore root task (already handled by runJob)
localTaskIds[taskId] = runJobId
} else {
common.parentId = localTaskIds[parentId]
localTaskIds[taskId] = logger.notice(message, common)
const common = {
data: log.data,
event: 'task.' + event,
result: log.result,
status: log.status,
}
} else {
const localTaskId = localTaskIds[taskId]
if (localTaskId === runJobId) {
if (event === 'end') {
if (log.status === 'failure') {
throw log.result
}
return log.result
if (event === 'start') {
const { parentId } = log
if (parentId === undefined) {
// ignore root task (already handled by runJob)
localTaskIds[taskId] = runJobId
} else {
common.parentId = localTaskIds[parentId]
localTaskIds[taskId] = logger.notice(message, common)
}
} else {
common.taskId = localTaskId
logger.notice(message, common)
const localTaskId = localTaskIds[taskId]
if (localTaskId === runJobId) {
if (event === 'end') {
if (log.status === 'failure') {
throw log.result
}
return log.result
}
} else {
common.taskId = localTaskId
logger.notice(message, common)
}
}
}
return
} finally {
remoteIds.forEach(id => {
this._listPoolMetadataBackups(REMOVE_CACHE_ENTRY, id)
this._listXoMetadataBackups(REMOVE_CACHE_ENTRY, id)
})
}
remoteIds.forEach(id => {
this._listPoolMetadataBackups(REMOVE_CACHE_ENTRY, id)
this._listXoMetadataBackups(REMOVE_CACHE_ENTRY, id)
})
return
}
cancelToken.throwIfRequested()