feat(xo-server-usage-report): ignore replicated VMs (#5241)

Fixes #4778
This commit is contained in:
badrAZ 2020-09-04 11:42:32 +02:00 committed by GitHub
parent 6fd45a37e2
commit c77016ea44
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 11 deletions

View File

@ -7,6 +7,8 @@
> Users must be able to say: “Nice enhancement, I'm eager to test it” > Users must be able to say: “Nice enhancement, I'm eager to test it”
- [Usage report] Exclude replicated VMs from the VMs evolution [#4778](https://github.com/vatesfr/xen-orchestra/issues/4778) (PR [#5241](https://github.com/vatesfr/xen-orchestra/pull/5241))
### Bug fixes ### Bug fixes
> Users must be able to say: “I had this issue, happy to know it's fixed” > Users must be able to say: “I had this issue, happy to know it's fixed”
@ -27,3 +29,5 @@
> - major: if the change breaks compatibility > - major: if the change breaks compatibility
> >
> In case of conflict, the highest (lowest in previous list) `$version` wins. > In case of conflict, the highest (lowest in previous list) `$version` wins.
- xo-server-usage-report minor

View File

@ -405,16 +405,26 @@ async function getSrsStats({ xo, xoObjects }) {
} }
function computeGlobalVmsStats({ haltedVms, vmsStats, xo }) { function computeGlobalVmsStats({ haltedVms, vmsStats, xo }) {
const allVms = concat( const allVms = vmsStats.map(vm => ({
map(vmsStats, vm => ({
uuid: vm.uuid, uuid: vm.uuid,
name: vm.name, name: vm.name,
})), }))
map(haltedVms, vm => ({
haltedVms.forEach(vm => {
const isReplication =
'start' in vm.blockedOperations &&
vm.tags.some(
tag => tag === 'Disaster Recovery' || tag === 'Continuous Replication'
)
// Exclude replicated VMs because they keep being created/destroyed due to the implementation
if (!isReplication) {
allVms.push({
uuid: vm.uuid, uuid: vm.uuid,
name: vm.name_label, name: vm.name_label,
})) })
) }
})
return Object.assign( return Object.assign(
computeMeans(vmsStats, [ computeMeans(vmsStats, [
@ -426,7 +436,7 @@ function computeGlobalVmsStats({ haltedVms, vmsStats, xo }) {
'netTransmission', 'netTransmission',
]), ]),
{ {
number: allVms.length, number: vmsStats.length + haltedVms.length,
allVms, allVms,
} }
) )