Skip to content

Commit

Permalink
fix(xo-server/rest-api/dashboard): fix 'no such VM <uuid>' when calcu…
Browse files Browse the repository at this point in the history
…lating vms protection (#8013)
  • Loading branch information
MathieuRA authored Sep 27, 2024
1 parent 943ad78 commit 0e9242b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/xo-server/src/xo-mixins/rest-api.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,15 @@ async function _getDashboardStats(app) {
return false
}

/**
* Some IDs may not exists anymore
* @param {object} job
* @returns {string[]}
*/
function _extractVmIdsFromBackupJob(job) {
let vmIds
try {
vmIds = extractIdsFromSimplePattern(job.vms).filter(vmId => app.hasObject(vmId, 'VM'))
vmIds = extractIdsFromSimplePattern(job.vms)
} catch (_) {
const predicate = createPredicate(job.vms)
vmIds = nonReplicaVms.filter(predicate).map(vm => vm.id)
Expand All @@ -324,7 +329,7 @@ async function _getDashboardStats(app) {
}

function _updateVmProtection(vmId, isProtected) {
if (vmIdsProtected.has(vmId)) {
if (vmIdsProtected.has(vmId) || !app.hasObject(vmId, 'VM')) {
return
}

Expand Down

0 comments on commit 0e9242b

Please sign in to comment.