fix(xo-server,xo-web): fix total number of VDIs to coalesce (#7098)

Fixes #7016

Summing all chains does take not common chains into account, the total must be computed on the server side.
This commit is contained in:
Julien Fontanet 2023-10-18 11:52:43 +02:00 committed by GitHub
parent 00a1778a6d
commit a3b8553cec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View File

@ -19,6 +19,7 @@
- [RPU] Fix "XenServer credentials not found" when running a Rolling Pool Update on a XenServer pool (PR [#7089](https://github.com/vatesfr/xen-orchestra/pull/7089))
- [Usage report] Fix "Converting circular structure to JSON" error
- [Home] Fix OS icons alignment (PR [#7090](https://github.com/vatesfr/xen-orchestra/pull/7090))
- [SR/Advanced] Fix the total number of VDIs to coalesce by taking into account common chains [#7016](https://github.com/vatesfr/xen-orchestra/issues/7016) (PR [#7098](https://github.com/vatesfr/xen-orchestra/pull/7098))
### Packages to release

View File

@ -49,18 +49,19 @@ export default {
await this._unplugPbd(this.getObject(id))
},
_getVdiChainsInfo(uuid, childrenMap, cache) {
_getVdiChainsInfo(uuid, childrenMap, cache, resultContainer) {
let info = cache[uuid]
if (info === undefined) {
const children = childrenMap[uuid]
const unhealthyLength = children !== undefined && children.length === 1 ? 1 : 0
resultContainer.nUnhealthyVdis += unhealthyLength
const vdi = this.getObjectByUuid(uuid, undefined)
if (vdi === undefined) {
info = { unhealthyLength, missingParent: uuid }
} else {
const parent = vdi.sm_config['vhd-parent']
if (parent !== undefined) {
info = this._getVdiChainsInfo(parent, childrenMap, cache)
info = this._getVdiChainsInfo(parent, childrenMap, cache, resultContainer)
info.unhealthyLength += unhealthyLength
} else {
info = { unhealthyLength }
@ -76,12 +77,13 @@ export default {
const unhealthyVdis = { __proto__: null }
const children = groupBy(vdis, 'sm_config.vhd-parent')
const vdisWithUnknownVhdParent = { __proto__: null }
const resultContainer = { nUnhealthyVdis: 0 }
const cache = { __proto__: null }
forEach(vdis, vdi => {
if (vdi.managed && !vdi.is_a_snapshot) {
const { uuid } = vdi
const { unhealthyLength, missingParent } = this._getVdiChainsInfo(uuid, children, cache)
const { unhealthyLength, missingParent } = this._getVdiChainsInfo(uuid, children, cache, resultContainer)
if (unhealthyLength !== 0) {
unhealthyVdis[uuid] = unhealthyLength
@ -95,6 +97,7 @@ export default {
return {
vdisWithUnknownVhdParent,
unhealthyVdis,
...resultContainer,
}
},

View File

@ -10,7 +10,7 @@ import { CustomFields } from 'custom-fields'
import { createGetObjectsOfType } from 'selectors'
import { createSelector } from 'reselect'
import { createSrUnhealthyVdiChainsLengthSubscription, deleteSr, reclaimSrSpace, toggleSrMaintenanceMode } from 'xo'
import { flowRight, isEmpty, keys, sum, values } from 'lodash'
import { flowRight, isEmpty, keys } from 'lodash'
// ===================================================================
@ -44,11 +44,11 @@ const UnhealthyVdiChains = flowRight(
connectStore(() => ({
vdis: createGetObjectsOfType('VDI').pick(createSelector((_, props) => props.chains?.unhealthyVdis, keys)),
}))
)(({ chains: { unhealthyVdis } = {}, vdis }) =>
)(({ chains: { nUnhealthyVdis, unhealthyVdis } = {}, vdis }) =>
isEmpty(vdis) ? null : (
<div>
<hr />
<h3>{_('srUnhealthyVdiTitle', { total: sum(values(unhealthyVdis)) })}</h3>
<h3>{_('srUnhealthyVdiTitle', { total: nUnhealthyVdis })}</h3>
<SortedTable collection={vdis} columns={COLUMNS} stateUrlParam='s_unhealthy_vdis' userData={unhealthyVdis} />
</div>
)