From a07c5418e98395f200e3e1a60939d919c8d0dcf8 Mon Sep 17 00:00:00 2001 From: Pierre Donias Date: Thu, 16 Dec 2021 10:29:13 +0100 Subject: [PATCH] feat(xo-server,xo-web): disable HA during Rolling Pool Update (#6057) See #5711 --- CHANGELOG.unreleased.md | 1 + .../xo-server/src/xapi/mixins/patching.mjs | 10 +++++- packages/xo-web/src/common/intl/messages.js | 1 + packages/xo-web/src/common/xo/index.js | 3 +- .../xo/rolling-pool-updates-modal/index.js | 31 +++++++++++++++++++ 5 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 packages/xo-web/src/common/xo/rolling-pool-updates-modal/index.js diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index d631a135b..583fec844 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -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 diff --git a/packages/xo-server/src/xapi/mixins/patching.mjs b/packages/xo-server/src/xapi/mixins/patching.mjs index 96f240067..82daf821d 100644 --- a/packages/xo-server/src/xapi/mixins/patching.mjs +++ b/packages/xo-server/src/xapi/mixins/patching.mjs @@ -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'))) diff --git a/packages/xo-web/src/common/intl/messages.js b/packages/xo-web/src/common/intl/messages.js index 16ed43753..9234b1bd8 100644 --- a/packages/xo-web/src/common/intl/messages.js +++ b/packages/xo-web/src/common/intl/messages.js @@ -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', diff --git a/packages/xo-web/src/common/xo/index.js b/packages/xo-web/src/common/xo/index.js index adbe5e560..b1b5d6c89 100644 --- a/packages/xo-web/src/common/xo/index.js +++ b/packages/xo-web/src/common/xo/index.js @@ -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: , title: _('rollingPoolUpdate'), icon: 'pool-rolling-update', }).then( diff --git a/packages/xo-web/src/common/xo/rolling-pool-updates-modal/index.js b/packages/xo-web/src/common/xo/rolling-pool-updates-modal/index.js new file mode 100644 index 000000000..1c8ce9983 --- /dev/null +++ b/packages/xo-web/src/common/xo/rolling-pool-updates-modal/index.js @@ -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 ( +
+

{_('rollingPoolUpdateMessage')}

+ {pool.HA_enabled && ( +

+ + {_('rollingPoolUpdateHaWarning')} + +

+ )} +
+ ) + } +}