feat(nbd-client/multi): allow partial connexion

This commit is contained in:
Florent Beauchamp 2023-12-08 09:26:42 +00:00 committed by Julien Fontanet
parent 847ad63c09
commit 79967e0eec
3 changed files with 26 additions and 7 deletions

View File

@ -1,7 +1,9 @@
import { asyncEach } from '@vates/async-each'
import { NBD_DEFAULT_BLOCK_SIZE } from './constants.mjs'
import NbdClient from './index.mjs'
import { createLogger } from '@xen-orchestra/log'
const { warn } = createLogger('vates:nbd-client:multi')
export default class MultiNbdClient {
#clients = []
#readAhead
@ -19,8 +21,25 @@ export default class MultiNbdClient {
}
async connect() {
for (const client of this.#clients) {
await client.connect()
const connectedClients = []
for (const clientId in this.#clients) {
const client = this.#clients[clientId]
try {
await client.connect()
connectedClients.push(client)
} catch (err) {
client.disconnect().catch(() => {})
warn(`can't connect to one nbd client`, { err })
}
}
if (connectedClients.length === 0) {
throw new Error(`Fail to connect to any Nbd client`)
}
if (connectedClients.length < this.#clients.length) {
warn(
`incomplete connection by multi Nbd, only ${connectedClients.length} over ${this.#clients.length} expected clients`
)
this.#clients = connectedClients
}
}

View File

@ -41,8 +41,8 @@ export const IncrementalXapi = class IncrementalXapiVmBackupRunner extends Abstr
const deltaExport = await exportIncrementalVm(exportedVm, baseVm, {
fullVdisRequired,
preferNbd: this._settings.preferNbd,
nbdConcurrency: this._settings.nbdConcurrency,
preferNbd: this._settings.preferNbd,
})
// since NBD is network based, if one disk use nbd , all the disk use them
// except the suspended VDI

View File

@ -22,15 +22,15 @@ const SCHEMA_SETTINGS = {
minimum: 0,
optional: true,
},
preferNbd: {
type: 'boolean',
optional: true,
},
nbdConcurrency: {
type: 'number',
minimum: 1,
optional: true,
},
preferNbd: {
type: 'boolean',
optional: true,
},
},
additionalProperties: true,
},