@xen-orchestra/backups 0.43.0 → 0.43.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/RemoteAdapter.mjs CHANGED
@@ -681,11 +681,13 @@ export class RemoteAdapter {
681
681
  }
682
682
  }
683
683
 
684
- async outputStream(path, input, { checksum = true, validator = noop } = {}) {
684
+ async outputStream(path, input, { checksum = true, maxStreamLength, streamLength, validator = noop } = {}) {
685
685
  const container = watchStreamSize(input)
686
686
  await this._handler.outputStream(path, input, {
687
687
  checksum,
688
688
  dirMode: this._dirMode,
689
+ maxStreamLength,
690
+ streamLength,
689
691
  async validator() {
690
692
  await input.task
691
693
  return validator.apply(this, arguments)
@@ -29,6 +29,8 @@ export const FullRemote = class FullRemoteVmBackupRunner extends AbstractRemote
29
29
  writer =>
30
30
  writer.run({
31
31
  stream: forkStreamUnpipe(stream),
32
+ // stream will be forked and transformed, it's not safe to attach additionnal properties to it
33
+ streamLength: stream.length,
32
34
  timestamp: metadata.timestamp,
33
35
  vm: metadata.vm,
34
36
  vmSnapshot: metadata.vmSnapshot,
@@ -35,13 +35,25 @@ export const FullXapi = class FullXapiVmBackupRunner extends AbstractXapi {
35
35
  useSnapshot: false,
36
36
  })
37
37
  )
38
+
39
+ const vdis = await exportedVm.$getDisks()
40
+ let maxStreamLength = 1024 * 1024 // Ovf file and tar headers are a few KB, let's stay safe
41
+ for (const vdiRef of vdis) {
42
+ const vdi = await this._xapi.getRecord('VDI', vdiRef)
43
+
44
+ // the size a of fully allocated vdi will be virtual_size exaclty, it's a gross over evaluation
45
+ // of the real stream size in general, since a disk is never completly full
46
+ // vdi.physical_size seems to underevaluate a lot the real disk usage of a VDI, as of 2023-10-30
47
+ maxStreamLength += vdi.virtual_size
48
+ }
49
+
38
50
  const sizeContainer = watchStreamSize(stream)
39
51
 
40
52
  const timestamp = Date.now()
41
-
42
53
  await this._callWriters(
43
54
  writer =>
44
55
  writer.run({
56
+ maxStreamLength,
45
57
  sizeContainer,
46
58
  stream: forkStreamUnpipe(stream),
47
59
  timestamp,
@@ -24,7 +24,7 @@ export class FullRemoteWriter extends MixinRemoteWriter(AbstractFullWriter) {
24
24
  )
25
25
  }
26
26
 
27
- async _run({ timestamp, sizeContainer, stream, vm, vmSnapshot }) {
27
+ async _run({ maxStreamLength, timestamp, sizeContainer, stream, streamLength, vm, vmSnapshot }) {
28
28
  const settings = this._settings
29
29
  const job = this._job
30
30
  const scheduleId = this._scheduleId
@@ -65,6 +65,8 @@ export class FullRemoteWriter extends MixinRemoteWriter(AbstractFullWriter) {
65
65
 
66
66
  await Task.run({ name: 'transfer' }, async () => {
67
67
  await adapter.outputStream(dataFilename, stream, {
68
+ maxStreamLength,
69
+ streamLength,
68
70
  validator: tmpPath => adapter.isValidXva(tmpPath),
69
71
  })
70
72
  return { size: sizeContainer.size }
@@ -1,9 +1,9 @@
1
1
  import { AbstractWriter } from './_AbstractWriter.mjs'
2
2
 
3
3
  export class AbstractFullWriter extends AbstractWriter {
4
- async run({ timestamp, sizeContainer, stream, vm, vmSnapshot }) {
4
+ async run({ maxStreamLength, timestamp, sizeContainer, stream, streamLength, vm, vmSnapshot }) {
5
5
  try {
6
- return await this._run({ timestamp, sizeContainer, stream, vm, vmSnapshot })
6
+ return await this._run({ maxStreamLength, timestamp, sizeContainer, stream, streamLength, vm, vmSnapshot })
7
7
  } finally {
8
8
  // ensure stream is properly closed
9
9
  stream.destroy()
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "type": "git",
9
9
  "url": "https://github.com/vatesfr/xen-orchestra.git"
10
10
  },
11
- "version": "0.43.0",
11
+ "version": "0.43.2",
12
12
  "engines": {
13
13
  "node": ">=14.18"
14
14
  },
@@ -28,7 +28,7 @@
28
28
  "@vates/nbd-client": "^2.0.0",
29
29
  "@vates/parse-duration": "^0.1.1",
30
30
  "@xen-orchestra/async-map": "^0.1.2",
31
- "@xen-orchestra/fs": "^4.1.0",
31
+ "@xen-orchestra/fs": "^4.1.1",
32
32
  "@xen-orchestra/log": "^0.6.0",
33
33
  "@xen-orchestra/template": "^0.1.0",
34
34
  "app-conf": "^2.3.0",
@@ -56,7 +56,7 @@
56
56
  "tmp": "^0.2.1"
57
57
  },
58
58
  "peerDependencies": {
59
- "@xen-orchestra/xapi": "^3.2.0"
59
+ "@xen-orchestra/xapi": "^3.3.0"
60
60
  },
61
61
  "license": "AGPL-3.0-or-later",
62
62
  "author": {