Skip to content

Commit

Permalink
fix isVhdDifferencing id
Browse files Browse the repository at this point in the history
  • Loading branch information
stephane-m-dev committed Dec 20, 2024
1 parent 1baef57 commit 4514141
Show file tree
Hide file tree
Showing 3 changed files with 690 additions and 26 deletions.
30 changes: 5 additions & 25 deletions @xen-orchestra/backups/_cleanVm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -569,39 +569,19 @@ export async function cleanVm(
// systematically update size and differentials after a merge

// @todo : after 2024-04-01 remove the fixmetadata options since the size computation is fixed
console.log({mergedSize, fixMetadata, fileSystemSize, size})
console.log({/* metadata, */ /* snapshot_time: metadata.vdis, */ vdis: metadata.vdis, isVhdDifferencing: metadata.isVhdDifferencing, parent: metadata.vmSnapshot.parent, mergedSize, fixMetadata, fileSystemSize, size})

Check failure on line 572 in @xen-orchestra/backups/_cleanVm.mjs

View workflow job for this annotation

GitHub Actions / CI

Unexpected console statement
if (mergedSize || (fixMetadata && fileSystemSize !== size)) {
metadata.size = mergedSize ?? fileSystemSize ?? size

if (mergedSize) {
// Dynamically rebuild the isVhdDifferencing metadata
// all disks are now key disk
metadata.isVhdDifferencing = {}

const vdiChains = {} // Map of VDI IDs to their chain of VHDs

// Build VDI chains from metadata
for (const id of Object.values(metadata.vdis ?? {})) {
const vhdPath = `${id}.vhd`

// Check if this VHD has a parent
const parent = metadata.parent?.[vhdPath]
if (parent) {
vdiChains[id] = vdiChains[id] || []
vdiChains[id].push({ vhd: vhdPath, isDifferencing: true })
} else {
// No parent means it's a key disk
vdiChains[id] = [{ vhd: vhdPath, isDifferencing: false }]
}
}

// Update the metadata for isVhdDifferencing
for (const chain of Object.values(vdiChains)) {
for (const { vhd, isDifferencing } of chain) {
metadata.isVhdDifferencing[vhd] = isDifferencing
}
for (const id of Object.keys(metadata.vdis ?? {})) {
console.log({id})

Check failure on line 581 in @xen-orchestra/backups/_cleanVm.mjs

View workflow job for this annotation

GitHub Actions / CI

Unexpected console statement
metadata.isVhdDifferencing[`${id}.vhd`] = false
}
}

mustRegenerateCache = true
try {
await handler.writeFile(metadataPath, JSON.stringify(metadata), { flags: 'w' })
Expand Down
Loading

0 comments on commit 4514141

Please sign in to comment.