Skip to content

Commit

Permalink
Feat(fs): add more error log during remote test
Browse files Browse the repository at this point in the history
  • Loading branch information
fbeauchamp committed May 16, 2022
1 parent 819127d commit 16cd438
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
1 change: 1 addition & 0 deletions @xen-orchestra/fs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"promise-toolbox": "^0.21.0",
"proper-lockfile": "^4.1.2",
"readable-stream": "^3.0.6",
"serialize-error": "^8.0.0",
"through2": "^4.0.2",
"xo-remote-parser": "^0.8.0"
},
Expand Down
8 changes: 7 additions & 1 deletion @xen-orchestra/fs/src/abstract.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import asyncMapSettled from '@xen-orchestra/async-map/legacy'
import getStream from 'get-stream'
import { coalesceCalls } from '@vates/coalesce-calls'
import { createLogger } from '@xen-orchestra/log'
import { fromCallback, fromEvent, ignoreErrors, timeout } from 'promise-toolbox'
import { limitConcurrency } from 'limit-concurrency-decorator'
import { parse } from 'xo-remote-parser'
import { pipeline } from 'stream'
import { randomBytes } from 'crypto'
import { serializeError } from 'serialize-error'
import { synchronized } from 'decorator-synchronized'

import { basename, dirname, normalize as normalizePath } from './_path'
import { createChecksumStream, validChecksumOfReadStream } from './checksum'

const { warn } = createLogger('@xen-orchestra:fs')

const checksumFile = file => file + '.checksum'
const computeRate = (hrtime, size) => {
const seconds = hrtime[0] + hrtime[1] / 1e9
Expand Down Expand Up @@ -357,11 +361,13 @@ export default class RemoteHandlerAbstract {
readRate: computeRate(readDuration, SIZE),
}
} catch (error) {
warn(`error while testing the remote at step ${step}`, { error })
return {
success: false,
step,
file: testFileName,
error: error.message || String(error),
// ensure even non serializeable errors are displayed
error: error.message || JSON.stringify(serializeError(error)),
}
} finally {
ignoreErrors.call(this._unlink(testFileName))
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

> Users must be able to say: “I had this issue, happy to know it's fixed”
- [Remote] show more details when remote testing fails (PR [#6216](https://github.com/vatesfr/xen-orchestra/pull/6216))

### Packages to release

> Packages will be released in the order they are here, therefore, they should
Expand All @@ -35,6 +37,8 @@
<!--packages-start-->

- @xen-orchestra/fs
- @xen-orchestra/mixins patch
- vhd-lib patch
- vhd-cli patch
- @xen-orchestra/backups patch
Expand Down
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16377,6 +16377,13 @@ send@0.18.0:
range-parser "~1.2.1"
statuses "2.0.1"

serialize-error@^8.0.0:
version "8.1.0"
resolved "https://registry.yarnpkg.com/serialize-error/-/serialize-error-8.1.0.tgz#3a069970c712f78634942ddd50fbbc0eaebe2f67"
integrity sha512-3NnuWfM6vBYoy5gZFvHiYsVbafvI9vZv/+jlIigFn4oP4zjNPK3LhcY0xSCgeb1a5L8jO71Mit9LlNoi2UfDDQ==
dependencies:
type-fest "^0.20.2"

serialize-javascript@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-3.1.0.tgz#8bf3a9170712664ef2561b44b691eafe399214ea"
Expand Down

0 comments on commit 16cd438

Please sign in to comment.