fix(vhd-lib/merge): dont fail on invalid state file
Fixes zammad#4227
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
- [Tables/actions] Fix collapsed actions being clickable despite being disabled (PR [#6023](https://github.com/vatesfr/xen-orchestra/pull/6023))
|
||||
- [Continuous Replication] Fix `could not find the base VM`
|
||||
- [Backup/Smart mode] Always ignore replicated VMs created by the current job
|
||||
- [Backup] Fix `Unexpected end of JSON input` during merge step
|
||||
|
||||
### Packages to release
|
||||
|
||||
@@ -36,6 +37,7 @@
|
||||
>
|
||||
> In case of conflict, the highest (lowest in previous list) `$version` wins.
|
||||
|
||||
- vhd-lib patch
|
||||
- @xen-orchestra/backups minor
|
||||
- @xen-orchestra/proxy minor
|
||||
- xo-server minor
|
||||
|
||||
@@ -25,12 +25,23 @@ export default limitConcurrency(2)(async function merge(
|
||||
const mergeStatePath = dirname(parentPath) + '/' + '.' + basename(parentPath) + '.merge.json'
|
||||
|
||||
return await Disposable.use(async function* () {
|
||||
let mergeState = await parentHandler.readFile(mergeStatePath).catch(error => {
|
||||
if (error.code !== 'ENOENT') {
|
||||
throw error
|
||||
}
|
||||
// no merge state in case of missing file
|
||||
})
|
||||
let mergeState = await parentHandler
|
||||
.readFile(mergeStatePath)
|
||||
.then(content => {
|
||||
const state = JSON.parse(content)
|
||||
|
||||
// ensure the correct merge will be continued
|
||||
assert.strictEqual(parentVhd.header.checksum, state.parent.header)
|
||||
assert.strictEqual(childVhd.header.checksum, state.child.header)
|
||||
|
||||
return state
|
||||
})
|
||||
.catch(error => {
|
||||
if (error.code !== 'ENOENT') {
|
||||
warn('problem while checking the merge state', { error })
|
||||
}
|
||||
})
|
||||
|
||||
// during merging, the end footer of the parent can be overwritten by new blocks
|
||||
// we should use it as a way to check vhd health
|
||||
const parentVhd = yield openVhd(parentHandler, parentPath, {
|
||||
@@ -38,13 +49,7 @@ export default limitConcurrency(2)(async function merge(
|
||||
checkSecondFooter: mergeState === undefined,
|
||||
})
|
||||
const childVhd = yield openVhd(childHandler, childPath)
|
||||
if (mergeState !== undefined) {
|
||||
mergeState = JSON.parse(mergeState)
|
||||
|
||||
// ensure the correct merge will be continued
|
||||
assert.strictEqual(parentVhd.header.checksum, mergeState.parent.header)
|
||||
assert.strictEqual(childVhd.header.checksum, mergeState.child.header)
|
||||
} else {
|
||||
if (mergeState === undefined) {
|
||||
assert.strictEqual(childVhd.header.blockSize, parentVhd.header.blockSize)
|
||||
|
||||
const parentDiskType = parentVhd.footer.diskType
|
||||
|
||||
Reference in New Issue
Block a user