Compare commits

..

47 Commits

Author SHA1 Message Date
Sylvère A.
905d9db85b chore(CHANGELOG): update next 2026-11-24 16:46:52 +01:00
Sylvère A.
9576b6e7e7 feat(xo-web): 5.209.0 2026-11-24 16:26:25 +01:00
Sylvère A.
891ce89817 feat(xo-server-web-hooks): 0.4.1 2026-11-24 16:26:16 +01:00
Sylvère A.
34c8aede24 feat(xo-server-usage-report): 0.11.2 2026-11-24 16:26:11 +01:00
Sylvère A.
ce5a2cfa2a feat(xo-server-transport-nagios): 1.0.4 2026-11-24 16:26:05 +01:00
Sylvère A.
95452a9d42 feat(xo-server-sdn-controller): 1.7.0 2026-11-24 16:25:59 +01:00
Sylvère A.
5af68c643b feat(xo-server-perf-alert): 1.1.3 2026-11-24 16:25:54 +01:00
Sylvère A.
0f268ce3dd feat(xo-server-openmetrics): 1.9.4 2026-11-24 16:25:47 +01:00
Sylvère A.
dcc578dc8d feat(xo-server-netbox): 1.14.1 2026-11-24 16:25:42 +01:00
Sylvère A.
0ae26cfebb feat(xo-server-load-balancer): 0.14.1 2026-11-24 16:25:36 +01:00
Sylvère A.
0d75531890 feat(xo-server-ipmi-sensors): 2.1.2 2026-11-24 16:25:30 +01:00
Sylvère A.
166a49ab26 feat(xo-server-backup-reports): 1.7.2 2026-11-24 16:25:22 +01:00
Sylvère A.
1c2717a7af feat(xo-server-auth-ldap): 0.10.13 2026-11-24 16:25:13 +01:00
Sylvère A.
0ea8c18fd0 feat(xo-server-audit): 0.16.0 2026-11-24 16:25:05 +01:00
Sylvère A.
b654011208 feat(xo-server): 5.214.0 2026-11-24 16:24:58 +01:00
Sylvère A.
d26add5ff9 feat(xapi-explore-sr): 0.4.9 2026-11-24 16:24:51 +01:00
Sylvère A.
b69133c2b8 feat(@xen-orchestra/web): 0.66.0 2026-11-24 16:24:42 +01:00
Sylvère A.
98dd59bbb4 feat(@xen-orchestra/rest-api): 0.42.0 2026-11-24 16:24:19 +01:00
Sylvère A.
288abdd02a feat(@xen-orchestra/qa-test): 1.5.0 2026-11-24 16:23:55 +01:00
Sylvère A.
7a06c6ccee feat(@xen-orchestra/vmware-explorer): 1.3.0 2026-11-24 16:23:39 +01:00
Sylvère A.
2e5ac8a282 feat(@xen-orchestra/proxy): 0.35.0 2026-11-24 16:23:08 +01:00
Sylvère A.
12b97f3060 feat(@xen-orchestra/mixins): 0.24.0 2026-11-24 16:22:55 +01:00
Sylvère A.
09737a54eb feat(@xen-orchestra/mcp): 1.4.4 2026-11-24 16:22:40 +01:00
Sylvère A.
7055f1654c feat(@xen-orchestra/web-core): 0.66.0 2026-11-24 16:22:17 +01:00
Sylvère A.
ab38f89b5b feat(@xen-orchestra/immutable-backups): 3.0.10 2026-11-24 16:22:02 +01:00
Sylvère A.
15a4caed96 feat(@xen-orchestra/disk-cli): 2.2.6 2026-11-24 16:21:52 +01:00
Sylvère A.
e8169b08c9 feat(@xen-orchestra/cr-seed-cli): 1.0.4 2026-11-24 16:21:41 +01:00
Sylvère A.
96eac01241 feat(@xen-orchestra/backups-cli): 1.1.19 2026-11-24 16:21:32 +01:00
Sylvère A.
f718219c98 feat(@xen-orchestra/backups): 1.0.0 2026-11-24 16:21:01 +01:00
Sylvère A.
e050216be5 feat(@xen-orchestra/xapi): 10.0.0 2026-11-24 16:20:18 +01:00
Sylvère A.
2a308c2304 feat(@xen-orchestra/backup-archive): 1.2.1 2026-11-24 16:19:23 +01:00
Sylvère A.
c9edc6ee55 feat(@xen-orchestra/autopilot-docking): 0.1.0 2026-11-24 16:19:10 +01:00
Sylvère A.
9c8aad12f1 feat(@xen-orchestra/audit-core): 0.4.1 2026-11-24 16:18:56 +01:00
Sylvère A.
a374b5afd1 feat(@xen-orchestra/acl): 1.9.0 2026-11-24 16:18:15 +01:00
Sylvère A.
e6b3a96151 feat(@vates/types): 3.0.0 2026-11-24 16:15:14 +01:00
Sylvère A.
944fa4d238 feat(@vates/syslog): 0.2.0 2026-11-24 16:06:18 +01:00
Sylvère A.
531d48cb76 feat(@vates/node-vsphere-soap): 2.2.1 2026-11-24 16:06:03 +01:00
Sylvère A.
d11566831b feat(@vates/nbd-client): 3.7.1 2026-11-24 16:05:42 +01:00
Sylvère A.
03d3e3b7cc feat(xen-api): 6.0.0 2026-11-24 16:05:16 +01:00
Sylvère A.
089da636ed feat(xo-collection): 1.0.0 2026-11-24 16:04:46 +01:00
Sylvère A.
c09b9cb820 feat(@vates/obfuscate): 0.2.0 2026-11-24 16:04:07 +01:00
Sylvère A.
f19126cd93 feat(@vates/iscsi): 0.4.1 2026-11-24 16:01:46 +01:00
Sylvère A.
8b5512afe6 feat(@vates/fuse-vhd): 2.1.4 2026-11-24 16:01:21 +01:00
Sylvère A.
5a993f204a feat(vhd-lib): 4.17.1 2026-11-24 15:59:58 +01:00
Sylvère A.
cb85c863fc feat(@xen-orchestra/fs): 4.11.0 2026-11-24 15:57:41 +01:00
Sylvère A.
6012db2bad feat(@vates/disposable): 0.1.7 2026-11-24 15:56:37 +01:00
Sylvère A.
cdcd61dadc feat(@xen-orchestra/log): 1.0.0 2026-11-24 15:54:11 +01:00
37 changed files with 118 additions and 870 deletions

View File

@@ -1,6 +1,6 @@
import assert from 'node:assert'
import { spawn } from 'node:child_process'
import { pFromCallback, pTimeout } from 'promise-toolbox'
import { pFromCallback } from 'promise-toolbox'
import { createLogger } from '@xen-orchestra/log'
import AbstractNbdClient from './AbstractNbdClient.mjs'
@@ -9,9 +9,6 @@ const { warn } = createLogger('vates:nbd-client:stdio')
// only the tail is kept: it's the part describing why the server died
const STDERR_MAX_LENGTH = 4096
// how long a failed connection waits for the server to exit and its stderr to end
const CLOSE_TIMEOUT = 1e3
/**
* NBD client talking to a server through its standard streams, like
* `nbdkit -s` or `qemu-nbd` in `--fd` mode: the queries are written to the
@@ -31,7 +28,7 @@ export default class NbdStdioClient extends AbstractNbdClient {
#cwd
#env
/** @type {{ child: import('node:child_process').ChildProcess, closing: boolean, stderr: string, closed: Promise<unknown> }|undefined} */
/** @type {{ child: import('node:child_process').ChildProcess, closing: boolean, stderr: string }|undefined} */
#state
/**
@@ -71,36 +68,6 @@ export default class NbdStdioClient extends AbstractNbdClient {
return this.#state?.child.pid
}
/**
* A server dying before the handshake makes it fail with "stream has ended
* without data", and the exit handler, racing with the teardown, often
* reports nothing: what the server wrote on stderr is the only reason given,
* so it becomes the error.
*/
async connect() {
try {
return await super.connect()
} catch (error) {
const state = this.#state
const closed =
state !== undefined &&
(await pTimeout.call(state.closed, CLOSE_TIMEOUT).then(
() => true,
() => false
))
// exitCode is null when the process was killed, by us when it did not die by itself
if (closed && state.child.exitCode !== null && state.stderr !== '') {
const serverError = new Error(state.stderr.trim(), { cause: error })
serverError.code = 'NBD_SERVER_EXITED'
serverError.exitCode = state.child.exitCode
serverError.command = this.#command
serverError.stderr = state.stderr
throw serverError
}
throw error
}
}
async _openTransport() {
const child = spawn(this.#command, this.#args, {
cwd: this.#cwd,
@@ -108,13 +75,7 @@ export default class NbdStdioClient extends AbstractNbdClient {
// the protocol goes through stdin/stdout, stderr is only used for diagnostics
stdio: ['pipe', 'pipe', 'pipe'],
})
const state = {
child,
closing: false,
stderr: '',
// 'close' comes after the exit and the end of the standard streams: stderr is complete
closed: new Promise(resolve => child.once('close', resolve)),
}
const state = { child, closing: false, stderr: '' }
this.#state = state
child.stderr.setEncoding('utf8')

View File

@@ -1,19 +0,0 @@
import assert from 'node:assert/strict'
import { describe, it } from 'node:test'
import NbdStdioClient from './NbdStdioClient.mjs'
describe('NbdStdioClient', () => {
it('reports what the server wrote on stderr when it dies before the handshake', async () => {
// the end of stdout and the exit of the process come in either order: repeat
for (let i = 0; i < 20; i++) {
const client = new NbdStdioClient({ command: 'sh', args: ['-c', 'echo "the actual reason" >&2; exit 1'] })
await assert.rejects(client.connect(), {
code: 'NBD_SERVER_EXITED',
exitCode: 1,
message: 'the actual reason',
stderr: 'the actual reason\n',
})
}
})
})

View File

@@ -22,11 +22,6 @@ export const BACKUP_EXPRESSION_CONTEXT = {
tags: { type: 'string[]' },
power_state: { type: 'string' },
},
pool: {
name_label: { type: 'string' },
description: { type: 'string' },
tags: { type: 'string[]' },
},
chainLength: { type: 'number' },
} as const
@@ -38,8 +33,6 @@ export const BACKUP_SETTING_CONTEXT = {
vmFilter: ['vm', 'run'],
srs: ['sr', 'run'],
remotes: ['backupRepository', 'run'],
vms: ['vm', 'run'],
pools: ['pool', 'run'],
} as const
export type BACKUP_SETTING_CONTEXT = (typeof BACKUP_SETTING_CONTEXT)[keyof typeof BACKUP_SETTING_CONTEXT]

