Skip to content

Commit

Permalink
feat(xo-server,xo-web): disable HA during Rolling Pool Update (#6057)
Browse files Browse the repository at this point in the history
See #5711
  • Loading branch information
pdonias authored Dec 16, 2021
1 parent c080db8 commit a07c541
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 2 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 @@
- [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>
)
}
}

0 comments on commit a07c541

Please sign in to comment.