Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(xo-web/pool): disable Rolling Pool Update if pool has 1 host #7286

Merged
merged 8 commits into from
Jan 22, 2024
Merged
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
- [File restore] Fix potential race condition in partition mount/unmount (PR [#7312](https://github.com/vatesfr/xen-orchestra/pull/7312))
- [Modal] Fix opened modal not closing when navigating to another route/URL (PR [#7301](https://github.com/vatesfr/xen-orchestra/pull/7301))
- [Backup/Restore] Don't count memory as a key (i.e. complete) disk [Forum#8212](https://xcp-ng.org/forum/post/69591) (PR [#7315](https://github.com/vatesfr/xen-orchestra/pull/7315))
- [Pool/patches] Disable Rolling Pool Update button if host is alone in its pool [#6415](https://github.com/vatesfr/xen-orchestra/issues/6415) (PR [#7286](https://github.com/vatesfr/xen-orchestra/pull/7286))

### Packages to release

Expand Down
2 changes: 2 additions & 0 deletions packages/xo-web/src/common/intl/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,8 @@ const messages = {
noNbdConnection: 'No NBD Connection',
nbdConnection: 'NBD Connection',
insecureNbdConnection: 'Insecure NBD Connection (not allowed through XO)',
// ----- Pool patches tab -----
multiHostPoolUpdate: "Rolling pool update can only work when there's multiple hosts in a pool with a shared storage",
// ----- Pool stats tab -----
poolNoStats: 'No stats',
poolAllHosts: 'All hosts',
Expand Down
15 changes: 13 additions & 2 deletions packages/xo-web/src/xo-app/pool/tab-patches.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Upgrade from 'xoa-upgrade'
import { addSubscriptions, connectStore, formatSize } from 'utils'
import { alert } from 'modal'
import { Col, Container, Row } from 'grid'
import { createGetObjectsOfType } from 'selectors'
import { createGetObjectsOfType, createSelector } from 'selectors'
import { FormattedRelative, FormattedTime } from 'react-intl'
import { getXoaPlan, ENTERPRISE } from 'xoa-plans'
import {
Expand All @@ -17,6 +17,7 @@ import {
subscribeHostMissingPatches,
} from 'xo'
import isEmpty from 'lodash/isEmpty.js'
import size from 'lodash/size.js'

const ROLLING_POOL_UPDATES_AVAILABLE = getXoaPlan().value >= ENTERPRISE.value

Expand Down Expand Up @@ -166,6 +167,12 @@ const INSTALLED_PATCH_COLUMNS = [
}))
@connectStore({
hostPatches: createGetObjectsOfType('patch').pick((_, { master }) => master.patches),
poolHosts: createGetObjectsOfType('host').filter(
createSelector(
(_, props) => props.pool.id,
poolId => host => host.$pool === poolId
)
),
})
export default class TabPatches extends Component {
render() {
Expand All @@ -174,11 +181,14 @@ export default class TabPatches extends Component {
master: { productBrand },
missingPatches = [],
pool,
poolHosts,
userPreferences,
} = this.props

const needsCredentials = productBrand !== 'XCP-ng' && userPreferences.xsCredentials === undefined

const isSingleHost = size(poolHosts) < 2

return (
<Upgrade place='poolPatches' required={2}>
<Container>
Expand All @@ -187,11 +197,12 @@ export default class TabPatches extends Component {
{ROLLING_POOL_UPDATES_AVAILABLE && (
<TabButton
btnStyle='primary'
disabled={isEmpty(missingPatches)}
disabled={isEmpty(missingPatches) || isSingleHost}
handler={rollingPoolUpdate}
handlerParam={pool.id}
icon='pool-rolling-update'
labelId='rollingPoolUpdate'
tooltip={isSingleHost ? _('multiHostPoolUpdate') : undefined}
/>
)}
<TabButton
Expand Down