fix(xo-server): change current_operations display for xo host and poo… (#10283)

This commit is contained in:
ayoub-el-kajji-v
2026-09-08 14:54:24 +02:00
committed by GitHub
parent c9391b075e
commit dc107da91a
2 changed files with 26 additions and 14 deletions

View File

@@ -26,6 +26,8 @@
- [Servers] Fix endless connection attempts to a pool which is already connected through another server entry (PR [#10355](https://github.com/vatesfr/xen-orchestra/pull/10355))
- [Servers] fix a mishandling in the grace period before marking a pool disconnected, this will keep the ui in sync AND not redownload all the xapi object for a transient issue (PR [#10355](https://github.com/vatesfr/xen-orchestra/pull/10355))
- [Rolling pool update/reboot] VMs are brought back to the host they were running on more reliably, and a VM that cannot be moved back no longer fails the whole operation (PR [#10295](https://github.com/vatesfr/xen-orchestra/pull/10295))
- [XO server] Fix current_operations format on host and pool objects (PR [#10283](https://github.com/vatesfr/xen-orchestra/pull/10283))
### Packages to release

View File

@@ -71,6 +71,27 @@ function toTimestamp(date) {
}
}
/**
* Builds a `{ taskId -> operation }` map from an XAPI object's raw
* `current_operations` (`{ OpaqueRef -> operation }`), dropping any entry
* whose task is no longer present in the local cache (e.g. it finished and
* was collected).
*
* This lets consumers know an operation is truly over once it disappears
* from the map, instead of seeing a stale entry forever.
*/
function getCurrentOperations(obj) {
const currentOperations = {}
const { $xapi } = obj
forEach(obj.current_operations, (operation, ref) => {
const task = $xapi.getObjectByRef(ref, undefined)
if (task !== undefined) {
currentOperations[task.$id] = operation
}
})
return currentOperations
}
// https://github.com/xenserver/xenadmin/blob/093ab0bcd6c4b3dd69da7b1e63ef34bb807c1ddb/XenModel/XenAPI-Extensions/VM.cs#L773-L827
const getVmGuestToolsProps = vm => {
const { $metrics: metrics, $guest_metrics: guestMetrics } = vm
@@ -180,7 +201,7 @@ const TRANSFORMS = {
return {
auto_poweron: obj.other_config.auto_poweron === 'true',
crashDumpSr: link(obj, 'crash_dump_SR'),
current_operations: obj.current_operations,
current_operations: getCurrentOperations(obj),
default_SR: link(obj, 'default_SR'),
HA_enabled: Boolean(obj.ha_enabled),
haRebootVmOnInternalShutdown: obj.ha_reboot_vm_on_internal_shutdown ?? true,
@@ -267,7 +288,7 @@ const TRANSFORMS = {
cores: cpuInfo && +cpuInfo.cpu_count,
sockets: cpuInfo && +cpuInfo.socket_count,
},
current_operations: obj.current_operations,
current_operations: getCurrentOperations(obj),
hostname: obj.hostname,
iscsiIqn: obj.iscsi_iqn ?? otherConfig.iscsi_iqn ?? '',
zstdSupported: obj.license_params.restrict_zstd_export === 'false',
@@ -398,17 +419,6 @@ const TRANSFORMS = {
}
}
// Build a { taskId → operation } map instead of forwarding the
// { taskRef → operation } map directly
const currentOperations = {}
const { $xapi } = obj
forEach(obj.current_operations, (operation, ref) => {
const task = $xapi.getObjectByRef(ref, undefined)
if (task !== undefined) {
currentOperations[task.$id] = operation
}
})
const { creation } = xoData.extract(obj) ?? {}
let $container
@@ -456,7 +466,7 @@ const TRANSFORMS = {
number: isRunning && metrics && xenTools ? +metrics.VCPUs_number : +obj.VCPUs_at_startup,
},
creation,
current_operations: currentOperations,
current_operations: getCurrentOperations(obj),
docker: (function () {
const monitor = otherConfig['xscontainer-monitor']
if (!monitor) {