Skip to content

Commit

Permalink
fix(Backups/cleanVm): handle missing vhd file of an alias (#8053)
Browse files Browse the repository at this point in the history
  • Loading branch information
fbeauchamp authored Oct 24, 2024
1 parent ba3753a commit fa9f865
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
18 changes: 15 additions & 3 deletions @xen-orchestra/backups/_cleanVm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,19 @@ export async function checkAliases(
) {
const aliasFound = []
for (const alias of aliasPaths) {
const target = await resolveVhdAlias(handler, alias)
let target
try {
target = await resolveVhdAlias(handler, alias)
} catch (err) {
if (err.code === 'ENOENT') {
logWarn('missing target of alias', { alias })
if (remove) {
logInfo('removing alias and non VHD target', { alias, target })
await handler.unlink(target)
await handler.unlink(alias)
}
}
}

if (!isVhdFile(target)) {
logWarn('alias references non VHD target', { alias, target })
Expand Down Expand Up @@ -201,9 +213,9 @@ export async function cleanVm(

// remove broken VHDs
await asyncMap(vhds, async path => {
if(removeTmp && basename(path)[0] === '.'){
if (removeTmp && basename(path)[0] === '.') {
logInfo('deleting temporary VHD', { path })
return VhdAbstract.unlink(handler, path)
return VhdAbstract.unlink(handler, path)
}
try {
await Disposable.use(openVhd(handler, path, { checkSecondFooter: !interruptedVhds.has(path) }), vhd => {
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- [Tags] Ability to remove blank tags from VMs/hosts/pools (PR [#8058](https://github.com/vatesfr/xen-orchestra/pull/8058))
- [Plugin/audit] Do not log call to `host.isPubKeyTooShort` [Forum#84464](https://xcp-ng.org/forum/post/84464)
- [Backup] fix VDI_INCOMPATIBLE_TYPE error (PR [#8043](https://github.com/vatesfr/xen-orchestra/pull/8043))
- [Backups] Fix handling of alias without vhd in cleanVm (PR [#8053](https://github.com/vatesfr/xen-orchestra/pull/8053))

### Packages to release

Expand Down

0 comments on commit fa9f865

Please sign in to comment.