Skip to content

Commit

Permalink
feat(xo-web/pool/host): add warning if hosts don't have the same vers…
Browse files Browse the repository at this point in the history
…ion (#7280)

Fixes #7059
  • Loading branch information
MathieuRA committed Jan 18, 2024
1 parent b7a66e9 commit c1c122d
Show file tree
Hide file tree
Showing 7 changed files with 310 additions and 217 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- [REST API] New pool action: `emergency_shutdown`, it suspends all the VMs and then shuts down all the host [#7277](https://github.com/vatesfr/xen-orchestra/issues/7277) (PR [#7279](https://github.com/vatesfr/xen-orchestra/pull/7279))
- [Tasks] Hide `/rrd_updates` tasks by default
- [Sign in] Support _Remember me_ feature with external providers (PR [#7298](https://github.com/vatesfr/xen-orchestra/pull/7298))
- [Pool/Host] Add a warning if hosts do not have the same version within a pool [#7059](https://github.com/vatesfr/xen-orchestra/issues/7059) (PR [#7280](https://github.com/vatesfr/xen-orchestra/pull/7280))

### Bug fixes

Expand Down
1 change: 1 addition & 0 deletions packages/xo-web/src/common/intl/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ const messages = {
powerState: 'Power state',
srSharedType: 'Shared {type}',
warningHostTimeTooltip: 'Host time and XOA time are not consistent with each other',
notAllHostsHaveTheSameVersion: 'Not all hosts within {pool} have the same version',
selectExistingTags: 'Select from existing tags',
sortByDisksUsage: 'Disks usage',

Expand Down
25 changes: 24 additions & 1 deletion packages/xo-web/src/xo-app/home/host-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
createSelector,
} from 'selectors'
import { injectState } from 'reaclette'
import { Host, Pool } from 'render-xo-item'

import MiniStats from './mini-stats'
import styles from './index.css'
Expand Down Expand Up @@ -126,13 +127,16 @@ export default class HostItem extends Component {
message,
}
}
_getAreHostsVersionsEqual = () => this.props.state.areHostsVersionsEqualByPool[this.props.item.$pool]

_getAlerts = createSelector(
() => this.props.needsRestart,
() => this.props.item,
this._isMaintained,
() => this.state.isHostTimeConsistentWithXoaTime,
(needsRestart, host, isMaintained, isHostTimeConsistentWithXoaTime) => {
this._getAreHostsVersionsEqual,
() => this.props.state.hostsByPoolId[this.props.item.$pool],
(needsRestart, host, isMaintained, isHostTimeConsistentWithXoaTime, areHostsVersionsEqual, poolHosts) => {
const alerts = []

if (needsRestart) {
Expand Down Expand Up @@ -201,6 +205,25 @@ export default class HostItem extends Component {
),
})
}

if (!areHostsVersionsEqual) {
alerts.push({
level: 'danger',
render: (
<div>
<p>
<Icon icon='alarm' /> {_('notAllHostsHaveTheSameVersion', { pool: <Pool id={host.$pool} link /> })}
</p>
<ul>
{map(poolHosts, host => (
<li>{_('keyValue', { key: <Host id={host.id} />, value: host.version })}</li>
))}
</ul>
</div>
),
})
}

return alerts
}
)
Expand Down
27 changes: 26 additions & 1 deletion packages/xo-web/src/xo-app/home/pool-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { addTag, editPool, getHostMissingPatches, removeTag } from 'xo'
import { connectStore, formatSizeShort } from 'utils'
import { compact, flatten, map, size, uniq } from 'lodash'
import { createGetObjectsOfType, createGetHostMetrics, createSelector } from 'selectors'
import { Host, Pool } from 'render-xo-item'
import { injectState } from 'reaclette'

import styles from './index.css'
Expand Down Expand Up @@ -101,10 +102,15 @@ export default class PoolItem extends Component {

_getPoolLicenseInfo = () => this.props.state.poolLicenseInfoByPoolId[this.props.item.id]

_getAreHostsVersionsEqual = () => this.props.state.areHostsVersionsEqualByPool[this.props.item.id]

_getAlerts = createSelector(
() => this.props.isAdmin,
this._getPoolLicenseInfo,
(isAdmin, poolLicenseInfo) => {
this._getAreHostsVersionsEqual,
() => this.props.poolHosts,
() => this.props.item.id,
(isAdmin, poolLicenseInfo, areHostsVersionsEqual, hosts, poolId) => {
const alerts = []

if (isAdmin && this._isXcpngPool()) {
Expand All @@ -120,6 +126,25 @@ export default class PoolItem extends Component {
})
}
}

if (!areHostsVersionsEqual) {
alerts.push({
level: 'danger',
render: (
<div>
<p>
<Icon icon='alarm' /> {_('notAllHostsHaveTheSameVersion', { pool: <Pool id={poolId} link /> })}
</p>
<ul>
{map(hosts, host => (
<li>{_('keyValue', { key: <Host id={host.id} />, value: host.version })}</li>
))}
</ul>
</div>
),
})
}

return alerts
}
)
Expand Down
Loading

0 comments on commit c1c122d

Please sign in to comment.