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 30, 2022
1 parent 0e49150 commit 388b521
Show file tree
Hide file tree
Showing 4 changed files with 16 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
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [S3] Fix S3 remote with empty directory not showing anything to restore (PR [#6218](https://github.com/vatesfr/xen-orchestra/pull/6218))
- [S3] remote fom did not save the `https` and `allow unatuhorized`during remote creation (PR [#6219](https://github.com/vatesfr/xen-orchestra/pull/6219))
- [VM/advanced] Fix various errors when adding ACLs [#6213](https://github.com/vatesfr/xen-orchestra/issues/6213) (PR [#6230](https://github.com/vatesfr/xen-orchestra/pull/6230))
- [Remote] show more details when remote testing fails (PR [#6216](https://github.com/vatesfr/xen-orchestra/pull/6216))

### Packages to release

Expand Down
7 changes: 7 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16389,6 +16389,13 @@ [email protected]:
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 388b521

Please sign in to comment.