@xen-orchestra/backups 0.29.4 → 0.29.5

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/Backup.js CHANGED
@@ -38,7 +38,7 @@ const DEFAULT_VM_SETTINGS = {
38
38
  fullInterval: 0,
39
39
  healthCheckSr: undefined,
40
40
  healthCheckVmsWithTags: [],
41
- maxMergedDeltasPerRun: 2,
41
+ maxMergedDeltasPerRun: Infinity,
42
42
  offlineBackup: false,
43
43
  offlineSnapshot: false,
44
44
  snapshotRetention: 0,
package/RemoteAdapter.js CHANGED
@@ -28,6 +28,7 @@ const { isMetadataFile } = require('./_backupType.js')
28
28
  const { isValidXva } = require('./_isValidXva.js')
29
29
  const { listPartitions, LVM_PARTITION_TYPE } = require('./_listPartitions.js')
30
30
  const { lvs, pvs } = require('./_lvm.js')
31
+ const { watchStreamSize } = require('./_watchStreamSize')
31
32
  // @todo : this import is marked extraneous , sould be fixed when lib is published
32
33
  const { mount } = require('@vates/fuse-vhd')
33
34
  const { asyncEach } = require('@vates/async-each')
@@ -661,7 +662,7 @@ class RemoteAdapter {
661
662
  const handler = this._handler
662
663
  if (this.#useVhdDirectory()) {
663
664
  const dataPath = `${dirname(path)}/data/${uuidv4()}.vhd`
664
- await createVhdDirectoryFromStream(handler, dataPath, input, {
665
+ const size = await createVhdDirectoryFromStream(handler, dataPath, input, {
665
666
  concurrency: writeBlockConcurrency,
666
667
  compression: this.#getCompressionType(),
667
668
  async validator() {
@@ -671,12 +672,14 @@ class RemoteAdapter {
671
672
  nbdClient,
672
673
  })
673
674
  await VhdAbstract.createAlias(handler, path, dataPath)
675
+ return size
674
676
  } else {
675
- await this.outputStream(path, input, { checksum, validator })
677
+ return this.outputStream(path, input, { checksum, validator })
676
678
  }
677
679
  }
678
680
 
679
681
  async outputStream(path, input, { checksum = true, validator = noop } = {}) {
682
+ const container = watchStreamSize(input)
680
683
  await this._handler.outputStream(path, input, {
681
684
  checksum,
682
685
  dirMode: this._dirMode,
@@ -685,6 +688,7 @@ class RemoteAdapter {
685
688
  return validator.apply(this, arguments)
686
689
  },
687
690
  })
691
+ return container.size
688
692
  }
689
693
 
690
694
  // open the hierarchy of ancestors until we find a full one
package/Task.js CHANGED
@@ -100,7 +100,7 @@ class Task {
100
100
  * In case of error, the task will be failed.
101
101
  *
102
102
  * @typedef Result
103
- * @param {() => Result)} fn
103
+ * @param {() => Result} fn
104
104
  * @param {boolean} last - Whether the task should succeed if there is no error
105
105
  * @returns Result
106
106
  */
package/_backupWorker.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- require('@xen-orchestra/log/configure.js').catchGlobalErrors(
3
+ require('@xen-orchestra/log/configure').catchGlobalErrors(
4
4
  require('@xen-orchestra/log').createLogger('xo:backups:worker')
5
5
  )
6
6
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  'use strict'
6
6
 
7
- const { catchGlobalErrors } = require('@xen-orchestra/log/configure.js')
7
+ const { catchGlobalErrors } = require('@xen-orchestra/log/configure')
8
8
  const { createLogger } = require('@xen-orchestra/log')
9
9
  const { getSyncedHandler } = require('@xen-orchestra/fs')
10
10
  const { join } = require('path')
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.29.4",
11
+ "version": "0.29.5",
12
12
  "engines": {
13
13
  "node": ">=14.6"
14
14
  },
@@ -21,33 +21,33 @@
21
21
  "@vates/cached-dns.lookup": "^1.0.0",
22
22
  "@vates/compose": "^2.1.0",
23
23
  "@vates/decorate-with": "^2.0.0",
24
- "@vates/disposable": "^0.1.3",
24
+ "@vates/disposable": "^0.1.4",
25
25
  "@vates/fuse-vhd": "^1.0.0",
26
26
  "@vates/nbd-client": "*",
27
27
  "@vates/parse-duration": "^0.1.1",
28
28
  "@xen-orchestra/async-map": "^0.1.2",
29
- "@xen-orchestra/fs": "^3.3.0",
30
- "@xen-orchestra/log": "^0.5.0",
29
+ "@xen-orchestra/fs": "^3.3.1",
30
+ "@xen-orchestra/log": "^0.6.0",
31
31
  "@xen-orchestra/template": "^0.1.0",
32
32
  "compare-versions": "^5.0.1",
33
33
  "d3-time-format": "^3.0.0",
34
34
  "decorator-synchronized": "^0.6.0",
35
35
  "end-of-stream": "^1.4.4",
36
- "fs-extra": "^10.0.0",
36
+ "fs-extra": "^11.1.0",
37
37
  "golike-defer": "^0.5.1",
38
38
  "limit-concurrency-decorator": "^0.5.0",
39
39
  "lodash": "^4.17.20",
40
40
  "node-zone": "^0.4.0",
41
- "parse-pairs": "^1.1.0",
41
+ "parse-pairs": "^2.0.0",
42
42
  "promise-toolbox": "^0.21.0",
43
43
  "proper-lockfile": "^4.1.2",
44
44
  "uuid": "^9.0.0",
45
- "vhd-lib": "^4.2.0",
45
+ "vhd-lib": "^4.2.1",
46
46
  "yazl": "^2.5.1"
47
47
  },
48
48
  "devDependencies": {
49
- "rimraf": "^3.0.2",
50
- "sinon": "^14.0.1",
49
+ "rimraf": "^4.1.1",
50
+ "sinon": "^15.0.1",
51
51
  "test": "^3.2.1",
52
52
  "tmp": "^0.2.1"
53
53
  },
@@ -20,7 +20,7 @@ const { packUuid } = require('./_packUuid.js')
20
20
  const { Disposable } = require('promise-toolbox')
21
21
  const NbdClient = require('@vates/nbd-client')
22
22
 
23
- const { debug, warn } = createLogger('xo:backups:DeltaBackupWriter')
23
+ const { debug, warn, info } = createLogger('xo:backups:DeltaBackupWriter')
24
24
 
25
25
  exports.DeltaBackupWriter = class DeltaBackupWriter extends MixinBackupWriter(AbstractDeltaWriter) {
26
26
  async checkBaseVdis(baseUuidToSrcVdi) {
@@ -133,7 +133,7 @@ exports.DeltaBackupWriter = class DeltaBackupWriter extends MixinBackupWriter(Ab
133
133
  }
134
134
  }
135
135
 
136
- async _transfer({ timestamp, deltaExport, sizeContainers }) {
136
+ async _transfer({ timestamp, deltaExport }) {
137
137
  const adapter = this._adapter
138
138
  const backup = this._backup
139
139
 
@@ -172,6 +172,7 @@ exports.DeltaBackupWriter = class DeltaBackupWriter extends MixinBackupWriter(Ab
172
172
  }
173
173
 
174
174
  const { size } = await Task.run({ name: 'transfer' }, async () => {
175
+ let transferSize = 0
175
176
  await Promise.all(
176
177
  map(deltaExport.vdis, async (vdi, id) => {
177
178
  const path = `${this._vmBackupDir}/${vhds[id]}`
@@ -200,21 +201,25 @@ exports.DeltaBackupWriter = class DeltaBackupWriter extends MixinBackupWriter(Ab
200
201
  const vdiRef = vm.$xapi.getObject(vdi.uuid).$ref
201
202
 
202
203
  let nbdClient
203
- if (!this._backup.config.useNbd) {
204
+ if (this._backup.config.useNbd) {
205
+ debug('useNbd is enabled', { vdi: id, path })
204
206
  // get nbd if possible
205
207
  try {
206
208
  // this will always take the first host in the list
207
209
  const [nbdInfo] = await vm.$xapi.call('VDI.get_nbd_info', vdiRef)
210
+ debug('got NBD info', { nbdInfo, vdi: id, path })
208
211
  nbdClient = new NbdClient(nbdInfo)
209
212
  await nbdClient.connect()
210
- debug(`got nbd connection `, { vdi: vdi.uuid })
213
+ info('NBD client ready', { vdi: id, path })
211
214
  } catch (error) {
212
215
  nbdClient = undefined
213
- debug(`can't connect to nbd server or no server available`, { error })
216
+ warn('error connecting to NBD server', { error, vdi: id, path })
214
217
  }
218
+ } else {
219
+ debug('useNbd is disabled', { vdi: id, path })
215
220
  }
216
221
 
217
- await adapter.writeVhd(path, deltaExport.streams[`${id}.vhd`], {
222
+ transferSize += await adapter.writeVhd(path, deltaExport.streams[`${id}.vhd`], {
218
223
  // no checksum for VHDs, because they will be invalidated by
219
224
  // merges and chainings
220
225
  checksum: false,
@@ -235,9 +240,7 @@ exports.DeltaBackupWriter = class DeltaBackupWriter extends MixinBackupWriter(Ab
235
240
  })
236
241
  })
237
242
  )
238
- return {
239
- size: Object.values(sizeContainers).reduce((sum, { size }) => sum + size, 0),
240
- }
243
+ return { size: transferSize }
241
244
  })
242
245
  metadataContent.size = size
243
246
  this._metadataFileName = await adapter.writeVmBackupMetadata(vm.uuid, metadataContent)