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
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- Avoid unnecessary `pool.add_to_other_config: Duplicate key` error in XAPI log [Forum#68761](https://xcp-ng.org/forum/post/68761)
- [Jobs] Reset parameters when editing method to avoid invalid parameters on execution [Forum#69299](https://xcp-ng.org/forum/post/69299)
- [Metadata Backup] Fix `ENOENT` error when restoring an _XO Config_ backup [Forum#68999](https://xcp-ng.org/forum/post/68999)
- [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 @@ -937,6 +937,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
Loading