feat(backups/cleanVm): invalidate cache on backup deletion (#6402)
This commit is contained in:
parent
6002a497fe
commit
5a54f7f302
@ -458,8 +458,11 @@ class RemoteAdapter {
|
|||||||
return backupsByPool
|
return backupsByPool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async _invalidateVmBackupListCacheDir(vmDir) {
|
||||||
|
await this.handler.unlink(`${vmDir}/cache.json.gz`)
|
||||||
|
}
|
||||||
async invalidateVmBackupListCache(vmUuid) {
|
async invalidateVmBackupListCache(vmUuid) {
|
||||||
await this.handler.unlink(`${BACKUP_DIR}/${vmUuid}/cache.json.gz`)
|
await this._invalidateVmBackupListCacheDir(`${BACKUP_DIR}/${vmUuid}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
async #getCachabledDataListVmBackups(dir) {
|
async #getCachabledDataListVmBackups(dir) {
|
||||||
|
@ -302,6 +302,7 @@ exports.cleanVm = async function cleanVm(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const jsons = new Set()
|
const jsons = new Set()
|
||||||
|
let mustInvalidateCache = false
|
||||||
const xvas = new Set()
|
const xvas = new Set()
|
||||||
const xvaSums = []
|
const xvaSums = []
|
||||||
const entries = await handler.list(vmDir, {
|
const entries = await handler.list(vmDir, {
|
||||||
@ -350,6 +351,7 @@ exports.cleanVm = async function cleanVm(
|
|||||||
if (remove) {
|
if (remove) {
|
||||||
logInfo('deleting incomplete backup', { path: json })
|
logInfo('deleting incomplete backup', { path: json })
|
||||||
jsons.delete(json)
|
jsons.delete(json)
|
||||||
|
mustInvalidateCache = true
|
||||||
await handler.unlink(json)
|
await handler.unlink(json)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -372,6 +374,7 @@ exports.cleanVm = async function cleanVm(
|
|||||||
logWarn('some VHDs linked to the backup are missing', { backup: json, missingVhds })
|
logWarn('some VHDs linked to the backup are missing', { backup: json, missingVhds })
|
||||||
if (remove) {
|
if (remove) {
|
||||||
logInfo('deleting incomplete backup', { path: json })
|
logInfo('deleting incomplete backup', { path: json })
|
||||||
|
mustInvalidateCache = true
|
||||||
jsons.delete(json)
|
jsons.delete(json)
|
||||||
await handler.unlink(json)
|
await handler.unlink(json)
|
||||||
}
|
}
|
||||||
@ -528,6 +531,12 @@ exports.cleanVm = async function cleanVm(
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// purge cache if a metadata file has been deleted
|
||||||
|
if (mustInvalidateCache) {
|
||||||
|
// cleanvm is always invoked as a method of RemoteAdapter
|
||||||
|
await this._invalidateVmBackupListCacheDir(vmDir)
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
// boolean whether some VHDs were merged (or should be merged)
|
// boolean whether some VHDs were merged (or should be merged)
|
||||||
merge: toMerge.length !== 0,
|
merge: toMerge.length !== 0,
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
<!--packages-start-->
|
<!--packages-start-->
|
||||||
|
|
||||||
|
- @xen-orchestra/backups minor
|
||||||
- xo-server-auth-saml patch
|
- xo-server-auth-saml patch
|
||||||
- xo-web patch
|
- xo-web patch
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user