fix(xo-server/RPU): correctly migrate VMs to their original host (#7238)

See zamma#19772
Introduced by bea771
This commit is contained in:
Mathieu
2023-12-19 19:22:50 +01:00
committed by GitHub
parent e66bcf2a5c
commit 41ed5625be
2 changed files with 11 additions and 7 deletions

View File

@@ -29,6 +29,7 @@
- [Plugin/transport-slack] Compatibility with other services like Mattermost or Discord [#7130](https://github.com/vatesfr/xen-orchestra/issues/7130) (PR [#7220](https://github.com/vatesfr/xen-orchestra/pull/7220))
- [Host/Network] Fix error "PIF_IS_PHYSICAL" when trying to remove a PIF that had already been physically disconnected [#7193](https://github.com/vatesfr/xen-orchestra/issues/7193) (PR [#7221](https://github.com/vatesfr/xen-orchestra/pull/7221))
- [Mirror backup] Fix backup reports not being sent (PR [#7235](https://github.com/vatesfr/xen-orchestra/pull/7235))
- [RPU] VMs are correctly migrated to their original host (PR [#7238](https://github.com/vatesfr/xen-orchestra/pull/7238))
### Packages to release

View File

@@ -534,7 +534,7 @@ export default {
}
// Remember on which hosts the running VMs are
const vmsByHost = mapValues(
const vmRefsByHost = mapValues(
groupBy(
filter(this.objects.all, {
$type: 'VM',
@@ -551,7 +551,7 @@ export default {
return hostId
}
),
vms => vms.map(vm => vm.$id)
vms => vms.map(vm => vm.$ref)
)
// Put master in first position to restart it first
@@ -623,20 +623,23 @@ export default {
continue
}
const vmIds = vmsByHost[hostId]
const vmRefs = vmRefsByHost[hostId]
if (vmIds === undefined) {
if (vmRefs === undefined) {
continue
}
const residentVms = host.$resident_VMs.map(vm => vm.uuid)
// host.$resident_VMs is outdated and returns resident VMs before the host.evacuate.
// this.getField is used in order not to get cached data.
const residentVmRefs = await this.getField('host', host.$ref, 'resident_VMs')
for (const vmId of vmIds) {
if (residentVms.includes(vmId)) {
for (const vmRef of vmRefs) {
if (residentVmRefs.includes(vmRef)) {
continue
}
try {
const vmId = await this.getField('VM', vmRef, 'uuid')
await this.migrateVm(vmId, this, hostId)
} catch (err) {
log.error(err)