feat(xo-server,xo-web): disable HA during Rolling Pool Update (#6057)

See #5711
This commit is contained in:
Pierre Donias 2021-12-16 10:29:13 +01:00 committed by GitHub
parent c080db814b
commit a07c5418e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 44 additions and 2 deletions

View File

@ -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)) - [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)) - [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)) - [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 ### Bug fixes

View File

@ -478,7 +478,15 @@ export default {
throw new Error('non pool-wide install not implemented') 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' }) const hosts = filter(this.objects.all, { $type: 'host' })
await Promise.all(hosts.map(host => host.$call('assert_can_evacuate'))) await Promise.all(hosts.map(host => host.$call('assert_can_evacuate')))

View File

@ -1003,6 +1003,7 @@ const messages = {
rollingPoolUpdate: 'Rolling pool update', rollingPoolUpdate: 'Rolling pool update',
rollingPoolUpdateMessage: 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.', '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.', 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', vmsHaveCds: '{nVms, number} VM{nVms, plural, one {} other {s}} {nVms, plural, one {has} other {have}} CDs',
ejectCds: 'Eject CDs', ejectCds: 'Eject CDs',

View File

@ -936,9 +936,10 @@ export const installAllPatchesOnPool = ({ pool }) => {
) )
} }
import RollingPoolUpdateModal from './rolling-pool-updates-modal' // eslint-disable-line import/first
export const rollingPoolUpdate = poolId => export const rollingPoolUpdate = poolId =>
confirm({ confirm({
body: _('rollingPoolUpdateMessage'), body: <RollingPoolUpdateModal pool={poolId} />,
title: _('rollingPoolUpdate'), title: _('rollingPoolUpdate'),
icon: 'pool-rolling-update', icon: 'pool-rolling-update',
}).then( }).then(

View File

@ -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>
)
}
}