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-server,xo-web): disable HA during Rolling Pool Update #6057

Merged
merged 3 commits into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -11,6 +11,7 @@
- [Health] Display default SRs that aren't shared [#5871](https://github.com/vatesfr/xen-orchestra/issues/5871) (PR [#6033](https://github.com/vatesfr/xen-orchestra/pull/6033))
- [Pool,VM/advanced] Ability to change the suspend SR [#4163](https://github.com/vatesfr/xen-orchestra/issues/4163) (PR [#6044](https://github.com/vatesfr/xen-orchestra/pull/6044))
- [Home/VMs/Backup filter] Filter out VMs in disabled backup jobs (PR [#6037](https://github.com/vatesfr/xen-orchestra/pull/6037))
- [Rolling Pool Update] Automatically disable High Availability during the update [#5711](https://github.com/vatesfr/xen-orchestra/issues/5711) (PR [#6057](https://github.com/vatesfr/xen-orchestra/pull/6057))

### Bug fixes

Expand Down
10 changes: 9 additions & 1 deletion packages/xo-server/src/xapi/mixins/patching.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,15 @@ export default {
throw new Error('non pool-wide install not implemented')
},

async rollingPoolUpdate() {
@decorateWith(deferrable)
async rollingPoolUpdate($defer) {
if (this.pool.ha_enabled) {
const haSrs = this.pool.$ha_statefiles.map(vdi => vdi.SR)
const haConfig = this.pool.ha_configuration
await this.call('pool.disable_ha')
$defer(() => this.call('pool.enable_ha', haSrs, haConfig))
}

const hosts = filter(this.objects.all, { $type: 'host' })
await Promise.all(hosts.map(host => host.$call('assert_can_evacuate')))

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 @@ -1003,6 +1003,7 @@ const messages = {
rollingPoolUpdate: 'Rolling pool update',
rollingPoolUpdateMessage:
'Are you sure you want to start a rolling pool update? Running VMs will be migrated back and forth and this can take a while.',
rollingPoolUpdateHaWarning: 'High Availability is enabled. This will automatically disable it during the update.',
poolNeedsDefaultSr: 'The pool needs a default SR to install the patches.',
vmsHaveCds: '{nVms, number} VM{nVms, plural, one {} other {s}} {nVms, plural, one {has} other {have}} CDs',
ejectCds: 'Eject CDs',
Expand Down
3 changes: 2 additions & 1 deletion packages/xo-web/src/common/xo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -936,9 +936,10 @@ export const installAllPatchesOnPool = ({ pool }) => {
)
}

import RollingPoolUpdateModal from './rolling-pool-updates-modal' // eslint-disable-line import/first
export const rollingPoolUpdate = poolId =>
confirm({
body: _('rollingPoolUpdateMessage'),
body: <RollingPoolUpdateModal pool={poolId} />,
title: _('rollingPoolUpdate'),
icon: 'pool-rolling-update',
}).then(
Expand Down
31 changes: 31 additions & 0 deletions packages/xo-web/src/common/xo/rolling-pool-updates-modal/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import _ from 'intl'
import BaseComponent from 'base-component'
import Icon from 'icon'
import React from 'react'
import { connectStore } from 'utils'
import { createGetObjectsOfType } from 'selectors'

@connectStore(
{
pools: createGetObjectsOfType('pool'),
},
{ withRef: true }
)
export default class RollingPoolUpdateModal extends BaseComponent {
render() {
const pool = this.props.pools[this.props.pool]

return (
<div>
<p>{_('rollingPoolUpdateMessage')}</p>
{pool.HA_enabled && (
<p>
<em className='text-warning'>
<Icon icon='alarm' /> {_('rollingPoolUpdateHaWarning')}
</em>
</p>
)}
</div>
)
}
}