Compare commits

..

1 Commits

Author SHA1 Message Date
Florent Beauchamp
81ae8518df fix(s3): retry upload even on error 400 2022-09-22 16:08:02 +02:00
5 changed files with 3 additions and 90 deletions

View File

@@ -223,7 +223,7 @@ export default class S3Handler extends RemoteHandlerAbstract {
// https://www.backblaze.com/b2/docs/calling.html#error_handling
@decorateWith(pRetry.wrap, {
delays: [100, 200, 500, 1000, 2000],
when: e => e.$metadata?.httpStatusCode === 500,
when: e => [500, 400].includes(e.$metadata?.httpStatusCode),
onRetry(error) {
warn('retrying writing file', {
attemptNumber: this.attemptNumber,

View File

@@ -21,6 +21,7 @@
- [Tasks] Fix the pool filter that did not display tasks even if they existed (PR [#6424](https://github.com/vatesfr/xen-orchestra/pull/6424))
- [Tasks] Fix tasks being displayed for all users (PR [#6422](https://github.com/vatesfr/xen-orchestra/pull/6422))
- [Storage/advanced] Fix the display of VDI to coalesce [#6334](https://xcp-ng.org/forum/topic/6334/coalesce-not-showing-anymore) (PR [#6429](https://github.com/vatesfr/xen-orchestra/pull/6429))
- [Backup/S3] Retry upload when receiving a error 400 from remote (PR [#6433](https://github.com/vatesfr/xen-orchestra/pull/6433))
### Packages to release
@@ -40,6 +41,7 @@
- @vates/fuse-vhd major
- @xen-orchestra/backups minor
- @xen-orchestra/fs patch
- vhd-lib minor
- xo-server-auth-saml patch
- xo-server minor

View File

@@ -1,51 +0,0 @@
'use strict'
const { Bar } = require('cli-progress')
const { getHandler } = require('@xen-orchestra/fs')
const { VhdSynthetic } = require('vhd-lib')
const { Disposable } = require('promise-toolbox')
async function checkOneVhd(vhd) {
await vhd.readBlockAllocationTable()
const nBlocks = vhd.header.maxTableEntries
const bar = new Bar({
format: '[{bar}] {percentage}% | ETA: {eta}s | {value}/{total}',
})
bar.start(nBlocks, 0)
const missings = []
for (let blockId = 0; blockId < nBlocks; ++blockId) {
bar.update(blockId)
try {
if (vhd.containsBlock(blockId)) {
await vhd.readBlock(blockId)
}
} catch (error) {
console.log('missing block ', blockId)
missings.push(blockId)
if (missings.length > 1000) {
throw new Error('Too much missing blocks')
}
}
}
bar.update(nBlocks)
bar.stop()
return missings
}
module.exports = async function merge(args) {
if (args.length < 1 || args.some(_ => _ === '-h' || _ === '--help')) {
return `Usage: ${this.command} <VHD>`
}
const handler = getHandler({ url: 'file:///' })
await Disposable.use(VhdSynthetic.fromVhdChain(handler, args[0]), async syntheticVhd => {
console.log('Check full VHD')
const missings = await checkOneVhd(syntheticVhd)
if (missings.length > 0) {
console.log(`${missings.length} blocks are missing`)
} else {
console.log('VHD data are ok')
}
})
}

View File

@@ -1,34 +0,0 @@
'use strict'
const { Bar } = require('cli-progress')
const { getHandler } = require('@xen-orchestra/fs')
const { mergeVhdChain } = require('vhd-lib/merge')
const { VhdSynthetic } = require('vhd-lib')
const { Disposable } = require('promise-toolbox')
module.exports = async function merge(args) {
if (args.length < 1 || args.some(_ => _ === '-h' || _ === '--help')) {
return `Usage: ${this.command} <VHD>`
}
const handler = getHandler({ url: 'file:///' })
let bar
await Disposable.use(VhdSynthetic.fromVhdChain(handler, args[0]), async syntheticVhd => {
const chainPaths = syntheticVhd.vhds.map(({ _path }) => _path)
console.log({ chainPaths })
await mergeVhdChain(handler, chainPaths, {
onProgress({ done, total }) {
if (bar === undefined) {
bar = new Bar({
format: 'merging [{bar}] {percentage}% | ETA: {eta}s | {value}/{total}',
})
bar.start(total, done)
} else {
bar.update(done)
}
},
})
})
bar.stop()
console.log('you must delete the cache.json.gz file to ensure the changes are visible in XO UI')
}

View File

@@ -55,10 +55,6 @@ const VhdSynthetic = class VhdSynthetic extends VhdAbstract {
return compressionType
}
get vhds() {
return this.#vhds
}
/**
* @param {Array<VhdAbstract>} vhds the chain of Vhds used to compute this Vhd, from the deepest child (in position 0), to the root (in the last position)
* only the last one can have any type. Other must have type DISK_TYPES.DIFFERENCING (delta)