feat(backups): use the right SR for health check during replication (#6902)
This commit is contained in:
committed by
GitHub
parent
58182e2083
commit
311098adc2
@@ -14,6 +14,19 @@ exports.MixinXapiWriter = (BaseClass = Object) =>
|
||||
this._sr = sr
|
||||
}
|
||||
|
||||
// check if the base Vm has all its disk on health check sr
|
||||
async #isAlreadyOnHealthCheckSr(baseVm) {
|
||||
const xapi = baseVm.$xapi
|
||||
const vdiRefs = await xapi.VM_getDisks(baseVm.$ref)
|
||||
for (const vdiRef of vdiRefs) {
|
||||
const vdi = xapi.getObject(vdiRef)
|
||||
if (vdi.$SR.uuid !== this._heathCheckSr.uuid) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
healthCheck() {
|
||||
const sr = this._healthCheckSr
|
||||
assert.notStrictEqual(sr, undefined, 'SR should be defined before making a health check')
|
||||
@@ -25,20 +38,35 @@ exports.MixinXapiWriter = (BaseClass = Object) =>
|
||||
},
|
||||
async () => {
|
||||
const { $xapi: xapi } = sr
|
||||
let clonedVm
|
||||
let healthCheckVmRef
|
||||
try {
|
||||
const baseVm = xapi.getObject(this._targetVmRef) ?? (await xapi.waitObject(this._targetVmRef))
|
||||
const clonedRef = await xapi
|
||||
.callAsync('VM.clone', this._targetVmRef, `Health Check - ${baseVm.name_label}`)
|
||||
.then(extractOpaqueRef)
|
||||
clonedVm = xapi.getObject(clonedRef) ?? (await xapi.waitObject(clonedRef))
|
||||
|
||||
if (await this.#isAlreadyOnHealthCheckSr(baseVm)) {
|
||||
healthCheckVmRef = await Task.run(
|
||||
{ name: 'cloning-vm' },
|
||||
async () =>
|
||||
await xapi
|
||||
.callAsync('VM.clone', this._targetVmRef, `Health Check - ${baseVm.name_label}`)
|
||||
.then(extractOpaqueRef)
|
||||
)
|
||||
} else {
|
||||
healthCheckVmRef = await Task.run(
|
||||
{ name: 'copying-vm' },
|
||||
async () =>
|
||||
await xapi
|
||||
.callAsync('VM.copy', this._targetVmRef, `Health Check - ${baseVm.name_label}`, sr.$ref)
|
||||
.then(extractOpaqueRef)
|
||||
)
|
||||
}
|
||||
const healthCheckVm = xapi.getObject(healthCheckVmRef) ?? (await xapi.waitObject(healthCheckVmRef))
|
||||
|
||||
await new HealthCheckVmBackup({
|
||||
restoredVm: clonedVm,
|
||||
restoredVm: healthCheckVm,
|
||||
xapi,
|
||||
}).run()
|
||||
} finally {
|
||||
clonedVm && (await xapi.VM_destroy(clonedVm.$ref))
|
||||
healthCheckVmRef && (await xapi.VM_destroy(healthCheckVmRef))
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
"proper-lockfile": "^4.1.2",
|
||||
"uuid": "^9.0.0",
|
||||
"vhd-lib": "^4.5.0",
|
||||
"xen-api": "^1.3.1",
|
||||
"yazl": "^2.5.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
- [Backup] Fix memory consumption when deleting _VHD directory_ incremental backups
|
||||
- [Remote] Fix `remote is disabled` error when editing a disabled remote
|
||||
- [Settings/Servers] Fix connectiong using an explicit IPv6 address
|
||||
- [Backups/Health check] Use the right SR for health check during replication job (PR [#6902](https://github.com/vatesfr/xen-orchestra/pull/6902))
|
||||
|
||||
### Packages to release
|
||||
|
||||
|
||||
@@ -365,6 +365,36 @@ const TransferMergeTask = ({ className, task }) => {
|
||||
)
|
||||
}
|
||||
|
||||
const CloningVmTask = ({ className, task }) => {
|
||||
return (
|
||||
<li className={className}>
|
||||
Cloning Vm
|
||||
<TaskStateInfos status={task.status} />
|
||||
<TaskWarnings warnings={task.warnings} />
|
||||
<TaskInfos infos={task.infos} />
|
||||
<TaskStart task={task} />
|
||||
<TaskEnd task={task} />
|
||||
<TaskDuration task={task} />
|
||||
<TaskError task={task} />
|
||||
</li>
|
||||
)
|
||||
}
|
||||
|
||||
const CopyingVmTask = ({ className, task }) => {
|
||||
return (
|
||||
<li className={className}>
|
||||
Copying Vm
|
||||
<TaskStateInfos status={task.status} />
|
||||
<TaskWarnings warnings={task.warnings} />
|
||||
<TaskInfos infos={task.infos} />
|
||||
<TaskStart task={task} />
|
||||
<TaskEnd task={task} />
|
||||
<TaskDuration task={task} />
|
||||
<TaskError task={task} />
|
||||
</li>
|
||||
)
|
||||
}
|
||||
|
||||
const COMPONENT_BY_TYPE = {
|
||||
vm: VmTask,
|
||||
remote: RemoteTask,
|
||||
@@ -380,6 +410,8 @@ const COMPONENT_BY_MESSAGE = {
|
||||
'health check': HealthCheckTask,
|
||||
vmstart: HealthCheckVmStartTask,
|
||||
'clean-vm': CleanVmTask,
|
||||
'cloning-vm': CloningVmTask,
|
||||
'copying-vm': CopyingVmTask,
|
||||
}
|
||||
|
||||
const TaskLi = ({ task, ...props }) => {
|
||||
|
||||
Reference in New Issue
Block a user