Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- [Warm migration] Fix `Vm target of warm migration not found` error at the end of a migration (PR [#10210](https://github.com/vatesfr/xen-orchestra/pull/10210))
- **XO 5**:
- [VM/Console] Fix the page header and tab navigation disappearing permanently in the console tab (PR [#10007](https://github.com/vatesfr/xen-orchestra/pull/10007))
- [XO server] Fix current_operations format on host and pool objects (PR [#10283](https://github.com/vatesfr/xen-orchestra/pull/10283))

### Packages to release

Expand Down Expand Up @@ -67,7 +68,7 @@
- xen-api minor
- xo-cli patch
- xo-common minor
- xo-server patch
- xo-server minor
- xo-server-ipmi-sensors minor
- xo-server-netbox patch
- xo-web patch
Expand Down
38 changes: 24 additions & 14 deletions packages/xo-server/src/xapi-object-to-xo.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
Loading