View File

@@ -646,7 +646,7 @@ export type XoVmBackupJob = BaseXoJob & {
proxy?: XoProxy['id']
mode: 'full' | 'delta'
remotes?: CMType.IdOr<XoBackupRepository['id']> | string
vms: CMType.IdOr<XoVm['id']> | Record<string, unknown> | string
vms: CMType.IdOr<XoVm['id']> | Record<string, unknown>
srs?: CMType.IdOr<XoSr['id']> | string
type: 'backup'
settings: {
@@ -663,7 +663,7 @@ export type XoMetadataBackupJobScheduleSettings = {
}
export type XoMetadataBackupJob = BaseXoJob & {
type: 'metadataBackup'
pools?: CMType.IdOr<XoPool['id']> | string
pools?: CMType.IdOr<XoPool['id']>
remotes: CMType.IdOr<XoBackupRepository['id']>
settings: {
''?: XoMetadataBackupJobGeneralSettings
@@ -696,7 +696,6 @@ export type XoMirrorBackupJob = BaseXoJob & {
sourceRemote: XoBackupRepository['id']
remotes: CMType.IdOr<XoBackupRepository['id']>
proxy?: XoProxy['id']
filter?: { vm: { uuid: { __or: XoVm['id'][] } } } | null
settings: {
'': XoMirrorBackupGeneralSettings
[scheduleId: XoSchedule['id']]: XoMirrorBackupScheduleSettings | undefined

View File

@@ -9,7 +9,6 @@ const { warn } = createLogger('xo:backups:buildContext')
/**
* @typedef {import('@vates/types/xen-api').XenApiVm} XenApiVm
* @typedef {import('@vates/types/xo').XoSr} XoSr
* @typedef {import('@vates/types/xo').XoPool} XoPool
* @typedef {import('@vates/types/xo').XoBackupRepository} XoBackupRepository
*
* @typedef {object} RunContext
@@ -31,10 +30,6 @@ const { warn } = createLogger('xo:backups:buildContext')
* @typedef {object} BackupRepositoryContext
* @property {{name: string, type: string | undefined, tags: string[]}} backupRepository
* @property {RunContext} run
*
* @typedef {object} PoolContext
* @property {{name_label: string, description: string, tags: string[]}} pool
* @property {RunContext} run
*/
/**
@@ -114,19 +109,3 @@ export function buildBackupRepositoryContext(backupRepository, run) {
run,
}
}
/**
* @param {XoPool} pool
* @param {RunContext} run
* @returns {PoolContext}
*/
export function buildPoolContext(pool, run) {
return {
pool: {
name_label: pool.name_label,
description: pool.name_description,
tags: Array.isArray(pool.tags) ? pool.tags : [],
},
run,
}
}

View File

@@ -1,13 +1,7 @@
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import {
buildRunContext,
buildVmContext,
buildSrContext,
buildBackupRepositoryContext,
buildPoolContext,
} from './_buildContext.mjs'
import { buildRunContext, buildVmContext, buildSrContext, buildBackupRepositoryContext } from './_buildContext.mjs'
import { BACKUP_EXPRESSION_CONTEXT } from '@vates/types/backup-expression-context'
describe('buildContext', () => {
@@ -150,39 +144,4 @@ describe('buildContext', () => {
Object.keys(BACKUP_EXPRESSION_CONTEXT.backupRepository).sort()
)
})
it('buildPoolContext', () => {
const pool1 = {
name_label: 'name_label',
name_description: 'description',
ignored: 'ignored',
}
const poolContext1 = buildPoolContext(pool1, runContext)
assert.deepEqual(poolContext1, {
pool: {
name_label: 'name_label',
description: 'description',
tags: [],
},
run: expectedRunContext,
})
assert.deepEqual(Object.keys(poolContext1.pool).sort(), Object.keys(BACKUP_EXPRESSION_CONTEXT.pool).sort())
const pool2 = {
name_label: 'name_label',
name_description: 'description',
tags: ['tag'],
ignored: 'ignored',
}
const poolContext2 = buildPoolContext(pool2, runContext)
assert.deepEqual(poolContext2, {
pool: {
name_label: 'name_label',
description: 'description',
tags: ['tag'],
},
run: expectedRunContext,
})
assert.deepEqual(Object.keys(poolContext2.pool).sort(), Object.keys(BACKUP_EXPRESSION_CONTEXT.pool).sort())
})
})

View File

@@ -83,7 +83,6 @@ const main = Disposable.wrap(async function* main(args) {
handler.unlink(taskFile).catch(error => warn('deleting task failure', { error }))
} catch (error) {
warn('failure handling task', { error })
if (error.code === 'ELOCKED') await new Promise(resolve => setTimeout(resolve, 5 * 60e3))
}
},
{ concurrency }

View File

@@ -15,8 +15,6 @@ import type {
import type { RestApi } from '../rest-api/rest-api.mjs'
import { assertValidCron, vmContainsNoBakTag } from '../helpers/utils.helper.mjs'
import type { CreateBackupJobBody, CreateBackupJobSchedule, UpdateBackupJobBody } from './backup-job.type.mjs'
import { compileExpression, isExpression } from '@xen-orchestra/backups/_expressionPredicate.mjs'
import { buildRunContext, buildVmContext } from '@xen-orchestra/backups/_buildContext.mjs'
export class BackupJobService {
#backupJobTypes = ['backup', 'metadataBackup', 'mirrorBackup']
@@ -71,24 +69,12 @@ export class BackupJobService {
*/
assertJobHasValidExpressions(type: AnyXoBackupJob['type'], job: UpdateBackupJobBody): void {
if (type === 'backup') {
const { srs, remotes, vms, settings } = job as Extract<UpdateBackupJobBody, { srs?: unknown }>
const { srs, remotes, settings } = job as Extract<UpdateBackupJobBody, { srs?: unknown }>
assertValidExpression('srs', srs)
assertValidExpression('remotes', remotes)
assertValidExpression('vms', vms)
assertValidSettingsExpression(settings, ['healthCheckVmsWithTags', 'fullInterval'])
} else if (type === 'mirrorBackup') {
const { filter, remotes, settings } = job as Extract<UpdateBackupJobBody, { sourceRemote?: unknown }>
assertValidSettingsExpression(settings, ['healthCheckVmsWithTags', 'vmFilter'])
assertValidExpression('remotes', remotes)
if (filter != null && filter.vm.uuid.__or.length === 0) {
throw invalidParameters('filter must contain at least one VM', [
{ instancePath: '/filter/vm/uuid/__or', message: 'must NOT have fewer than 1 items' },
])
}
} else if (type === 'metadataBackup') {
const { remotes, pools } = job as Extract<UpdateBackupJobBody, { pools?: unknown }>
assertValidExpression('remotes', remotes)
assertValidExpression('pools', pools)
assertValidSettingsExpression(job.settings, ['healthCheckVmsWithTags', 'vmFilter'])
}
}
@@ -104,47 +90,16 @@ export class BackupJobService {
return false
}
const isVmInJob = await this.getBackupJobVmMatcher(backupJob)
return isVmInJob(vm)
}
/**
* Returns a function telling whether a VM is selected by the `vms` of the job,
* whether it is a list of IDs, an object pattern or an expression
*/
async getBackupJobVmMatcher(backupJob: XoVmBackupJob): Promise<(vm: XoVm) => boolean> {
try {
const vmIds = new Set<XoVm['id']>(extractIdsFromSimplePattern(backupJob.vms))
return vm => vmIds.has(vm.id)
const vmIds: XoVm['id'][] = extractIdsFromSimplePattern(backupJob.vms)
return vmIds.some(id => id === vm.id)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (_) {
if (!isExpression(backupJob.vms)) {
return createPredicate(backupJob.vms)
}
// `run:` clauses depend on the timezone, which is resolved per schedule like the executor does,
// so the VM is in the job if it matches for at least one of its schedules
const predicate = compileExpression(backupJob.vms)
const now = new Date()
const runContexts = (await this.#getScheduleTimezones(backupJob)).map(timezone => buildRunContext(now, timezone))
return vm => runContexts.some(runContext => predicate(buildVmContext(vm, runContext)))
const predicate = createPredicate(backupJob.vms)
return predicate(vm)
}
}
async #getScheduleTimezones(backupJob: XoVmBackupJob): Promise<(string | undefined)[]> {
const schedules = (await this.#restApi.xoApp.getAllSchedules()).filter(schedule => schedule.jobId === backupJob.id)
if (schedules.length === 0) {
return [backupJob.settings['']?.timezone]
}
return schedules.map(schedule => {
const scheduleTimezone = backupJob.settings[schedule.id]?.timezone
return typeof scheduleTimezone === 'string'
? scheduleTimezone
: (backupJob.settings['']?.timezone ?? schedule.timezone)
})
}
async backupJobHasAtLeastOneScheduleEnabled(id: XoVmBackupJob['id']): Promise<boolean> {
const backupJob = await this.#restApi.xoApp.getJob<XoVmBackupJob>(id)

View File

@@ -6,19 +6,15 @@ import type {
XoMetadataBackupJobGeneralSettings,
XoMetadataBackupJobScheduleSettings,
XoMirrorBackupGeneralSettings,
XoVm,
} from '@vates/types'
import { Unbrand } from '../open-api/common/response.common.mjs'
import type * as CMType from '@vates/types/lib/complex-matcher'
/**
* Copy of XoVmBackupJobScheduleSettings without the brand:
* tsoa empties any mapped type (Unbrand, Pick, Omit…) nested under Unbrand<UnbrandedXoVmBackupJob>,
* which dropped every schedule setting from the request bodies
*/
type VmBackupJobScheduleSettings = {
// Manual copy because with Unbrand<>, tsoa emits an empty schema. If XoVmBackupJobScheduleSettings changes
// in @vates/types, you have to update this copy too.
type UnbrandedXoVmBackupJobScheduleSettings = {
exportRetention?: number
healthCheckVmsWithTags?: XoVm['tags'] | string
healthCheckVmsWithTags?: string[] | string
fullInterval?: number | string
copyRetention?: number
snapshotRetention?: number
@@ -29,17 +25,17 @@ type VmBackupJobScheduleSettings = {
type UnbrandedXoVmBackupJob = Omit<XoVmBackupJob, 'settings' | 'remotes' | 'vms' | 'srs'> & {
remotes?: CMType.IdOr<string> | string
vms: CMType.IdOr<string> | Record<string, unknown> | string
vms: CMType.IdOr<string> | Record<string, unknown>
srs?: CMType.IdOr<string> | string
settings: {
'': XoVmBackupJobGeneralSettings
[scheduleId: string]: VmBackupJobScheduleSettings | undefined
[scheduleId: string]: UnbrandedXoVmBackupJobScheduleSettings | undefined
}
}
export type UnbrandXoVmBackupJob = Unbrand<UnbrandedXoVmBackupJob>
type UnbrandedXoMetadataBackupJob = Omit<XoMetadataBackupJob, 'settings' | 'pools' | 'remotes'> & {
pools?: CMType.IdOr<string> | string
pools?: CMType.IdOr<string>
remotes: CMType.IdOr<string>
settings: {
''?: XoMetadataBackupJobGeneralSettings
@@ -48,23 +44,21 @@ type UnbrandedXoMetadataBackupJob = Omit<XoMetadataBackupJob, 'settings' | 'pool
}
export type UnbrandXoMetadataBackupJob = Unbrand<UnbrandedXoMetadataBackupJob>
/**
* Same as VmBackupJobScheduleSettings
*/
type MirrorBackupJobScheduleSettings = {
// Manual copy because with Unbrand<>, tsoa emits an empty schema. If XoMirrorBackupScheduleSettings changes
// in @vates/types, you have to update this copy too.
type UnbrandedXoMirrorBackupScheduleSettings = {
exportRetention?: number
healthCheckVmsWithTags?: XoVm['tags'] | string
healthCheckVmsWithTags?: string[] | string
vmFilter?: string
healthCheckSr?: string
[key: string]: unknown
}
type UnbrandedXoMirrorBackupJob = Omit<XoMirrorBackupJob, 'settings' | 'remotes' | 'filter'> & {
type UnbrandedXoMirrorBackupJob = Omit<XoMirrorBackupJob, 'settings' | 'remotes'> & {
remotes: CMType.IdOr<string>
filter?: { vm: { uuid: { __or: string[] } } } | null
settings: {
'': XoMirrorBackupGeneralSettings
[scheduleId: string]: MirrorBackupJobScheduleSettings | undefined
[scheduleId: string]: UnbrandedXoMirrorBackupScheduleSettings | undefined
}
}
export type UnbrandXoMirrorBackupJob = Unbrand<UnbrandedXoMirrorBackupJob>

View File

@@ -14,6 +14,7 @@ import {
XoBackupLog,
} from '@vates/types'
import { createLogger } from '@xen-orchestra/log'
import { createPredicate } from 'value-matcher'
import { extractIdsFromSimplePattern } from '@xen-orchestra/backups/extractIdsFromSimplePattern.mjs'
import { noSuchObject } from 'xo-common/api-errors.js'
import { parse } from 'xo-remote-parser'
@@ -360,22 +361,23 @@ export class XoaService {
const nonReplicaVms = Object.values(this.#restApi.getObjectsByType<XoVm>('VM', { filter: vm => !isReplicaVm(vm) }))
const restApi = this.#restApi
const xoApp = restApi.xoApp
const backupJobService = this.#backupJobService
async function _extractVmIdsFromBackupJob(job: XoVmBackupJob): Promise<XoVm['id'][]> {
function _extractVmIdsFromBackupJob(job: XoVmBackupJob) {
let vmIds: XoVm['id'][]
try {
return extractIdsFromSimplePattern(job.vms)
vmIds = extractIdsFromSimplePattern(job.vms)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (_) {
const isVmInJob = await backupJobService.getBackupJobVmMatcher(job)
return nonReplicaVms.filter(isVmInJob).map(vm => vm.id)
const predicate = createPredicate(job.vms)
vmIds = nonReplicaVms.filter(predicate).map(vm => vm.id)
}
return vmIds
}
async function _processVmsProtection(job: XoVmBackupJob, isProtected: boolean) {
function _processVmsProtection(job: XoVmBackupJob, isProtected: boolean) {
if (job.type !== BACKUP_TYPE.backup) {
return
}
;(await _extractVmIdsFromBackupJob(job)).forEach(vmId => {
_extractVmIdsFromBackupJob(job).forEach(vmId => {
_updateVmProtection(vmId, isProtected)
})
}
@@ -432,7 +434,7 @@ export class XoaService {
for (const job of jobs) {
if (!(await this.#backupJobService.backupJobHasAtLeastOneScheduleEnabled(job.id))) {
await _processVmsProtection(job, false)
_processVmsProtection(job, false)
disabledJobs++
continue
}
@@ -484,7 +486,7 @@ export class XoaService {
}
if (last3BackupLogs.length === 0) {
await _processVmsProtection(job, false)
_processVmsProtection(job, false)
continue
}
@@ -498,11 +500,11 @@ export class XoaService {
backupLogStatusesByVm[id].push(isSuccess)
}
let jobVmIds: XoVm['id'][] | undefined
for (const { tasks, status } of last3BackupLogs) {
last3BackupLogs.forEach(jobLob => {
const { tasks, status } = jobLob
if (tasks === undefined) {
jobVmIds ??= await _extractVmIdsFromBackupJob(job)
jobVmIds.forEach(vmId => updateVmBackupLogStatuses(vmId, status === 'success'))
const vmIds = _extractVmIdsFromBackupJob(job)
vmIds.forEach(vmId => updateVmBackupLogStatuses(vmId, status === 'success'))
} else {
tasks.forEach(task => {
if (task.data === undefined) {
@@ -511,7 +513,7 @@ export class XoaService {
updateVmBackupLogStatuses(task.data.id as XoVm['id'], task.status === 'success')
})
}
}
})
for (const [vmId, statuses] of Object.entries(backupLogStatusesByVm)) {
_updateVmProtection(

View File

@@ -13,12 +13,6 @@
> Users must be able to say: "I had this issue, happy to know it's fixed"
- [Backups/Merge] The background merge no longer crashes with `ENAMETOOLONG` when a VM's backups are locked by another job: it waits 5 minutes before trying again instead of retrying in a loop (PR [#10866](https://github.com/vatesfr/xen-orchestra/pull/10866))
- [SDN Controller] A host that joins a pool with private networks is now wired into them as soon as the host is enabled
- [SDN Controller] When a host is ejected from a pool, the tunnels to it are now removed from the remaining hosts (including the star-center host), so no stale tunnel is left on the pool after a host leaves a pool with private networks
- [V2V] When the import of a disk fails before its transfer starts, the task shows the reason given by the migration engine (e.g. `could not connect: timed out`) instead of `stream has ended without data, was looking for 8 bytes` (PR [#10842](https://github.com/vatesfr/xen-orchestra/pull/10842))
- [XO6] A VM converted into a template no longer stays in the VM list and treeview, contribution by [@pcbeingused333](https://github.com/pcbeingused333), fixes issue [#10717](https://github.com/vatesfr/xen-orchestra/issues/10717) (PR [#10884](https://github.com/vatesfr/xen-orchestra/pull/10884))
### Packages to release
> When modifying a package, add it here with its release type.
@@ -35,9 +29,4 @@
<!--packages-start-->
- @vates/nbd-client patch
- @xen-orchestra/backups patch
- xo-collection patch
- xo-server-sdn-controller patch
<!--packages-end-->

View File

@@ -569,7 +569,7 @@ XCP-ng is a type 1 hypervisor, similar to VMware ESXi.
You can migrate your VM from VMware vSphere to a Vates environment (Xen Orchestra and XCP-ng), directly from Xen Orchestra. For this, we use V2V ("VMware to Vates").
Since XO 6.11, the migration is driven from XO 6, in **Administration → V2V → Migrate VMs**. To know more on using V2V in Xen Orchestra to migrate your environment from VMware, refer to the [VMware migration (V2V) guide](../migrate-from-vmware/v2v-migration-guide.md).
To know more on using V2V in Xen Orchestra to migrate your environment from VMware, refer to the [XO V2V section in the XCP-ng documentation](https://docs.xcp-ng.org/installation/migrate-to-xcp-ng/#xo-v2v).
## Hosts management

View File

@@ -3,13 +3,13 @@ sidebar_label: VMware migration (V2V)
sidebar_position: 1
---
# VMware migration (V2V) — NEW
# VMware migration (V2V)
## Introduction {#-introduction}
Xen Orchestra 5.110 introduced a new migration backend for moving virtual machines from VMware to XCP-ng (V2V). It replaces the old NFS-based method with `vectura`, a standalone reader of VMware's NFC protocol, delivering better performance and reliability without any VMware-provided library.
The whole process is driven from Xen Orchestra, in **Administration → V2V → Migrate VMs**. XO connects to your vCenter or ESXi host, reads the VM disks directly, and imports them into an XCP-ng storage repository:
The whole process is driven from Xen Orchestra, in **Import → VM → From VMware**. XO connects to your vCenter or ESXi host, reads the VM disks directly, and imports them into an XCP-ng storage repository:
<Schema label="XO reads the VM disks from ESXi through vectura, and imports them into an XCP-ng pool. The source VM keeps running during most of the transfer" legend={[["#5ac8c8", "VMware"], ["#8e83fe", "XCP-ng"], ["#6aabf0", "XO"]]} maxWidth="640px">
<svg viewBox="0 0 640 240" role="img" aria-label="A VM running on an ESXi host inside a VMware infrastructure is exported by Xen Orchestra using vectura, then imported into an XCP-ng host in the destination pool, where the migrated VM is ready to boot; the source VM keeps running during the warm phase of the transfer">
@@ -46,7 +46,6 @@ This guide walks you through the entire migration process:
- Preparing your Xen Orchestra environment
- Preparing your VMware environment
- Running the migration wizard
- Running a test migration
- Executing the final cutover
- Preparing the guest to boot on XCP-ng with the [Autopilot docking](#-autopilot-docking)
@@ -54,7 +53,7 @@ This guide walks you through the entire migration process:
You will also find troubleshooting advice and best practices to maximize speed and minimize downtime.
:::note
Since XO 6.11, the V2V import is available in the XO 6 interface, in **Administration → V2V → Migrate VMs**. This guide describes the XO 6 interface. The XO 5 import form remains available: see [Using XO 5 (legacy)](#-using-xo-5).
The V2V import is currently available in the XO 5 interface. The new XO 6 web UI does not expose it yet: even if you use XO 6 daily, switch to the XO 5 interface for the migration itself.
:::
## Benefits {#-benefits}
@@ -81,8 +80,6 @@ Additionally, UEFI VMs are no longer forced into Secure Boot mode, which resolve
Recent releases keep improving the workflow: since XO 6.6, a CD-ROM drive present on the source is recreated on the destination VM, and a two-step transfer (a first warm pass followed by a final run) tells you upfront whether the next run will be a full or a delta transfer.
Since XO 6.11, the XO 6 interface brings a migration wizard: you can migrate several VMs at once, choose a storage repository for each disk and a network for each network adapter, and resume a partial import from its last sync. Migration lists are saved in your browser, one per source and destination pool.
#### Performance gains
Performance gains can be significant, though results depend on the environment:
@@ -97,9 +94,7 @@ Performance gains can be significant, though results depend on the environment:
Make sure your Xen Orchestra instance is up to date. The import page includes an automatic check that verifies that `vectura`, shipped with your Xen Orchestra, runs on this system. Errors must be resolved before the migration can start.
<UiDetail src="/img/xo6/v2v-prerequisite-check.png" alt="The prerequisite check on the Source step of the migration wizard, showing the status of vectura" width={340} />
<UiDetail src="/img/xo5/v2v-prerequisite-check.png" alt="The prerequisite check on the XO 5 import page, showing the status of vectura" width={232} />
<UiDetail src="/img/xo5/v2v-prerequisite-check.png" alt="The prerequisite check on the import page, showing the status of vectura" width={232} />
### Dependencies
@@ -108,7 +103,15 @@ is shipped with Xen Orchestra and runs from there: there is nothing to install,
from VMware or Broadcom, and nothing to compile. It needs a Linux x86-64 system with glibc 2.31 or
later, such as Debian 11 or Ubuntu 20.04.
Go to **Administration → V2V → Migrate VMs**. The prerequisite check is shown at the top of the **Connect a new VMware source** card. Until it passes, VMs cannot be migrated.
Go to the **Import → VM → From VMware** section. Once the check passes, a **transfer form** appears:
<UiDetail src="/img/xo5/v2v-transfer-form.png" alt="The transfer form used to connect to VMware and import a VM into Xen Orchestra" width={620} />
:::warning
Filling in this form and clicking the **Connect** button will start the VM import. Make sure your VMware environment is ready first!
Read [Preparing the VMware environment](#-preparing-the-vmware-environment) to know more.
:::
## Preparing the VMware environment {#-preparing-the-vmware-environment}
@@ -145,7 +148,7 @@ A snapshot taken before CBT was enabled cannot be used to compute a delta. Remov
Keep the VMware Tools (or open-vm-tools) installed and running on the source VMs. XO uses them to:
- shut the guest down cleanly when the **Stop the source VM** option is enabled, instead of powering it off;
- shut the guest down cleanly when the `Stop source` option is enabled, instead of powering it off;
- read the IP addresses of each network card, which the [Autopilot docking](#-autopilot-docking) needs for Windows VMs with several network cards in static addressing.
With the Autopilot docking, there is no need to remove the VMware Tools before the migration: the docking disables them on the migrated VM.
@@ -185,7 +188,7 @@ Here is the "surefire method" to prepare your VMware environment.
It involves a lot of manual steps, but it lets you detect and fix issues without impacting production.
:::tip
There is also a "fire-and-forget" approach: launch the migration with the **Stop the source VM** option enabled, then start the VM once the migration is complete.
There is also a "fire-and-forget" approach: launch the migration with the `Stop source` option enabled, then start the VM once the migration is complete.
This method is only recommended for non-critical VMs, and only after the first few migrations have gone smoothly.
:::
@@ -212,115 +215,6 @@ Without the Autopilot docking, take another snapshot named `vm without tools`.
This snapshot captures the state of the VM without VMware-specific components, and will be used for the initial migration.
## Running the migration wizard {#-running-the-migration-wizard}
The wizard has five steps: **Source**, **Destination**, **VMs**, **Mapping** and **Review**. Only administrators can migrate VMs.
### Source
Fill in the **Connect a new VMware source** form with the address of your vCenter or ESXi host (**Host** and **Port**, 443 by default), your VMware **Username** and **Password**, then click **Connect**.
<UiShot light="/img/xo6/v2v-source-light.png" dark="/img/xo6/v2v-source-dark.png" alt="The Source step of the migration wizard, with the remembered connections and the connection form" url="https://your-xo/v6/#/admin/v2v/migrate" />
- **Skip SSL check (self-signed certificate)** is enabled by default: the server certificate is not verified.
- **Remember connection in this browser** keeps the connection, password included, in this browser only. Xen Orchestra never stores your VMware credentials. Make sure this complies with your security guidelines.
Remembered connections are listed in the **Remembered connections** card, with the number of VMs and their migration status. Click **Connect** to reuse one. The connection remembered by the XO 5 import form is added to this list.
### Destination
Choose the **Destination pool**, then the global defaults applied to every VM:
- **Default storage repository**: prefilled with the pool default SR.
- **Default network**: prefilled with the management network of the pool master.
- **Default template**.
<UiShot light="/img/xo6/v2v-destination-light.png" dark="/img/xo6/v2v-destination-dark.png" alt="The Destination step of the migration wizard, with the destination pool and the global defaults" url="https://your-xo/v6/#/admin/v2v/migrate?step=destination" />
Each VM can override these defaults in the **Mapping** step.
Each source and destination pool pair has its own migration list, saved in your browser. If a list already exists for this pair, click **Continue with existing list** to reopen it, with the current migration state of every VM.
### VMs
The table lists the VMs of the source, with their power state, datastores, size, migration status and last sync. Filter them with the presets (**All**, **Not migrated**, **Not ready**, **In progress**, **Warm synced**, **Cutover done**), with the query builder, or by clicking a datastore.
<UiShot light="/img/xo6/v2v-vms-light.png" dark="/img/xo6/v2v-vms-dark.png" alt="The VMs step of the migration wizard, with the VMs of the source and the Selected VMs side panel" url="https://your-xo/v6/#/admin/v2v/migrate?step=vms" />
Select the VMs to migrate, then click **Add to migration list**. VMs with an [unsupported disk](#-unsupported) cannot be selected.
The **Selected VMs** side panel shows the migration list. Removing a VM from the list does not delete anything, neither on the source nor in XO.
### Mapping
The table shows every VM of the migration list, with its type:
- **New**: the VM is imported for the first time.
- **Resume**: a partial import of the VM exists on the destination pool. The import resumes from the last sync, with the mapping of the first run.
<UiShot light="/img/xo6/v2v-mapping-light.png" dark="/img/xo6/v2v-mapping-dark.png" alt="The Mapping step of the migration wizard, with the details of a VM in the side panel" url="https://your-xo/v6/#/admin/v2v/migrate?step=mapping" />
Click a VM to open its details in the side panel, then click **Edit settings** to choose:
- a **Target SR** for each disk,
- a **Target network** for each network adapter,
- the **Template**.
Each value shows whether it comes from the **Global default** or is **Overridden**. Click **Reset to default** to go back to the global default.
The mapping of a resumed VM is locked. To start over with a new mapping, click **Delete** in its side panel: the partial import is deleted, and the VM is imported as a new VM.
The **Checks** column tells whether each VM is ready. A VM with one of these checks is not migrated:
- **Not found in the source**
- An [unsupported disk](#-unsupported)
- **Import in progress**
- **Partial import on pool \{pool\}**: the partial import of the VM exists on another pool.
- **Mapping incomplete**: a chosen SR, network or template is no longer available on the pool.
A VM with the **Already migrated, confirmation at launch** check is only migrated again after your confirmation, in the **Review** step.
### Review
Set the **Default options** of the launch:
- **Stop the source VM**: enabled by default. The source VM is stopped before the last delta transfer. This is needed to fully transfer a running VM.
- **Stop on error**: enabled by default. The migration stops on the first error when importing VMs.
- **Concurrent VMs**: the number of VMs imported at the same time, 2 by default (from 1 to 8).
<UiShot light="/img/xo6/v2v-review-light.png" dark="/img/xo6/v2v-review-dark.png" alt="The Review step of the migration wizard, with the default options and the per-VM options" url="https://your-xo/v6/#/admin/v2v/migrate?step=review" />
In the **Per-VM options** table, you can override the **Stop source** option for each VM.
Before the launch, VMs are grouped as follows:
- **Excluded**: VMs with a blocking check. They are not migrated.
- **Already fully migrated**: tick **Create a second copy of \{name\}** to migrate the VM again. A second VM is created on the destination pool.
- **Resumed**: VMs resumed from their last sync.
- **New**: VMs imported for the first time.
Click **Launch \{n\} VMs** to start the migration. The migration runs in a task: click **See the task** to follow its progress.
### Limitations {#-limitations}
- The **Tags** and **Keep MAC addresses** options of the **Mapping** step are not applied yet.
- The **Start the VM on XCP-ng** and **Automatically clean up the VM** options are not supported yet.
- Do not launch the migration of the same VM twice at the same time: both imports would use the same partial import.
### Using XO 5 (legacy) {#-using-xo-5}
Go to the **Import → VM → From VMware** section. Once the check passes, a **transfer form** appears:
<UiDetail src="/img/xo5/v2v-transfer-form.png" alt="The transfer form used to connect to VMware and import a VM into Xen Orchestra" width={620} />
:::warning
Filling in this form and clicking the **Connect** button will start the VM import. Make sure your VMware environment is ready first!
Read [Preparing the VMware environment](#-preparing-the-vmware-environment) to know more.
:::
In XO 5, the `Stop source` option matches the **Stop the source VM** option of the XO 6 wizard.
## Initial test migration {#-initial-test-migration}
Before making the final switch, **run a test migration first**. This lets you catch any issues before moving to production.
@@ -330,23 +224,23 @@ Before making the final switch, **run a test migration first**. This lets you ca
Understanding the warm migration mechanism helps you follow the progress:
1. If the source VM is running and has no snapshot, XO automatically takes one, named `[V2V] migration to XCP-ng`.
2. XO creates the destination VM (its name starts with `[Importing...]` while the transfer runs) and imports the read-only snapshot chain while the source VM keeps running in production.
2. XO creates the destination VM (its name ends with `importing...` while the transfer runs) and imports the read-only snapshot chain while the source VM keeps running in production.
3. A snapshot of the destination VM is taken after this first pass, so the process can be resumed safely without creating duplicate VMs.
4. If the **Stop the source VM** option is enabled, XO then shuts the source VM down through its VMware Tools, transfers only the final delta (the blocks written since the snapshot), and takes a final `complete import from V2V` snapshot. When the VMware Tools do not run, or the guest does not shut down within 10 minutes, the VM is powered off instead, and the task reports it.
4. If the `Stop source` option is enabled, XO then shuts the source VM down through its VMware Tools, transfers only the final delta (the blocks written since the snapshot), and takes a final `complete import from V2V` snapshot. When the VMware Tools do not run, or the guest does not shut down within 10 minutes, the VM is powered off instead, and the task reports it.
5. If the [Autopilot docking](#-autopilot-docking) is enabled and the import is complete, XO boots the destination VM on the docking ISO, which prepares the guest to run on XCP-ng.
As long as the import is partial (the source VM is still live), XO blocks the destination VM from starting normally, to prevent both copies from running at once.
### Perform the first migration attempt
1. **Start the V2V migration** in Xen Orchestra, with the **Stop the source VM** option disabled (it is enabled by default).\
1. **Start the V2V migration** in Xen Orchestra, without enabling the `Stop source` option.\
This will transfer the VM data up to the snapshot named `vm without tools`.
:::tip
You can safely close your browser while the migration runs.
:::
2. **Monitor the migration progress** using one of these methods:
- Check the VM status in Xen Orchestra (its name should show `[Importing...]`).
- Follow the migration task: click **See the task** once the migration is launched.
- Check the VM status in Xen Orchestra (its name should show `importing...`).
- Follow the disk transfer progress indicators.
### Testing the migrated VM
@@ -377,7 +271,7 @@ Once you have finished your checks and taken notes, delete the test VM. This wil
When you're ready for the final migration:
- Shut down the source VM completely.
- Start the V2V migration in Xen Orchestra with the **Stop the source VM** option enabled.\
- Start the V2V migration in Xen Orchestra with the `Stop source` option enabled.\
This ensures the final sync happens while the VM is powered off, and prevents any inconsistencies.
### Post-migration tasks
@@ -491,9 +385,6 @@ If you encounter problems during migration, try these steps to diagnose and reso
- **Test network connectivity**\
Ensure stable network connectivity between the VMware environment, Xen Orchestra, and XCP-ng hosts.
- **Check the launch errors**\
When the migration cannot be started, the **Review** step lists the problem of each VM. VMs with a blocking check are listed in the **Excluded** group, with the reason.
- **Retry with cold migration**\
If warm migration fails, power off the VM, remove all snapshots, and try again.

View File

@@ -38,7 +38,6 @@ XO 6 is under active development, so this table evolves with every release. As a
| Storage | Inspect SRs and VDIs; connect, disconnect and delete SRs; create, attach, export, delete VDIs and migrate them between SRs | SR creation, advanced disk operations |
| Performance stats | Usage charts on every dashboard (last week) | Full stats views with granularity control, via the marked Stats link |
| Backups | Job list with run history, per-job pages (runs, configuration, backed up VMs, targets), per-VM protection status, dashboard health panels | Job creation and editing, restore, remotes, mirrors, sequences, health checks |
| VMware migration (V2V) | Migration wizard: several VMs at once, a storage repository per disk and a network per network adapter, resume from the last sync | VMware import form |
| Tasks | Full task history at every level, last-24-hours quick view | Task list |
| Users and access | Users list with details, groups and authentication tokens | User creation and editing, groups, roles, LDAP and other auth providers, ACLs |
| Settings | Color mode, five themes, 21 languages | Servers, plugins, proxies, licenses, everything under Settings |

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 181 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 178 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 194 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 192 KiB

View File

@@ -107,14 +107,7 @@ export class Index {
const type = getIndexType(value)
// Removes item from the previous type's list if any.
if (prevType != null) {
delete itemsByType[prevType][key]
// The item left this type: let the listeners of the previous type know.
if (prevType !== type) {
this.getEventEmitterByType(prevType)?.emit('remove', undefined, previousObj)
}
}
if (prevType != null) delete itemsByType[prevType][key]
// Inserts item into the new type's list if any.
if (type != null) {

View File

@@ -135,55 +135,6 @@ describe('Index', function () {
})
})
it('emits remove on the previous type when an item changes type', function () {
const removed = []
const updated = []
byGroup.getEventEmitterByType('foo').on('remove', (_, prev) => removed.push(prev))
byGroup.getEventEmitterByType('foo').on('update', value => updated.push(value))
const item1bis = {
id: item1.id,
group: 'bar',
}
col.update(item1bis)
return waitTicks().then(() => {
assert.deepEqual(removed, [item1])
assert.deepEqual(updated, [])
})
})
it('emits remove on the previous type when an item no longer has a type', function () {
const removed = []
byGroup.getEventEmitterByType('foo').on('remove', (_, prev) => removed.push(prev))
col.update({ id: item1.id })
return waitTicks().then(() => {
assert.deepEqual(removed, [item1])
})
})
it('emits update, not remove, when an item keeps the same type', function () {
const removed = []
const updated = []
const ee = byGroup.getEventEmitterByType('foo')
ee.on('remove', (_, prev) => removed.push(prev))
ee.on('update', (value, prev) => updated.push([value, prev]))
const item1bis = {
id: item1.id,
group: 'foo',
newProp: true,
}
col.update(item1bis)
return waitTicks().then(() => {
assert.deepEqual(removed, [])
assert.deepEqual(updated, [[item1bis, item1]])
})
})
it('correctly updates the value even if the same object has the same hash', function () {
const item1bis = {
id: item1.id,

View File

@@ -1254,20 +1254,6 @@ class SDNController extends EventEmitter {
return
}
// The tunnel legs of a removed host on the remaining hosts (in
// particular on the star center) are not cleaned up by XAPI: re-run
// the network registration of its pool, as on plugin load, to remove
// them and rewire the remaining hosts
const poolUuid = object?.$type === 'host' ? object.$pool.uuid : undefined
if (poolUuid !== undefined) {
await Promise.all(
map(
filter(this.privateNetworks, privateNetwork => privateNetwork.networks[poolUuid] !== undefined),
privateNetwork => privateNetwork.addNetwork(privateNetwork.networks[poolUuid])
)
)
}
// If a network is removed, clean this.privateNetworks from it
const networkRef = this._networks.get(id)
if (networkRef !== undefined) {
@@ -1345,10 +1331,6 @@ class SDNController extends EventEmitter {
this._newHosts.splice(i, 1)
// The OVSDB client can not have been created when the host was added, as it
// was not enabled yet: create it now that the host is up.
this._getOrCreateOvsdbClient(host)
log.debug('Sync pool certificates', {
newHost: host.name_label,
pool: host.$pool.name_label,
@@ -1574,7 +1556,7 @@ class SDNController extends EventEmitter {
async _addHostToPrivateNetworks(host) {
const xapi = host.$xapi
const tunnels = Object.values(xapi.objects.indexes.type.tunnel ?? {})
const tunnels = Object.values(xapi.objects.indexes.type.SDN_tunnel ?? {})
for (const tunnel of tunnels) {
const accessPif = xapi.getObjectByRef(tunnel.access_PIF)
if (accessPif.host !== host.$ref) {

View File

@@ -299,163 +299,6 @@ describe('SDN controller reliability', () => {
})
})
describe('a host joining a pool with private networks', () => {
function makeJoiningHost(xapi) {
return {
$type: 'host',
$ref: 'host-ref-1',
$id: 'host-id-1',
$xapi: xapi,
name_label: 'joining-host',
enabled: false,
PIFs: [],
$pool: { uuid: 'pool-uuid-1', $ref: 'pool-ref-1', $id: 'pool-id-1', name_label: 'pool' },
}
}
it('creates the OVSDB client when the just-joined host becomes enabled', async () => {
const controller = createFakeController()
const xapi = createFakeXapi()
xapi.objects = new EventEmitter()
xapi.objects.indexes = { type: {} }
controller._getOrCreateOfChannel = mock.fn(() => undefined)
controller._setBridgeControllerForHost = mock.fn()
const host = makeJoiningHost(xapi)
controller._objectsAdded({ 'host-id-1': host })
// the host is not enabled yet: no client on the add event
assert.equal(controller.ovsdbClients[host.$ref], undefined)
assert.deepEqual(controller._newHosts, [host])
// the host becomes enabled: the client must be created by the update path
host.enabled = true
host.PIFs = ['pif-ref-1']
controller._objectsUpdated({ 'host-id-1': host })
await new Promise(resolve => setImmediate(resolve))
assert.notEqual(controller.ovsdbClients[host.$ref], undefined)
assert.deepEqual(controller._newHosts, [])
})
it('adds the host to the private networks through its tunnels', async () => {
const controller = createFakeController()
const xapi = createFakeXapi()
const network = { $ref: 'network-ref-1', name_label: 'test-network' }
const accessPif = {
$ref: 'pif-ref-tunnel',
host: 'host-ref-1',
device: 'tunnel0',
currently_attached: true,
$network: network,
}
// a tunnel for another host must be ignored
xapi.objects.indexes = {
type: {
tunnel: [
{ $ref: 'tunnel-ref-1', access_PIF: 'pif-ref-tunnel' },
{ $ref: 'tunnel-ref-2', access_PIF: 'pif-ref-other-host' },
],
},
}
xapi.getObjectByRef = ref =>
ref === accessPif.$ref ? accessPif : { $ref: 'pif-ref-other-host', host: 'host-ref-other', $network: network }
const host = makeJoiningHost(xapi)
host.enabled = true
const addHostToPrivateNetwork = mock.fn(async () => undefined)
controller._addHostToPrivateNetwork = addHostToPrivateNetwork
await controller._addHostToPrivateNetworks(host)
// only the tunnel whose access PIF belongs to the host is processed
assert.equal(addHostToPrivateNetwork.mock.calls.length, 1)
assert.equal(addHostToPrivateNetwork.mock.calls[0].arguments[0], host)
assert.equal(addHostToPrivateNetwork.mock.calls[0].arguments[1], network)
})
})
describe('a host ejected from a pool with private networks', () => {
function makeEjectContext() {
const controller = createFakeController()
const xapi = createFakeXapi()
xapi.objects = new EventEmitter()
xapi.objects.indexes = { type: {} }
const poolUuid = 'pool-uuid-1'
const host = {
$type: 'host',
$ref: 'host-ref-1',
$id: 'host-id-1',
$xapi: xapi,
name_label: 'ejected-host',
enabled: true,
PIFs: [],
$pool: { uuid: poolUuid, $ref: 'pool-ref-1', $id: 'pool-id-1', name_label: 'pool' },
}
const network = {
$ref: 'network-ref-1',
$id: 'network-id-1',
$pool: { uuid: poolUuid, $ref: 'pool-ref-1', $id: 'pool-id-1', $xapi: xapi },
name_label: 'test-network',
}
const addNetwork = mock.fn(async () => undefined)
controller.privateNetworks = {
// the network of the pool of the removed host
'private-network-uuid-1': {
uuid: 'private-network-uuid-1',
networks: { [poolUuid]: network },
center: { $ref: 'host-ref-2' },
addNetwork,
},
// a network of another pool must not be touched
'private-network-uuid-2': {
uuid: 'private-network-uuid-2',
networks: { 'pool-uuid-2': { $ref: 'network-ref-2' } },
center: { $ref: 'host-ref-3' },
addNetwork: mock.fn(async () => undefined),
},
}
// a client of the removed host, to check it is dropped
const ovsdbClient = { host }
controller.ovsdbClients = { [host.$ref]: ovsdbClient }
controller.ofChannels = { [host.$ref]: { host } }
return { controller, xapi, host, network, addNetwork }
}
it('rewires the private networks of the host pool', async () => {
const { controller, xapi, host, network, addNetwork } = makeEjectContext()
controller._objectsRemoved(xapi, { 'host-id-1': host })
await new Promise(resolve => setImmediate(resolve))
// the client and channel of the removed host are dropped
assert.equal(controller.ovsdbClients[host.$ref], undefined)
assert.equal(controller.ofChannels[host.$ref], undefined)
// the network of the host's pool is re-registered: this is what removes
// the stale tunnel legs (resetForNetwork) on the remaining hosts
assert.equal(addNetwork.mock.calls.length, 1)
assert.equal(addNetwork.mock.calls[0].arguments[0], network)
})
it('does not rewire for a non-host object removal', async () => {
const { controller, xapi, addNetwork } = makeEjectContext()
controller._objectsRemoved(xapi, { 'pif-id-1': { $type: 'PIF', $ref: 'pif-ref-1', $id: 'pif-id-1' } })
await new Promise(resolve => setImmediate(resolve))
assert.equal(addNetwork.mock.calls.length, 0)
})
})
describe('VIF traffic rules', () => {
// a VIF on a host where the XAPI plugin fails to apply (or remove) the rule
function controllerWithFailingPlugin() {

View File

@@ -87,10 +87,9 @@ export class PrivateNetwork {
host: this.center.name_label,
})
let hostResult
let centerResult
let bridgeName
try {
;[hostResult, centerResult] = await Promise.all([
;[bridgeName] = await Promise.all([
hostClient.addInterfaceAndPort(network, centerPif.IP, encapsulation, vni, password, this.uuid),
centerClient.addInterfaceAndPort(centerNetwork, hostPif.IP, encapsulation, vni, password, this.uuid),
])
@@ -104,22 +103,14 @@ export class PrivateNetwork {
})
return
}
if (hostResult === undefined) {
return
}
log.info('Host added', {
privateNetwork: this.uuid,
network: network.name_label,
host: host.name_label,
pool: host.$pool.name_label,
})
// The reconcile re-runs on every host metrics event: log only when the
// host or the center side has actually been (re)wired
if (hostResult.added || centerResult?.added) {
log.info('Host added', {
privateNetwork: this.uuid,
network: network.name_label,
host: host.name_label,
pool: host.$pool.name_label,
})
}
return hostResult.name
return bridgeName
}
addNetwork(network) {

View File

@@ -1,79 +0,0 @@
import { describe, it } from 'node:test'
import { strict as assert } from 'node:assert'
import { PrivateNetwork } from './private-network.js'
describe('PrivateNetwork.addHost', () => {
const transportPif = { network: 'network-ref-1', IP: '10.0.0.1' }
function makePrivateNetwork(hostResult, centerResult) {
const controller = {
privateNetworks: {},
registerPrivateNetwork: privateNetwork => {
controller.privateNetworks[privateNetwork.uuid] = privateNetwork
},
ovsdbClients: {
'host-ref-1': { addInterfaceAndPort: async () => hostResult },
'host-ref-center': { addInterfaceAndPort: async () => centerResult },
},
}
const network = {
$ref: 'network-ref-1',
$xapi: { getRecord: async () => network },
other_config: {},
}
const pif = { network: 'network-ref-1' }
const host = {
$ref: 'host-ref-1',
name_label: 'host-1',
$PIFs: [pif],
$pool: { uuid: 'pool-uuid-1', name_label: 'pool' },
}
const center = {
$ref: 'host-ref-center',
name_label: 'center',
$PIFs: [pif],
$pool: { uuid: 'pool-uuid-1', name_label: 'pool' },
}
const privateNetwork = new PrivateNetwork(controller, 'private-network-uuid')
privateNetwork.center = center
privateNetwork.networks = { 'pool-uuid-1': network }
// always report the transport PIF, so getTransportPif does not need the XAPI
privateNetwork.getTransportPif = async () => transportPif
return { privateNetwork, host, center }
}
it('returns the bridge name when the port already exists on both sides', async () => {
const { privateNetwork, host } = makePrivateNetwork(
{ name: 'xapi1', added: false },
{ name: 'xapi2', added: false }
)
assert.equal(await privateNetwork.addHost(host), 'xapi1')
})
it('returns the bridge name when only the host side was (re)wired', async () => {
const { privateNetwork, host } = makePrivateNetwork(
{ name: 'xapi1', added: true },
{ name: 'xapi2', added: false }
)
assert.equal(await privateNetwork.addHost(host), 'xapi1')
})
it('returns the bridge name when only the center side was (re)wired', async () => {
const { privateNetwork, host } = makePrivateNetwork(
{ name: 'xapi1', added: false },
{ name: 'xapi2', added: true }
)
assert.equal(await privateNetwork.addHost(host), 'xapi1')
})
it('returns nothing when the host side could not be connected', async () => {
const { privateNetwork, host } = makePrivateNetwork(undefined, { name: 'xapi2', added: true })
assert.equal(await privateNetwork.addHost(host), undefined)
})
it('does nothing for the star-center host itself', async () => {
const { privateNetwork, center } = makePrivateNetwork(undefined, undefined)
assert.equal(await privateNetwork.addHost(center), undefined)
})
})

View File

@@ -100,8 +100,7 @@ export class OvsdbClient {
if (password === undefined) {
socket.destroy()
this._adding = this._adding.filter(elem => elem.id !== network.uuid || elem.addr !== remoteAddress)
// The port already exists: nothing has been added
return { name: bridge.name, added: false }
return bridge.name
}
// Remove port and interface to recreate it with new password
@@ -200,7 +199,7 @@ export class OvsdbClient {
host: this.host.name_label,
})
socket.destroy()
return { name: bridge.name, added: true }
return bridge.name
}
async resetForNetwork(network, privateNetworkUuid) {
@@ -355,16 +354,9 @@ export class OvsdbClient {
const where = [['target', '==', TARGET]]
const selectResult = await this._select('Controller', ['_uuid'], where, socket)
// The Controller row is created by setBridgeController(), which may not have
// run yet on a host that just joined the pool: don't crash, it will be set
// later (next PIF event or the join flow).
if (selectResult === undefined) {
socket.destroy()
return
}
this._controllerUuid = selectResult._uuid[1]
}
assert.notStrictEqual(this._controllerUuid, undefined)
const bridge = await this._getBridgeForNetwork(network, socket)
if (bridge.uuid === undefined) {

View File

@@ -74,25 +74,3 @@ describe('a bridge XO already controls', () => {
assert.equal(transactions[0].length, 2)
})
})
describe('a network bridge on a host without a controller yet', () => {
// a client on a host that just joined the pool: the Controller row is not
// created yet (setBridgeController has not run), so the select finds nothing
function makeClient() {
const client = new OvsdbClient({ name_label: 'host', $PIFs: [{ $network: { uuid: 'net', name_label: 'net' } }] })
const transactions = []
client._connect = async () => ({ destroy() {} })
client._select = async () => undefined
client._sendOvsdbTransaction = async params => {
transactions.push(params)
return [{ error: null, result: [{ uuid: ['uuid', 'controller'] }] }]
}
return { client, transactions }
}
it('does not throw and sends no transaction when the Controller row is missing', async () => {
const { client, transactions } = makeClient()
await client.setBridgeControllerForNetwork({ uuid: 'net', name_label: 'net' })
assert.deepEqual(transactions, [])
})
})

View File

@@ -1,9 +1,5 @@
import { isSrWritable } from '../../utils.mjs'
import {
buildSrContext,
buildBackupRepositoryContext,
buildPoolContext,
} from '@xen-orchestra/backups/_buildContext.mjs'
import { buildSrContext, buildBackupRepositoryContext } from '@xen-orchestra/backups/_buildContext.mjs'
import { compileExpression } from '@xen-orchestra/backups/_expressionPredicate.mjs'
export function resolveBackupSrs(job, srs, runContext) {
@@ -44,16 +40,3 @@ export function resolveBackupRepositories(job, backupRepositories, runContext) {
return { backupRepositoryIds, proxySkippedIds, invalidUrlIds }
}
export function resolveBackupPools(job, pools, runContext) {
const predicate = compileExpression(job.pools)
const poolUuids = []
pools.forEach(pool => {
if (predicate(buildPoolContext(pool, runContext))) {
poolUuids.push(pool.uuid)
}
})
return poolUuids
}

View File

@@ -2,7 +2,7 @@ import assert from 'node:assert/strict'
import { describe, it } from 'node:test'
import { buildRunContext } from '@xen-orchestra/backups/_buildContext.mjs'
import { resolveBackupRepositories, resolveBackupSrs, resolveBackupPools } from './_resolveBackupTargets.mjs'
import { resolveBackupRepositories, resolveBackupSrs } from './_resolveBackupTargets.mjs'
// a Monday, at 22:00 UTC
const RUN_CONTEXT = buildRunContext(new Date('2026-11-02T22:00:00Z'), 'UTC')
@@ -25,13 +25,6 @@ const backupRepository = ({ id, name = id, url = 'nfs://nas:/backups', enabled =
proxy,
})
const pool = ({ uuid, name_label = uuid, tags = [] }) => ({
uuid,
name_label,
name_description: '',
tags,
})
describe('resolveBackupSrs()', () => {
it('returns the SRs matching the expression', () => {
const srs = [sr({ uuid: 'nfs-sr' }), sr({ uuid: 'local-sr', SR_type: 'ext' })]
@@ -155,24 +148,3 @@ describe('resolveBackupRepositories()', () => {
)
})
})
describe('resolveBackupPools()', () => {
it('returns the pools matching the expression', () => {
const pools = [pool({ uuid: 'pool1' }), pool({ uuid: 'pool2' })]
assert.deepEqual(resolveBackupPools({ pools: 'pool:name_label:pool1' }, pools, RUN_CONTEXT), ['pool1'])
})
it('evaluates the run context', () => {
const pools = [pool({ uuid: 'pool1' })]
assert.deepEqual(resolveBackupPools({ pools: 'run:hour:22' }, pools, RUN_CONTEXT), ['pool1'])
assert.deepEqual(resolveBackupPools({ pools: 'run:hour:23' }, pools, RUN_CONTEXT), [])
})
it('returns an empty array when nothing matches', () => {
const pools = [pool({ uuid: 'pool1' })]
assert.deepEqual(resolveBackupPools({ pools: 'pool:name_label:missing' }, pools, RUN_CONTEXT), [])
})
})

View File

@@ -22,8 +22,8 @@ import { serializeError, unboxIdsFromPattern } from '../../utils.mjs'
import { journalPurgeHorizon, serveVmBackups, VmBackupsCache } from './_vmBackupsCache.mjs'
import { VmBackupsSource } from './_vmBackupsSource.mjs'
import { waitAll } from '../../_waitAll.mjs'
import { compileExpression, isExpression } from '@xen-orchestra/backups/_expressionPredicate.mjs'
import { buildRunContext, buildVmContext } from '@xen-orchestra/backups/_buildContext.mjs'
import { isExpression } from '@xen-orchestra/backups/_expressionPredicate.mjs'
import { buildRunContext } from '@xen-orchestra/backups/_buildContext.mjs'
import { resolveBackupSrs, resolveBackupRepositories } from './_resolveBackupTargets.mjs'
const logger = createLogger('xo:xo-mixins:backups-ng')
@@ -214,41 +214,9 @@ export default class BackupNg {
job = { ...job, runContext }
const remotesExpression = isExpression(job.remotes) ? job.remotes : undefined
if (remotesExpression !== undefined) {
const {
backupRepositoryIds: remoteIds,
proxySkippedIds,
invalidUrlIds,
} = resolveBackupRepositories(job, await app.getAllRemotes(), runContext)
if (proxySkippedIds.length > 0) {
jobsLogger.warning(
'some backup repositories matched the expression but are not linked to the proxy of this job, they are skipped',
{
event: 'task.warning',
taskId: runJobId,
data: { backupRepositories: proxySkippedIds, proxy: job.proxy },
}
)
}
if (invalidUrlIds.length > 0) {
jobsLogger.warning(
'some backup repositories matched the expression but have an invalid URL, they are skipped',
{
event: 'task.warning',
taskId: runJobId,
data: { backupRepositories: invalidUrlIds },
}
)
}
job.remotes = { id: { __or: remoteIds } }
}
if (job.type === 'backup') {
const srsExpression = isExpression(job.srs) ? job.srs : undefined
const remotesExpression = isExpression(job.remotes) ? job.remotes : undefined
if (isExpression(job.srs)) {
const srUuids = resolveBackupSrs(job, Object.values(app.getObjectsByType('SR')), runContext)
@@ -256,6 +224,38 @@ export default class BackupNg {
job.srs = { id: { __or: srUuids } }
}
if (isExpression(job.remotes)) {
const {
backupRepositoryIds: remoteIds,
proxySkippedIds,
invalidUrlIds,
} = resolveBackupRepositories(job, await app.getAllRemotes(), runContext)
if (proxySkippedIds.length > 0) {
jobsLogger.warning(
'some backup repositories matched the expression but are not linked to the proxy of this job, they are skipped',
{
event: 'task.warning',
taskId: runJobId,
data: { backupRepositories: proxySkippedIds, proxy: job.proxy },
}
)
}
if (invalidUrlIds.length > 0) {
jobsLogger.warning(
'some backup repositories matched the expression but have an invalid URL, they are skipped',
{
event: 'task.warning',
taskId: runJobId,
data: { backupRepositories: invalidUrlIds },
}
)
}
job.remotes = { id: { __or: remoteIds } }
}
if (
(srsExpression !== undefined || remotesExpression !== undefined) &&
unboxIdsFromPattern(job.srs).length === 0 &&
@@ -313,16 +313,10 @@ export default class BackupNg {
vmIds = Object.keys(
app.getObjects({
filter: (() => {
let isMatchingVm
if (isExpression(vmsPattern)) {
const predicate = compileExpression(vmsPattern)
isMatchingVm = obj => obj.type === 'VM' && predicate(buildVmContext(obj, runContext))
} else {
isMatchingVm = createPredicate({
type: 'VM',
...vmsPattern,
})
}
const isMatchingVm = createPredicate({
type: 'VM',
...vmsPattern,
})
return obj =>
isMatchingVm(obj) &&

View File

@@ -5,9 +5,6 @@ import { createLogger } from '@xen-orchestra/log'
import { createRunner } from '@xen-orchestra/backups/Backup.mjs'
import { parseMetadataBackupId } from '@xen-orchestra/backups/parseMetadataBackupId.mjs'
import { RestoreMetadataBackup } from '@xen-orchestra/backups/RestoreMetadataBackup.mjs'
import { isExpression } from '@xen-orchestra/backups/_expressionPredicate.mjs'
import { resolveBackupPools, resolveBackupRepositories } from './backups-ng/_resolveBackupTargets.mjs'
import { buildRunContext } from '@xen-orchestra/backups/_buildContext.mjs'
import { Task } from '@vates/task'
import { debounceWithKey, REMOVE_CACHE_ENTRY } from '../_pDebounceWithKey.mjs'
@@ -51,62 +48,12 @@ export default class metadataBackup {
}
const app = this._app
const runContext = buildRunContext(
new Date(),
job.settings[schedule.id]?.timezone ?? job.settings['']?.timezone ?? schedule.timezone
)
if (job.xoMetadata) {
const config = await app.exportConfig()
job.xoMetadata = typeof config === 'string' ? config : { encoding: 'base64', data: config.toString('base64') }
}
if (isExpression(job.remotes)) {
const {
backupRepositoryIds: remoteIds,
proxySkippedIds,
invalidUrlIds,
} = resolveBackupRepositories(job, await app.getAllRemotes(), runContext)
if (proxySkippedIds.length > 0) {
jobsLogger.warning(
'some backup repositories matched the expression but are not linked to the proxy of this job, they are skipped',
{
event: 'task.warning',
taskId: runJobId,
data: { backupRepositories: proxySkippedIds, proxy: job.proxy },
}
)
}
if (invalidUrlIds.length > 0) {
jobsLogger.warning(
'some backup repositories matched the expression but have an invalid URL, they are skipped',
{
event: 'task.warning',
taskId: runJobId,
data: { backupRepositories: invalidUrlIds },
}
)
}
job.remotes = { id: { __or: remoteIds } }
}
if (isExpression(job.pools)) {
const poolIds = resolveBackupPools(job, Object.values(app.getObjectsByType('pool')), runContext)
if (poolIds.length === 0) {
jobsLogger.warning('no matching pool found', {
event: 'task.warning',
taskId: runJobId,
data: { pools: job.pools },
})
}
job.pools = { id: { __or: poolIds } }
}
const remoteIds = unboxIdsFromPattern(job.remotes)
const proxyId = job.proxy
try {