feat(xo-web/host): manage evacuation failure during host shutdown (#5966)

This commit is contained in:
Rajaa.BARHTAOUI 2021-10-28 14:23:43 +02:00 committed by GitHub
parent de1d942b90
commit 1d069683ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 9 deletions

View File

@ -14,6 +14,7 @@
- [Servers] Ability to use an HTTP proxy between XO and a server - [Servers] Ability to use an HTTP proxy between XO and a server
- [Pool/advanced] Ability to define network for importing/exporting VMs/VDIs (PR [#5957](https://github.com/vatesfr/xen-orchestra/pull/5957)) - [Pool/advanced] Ability to define network for importing/exporting VMs/VDIs (PR [#5957](https://github.com/vatesfr/xen-orchestra/pull/5957))
- [Menu] Notify user when proxies need to be upgraded (PR [#5930](https://github.com/vatesfr/xen-orchestra/pull/5930)) - [Menu] Notify user when proxies need to be upgraded (PR [#5930](https://github.com/vatesfr/xen-orchestra/pull/5930))
- [Host] Handle evacuation failure during host shutdown (PR [#5966](https://github.com/vatesfr/xen-orchestra/pull/#5966))
### Bug fixes ### Bug fixes

View File

@ -183,14 +183,15 @@ start.resolve = {
// ------------------------------------------------------------------- // -------------------------------------------------------------------
export function stop({ host }) { export function stop({ host, bypassEvacuate }) {
return this.getXapi(host).shutdownHost(host._xapiId) return this.getXapi(host).shutdownHost(host._xapiId, { bypassEvacuate })
} }
stop.description = 'stop the host' stop.description = 'stop the host'
stop.params = { stop.params = {
id: { type: 'string' }, id: { type: 'string' },
bypassEvacuate: { type: 'boolean', optional: true },
} }
stop.resolve = { stop.resolve = {

View File

@ -297,10 +297,13 @@ export default class Xapi extends XapiBase {
await this.call('host.syslog_reconfigure', host.$ref) await this.call('host.syslog_reconfigure', host.$ref)
} }
async shutdownHost(hostId, force = false) { async shutdownHost(hostId, { force = false, bypassEvacuate = false }) {
const host = this.getObject(hostId) const host = this.getObject(hostId)
if (bypassEvacuate) {
await this.clearHost(host, force) await this.call('host.disable', host.$ref)
} else {
await this.clearHost(host, force)
}
await this.callAsync('host.shutdown', host.$ref) await this.callAsync('host.shutdown', host.$ref)
} }

View File

@ -1655,6 +1655,8 @@ const messages = {
stopHostModalTitle: 'Shutdown host', stopHostModalTitle: 'Shutdown host',
stopHostModalMessage: stopHostModalMessage:
"This will shutdown your host. Do you want to continue? If it's the pool master, your connection to the pool will be lost", "This will shutdown your host. Do you want to continue? If it's the pool master, your connection to the pool will be lost",
forceStopHost: 'Force shutdown host',
forceStopHostMessage: 'This will shutdown your host without evacuating its VMs. Do you want to continue?',
addHostModalTitle: 'Add host', addHostModalTitle: 'Add host',
addHostModalMessage: 'Are you sure you want to add {host} to {pool}?', addHostModalMessage: 'Are you sure you want to add {host} to {pool}?',
restartHostModalTitle: 'Restart host', restartHostModalTitle: 'Restart host',

View File

@ -807,11 +807,26 @@ export const restartHostsAgents = hosts => {
export const startHost = host => _call('host.start', { id: resolveId(host) }) export const startHost = host => _call('host.start', { id: resolveId(host) })
export const stopHost = host => export const stopHost = async host => {
confirm({ await confirm({
title: _('stopHostModalTitle'),
body: _('stopHostModalMessage'), body: _('stopHostModalMessage'),
}).then(() => _call('host.stop', { id: resolveId(host) }), noop) title: _('stopHostModalTitle'),
})
try {
await _call('host.stop', { id: resolveId(host) })
} catch (err) {
if (err.message === 'no hosts available') {
// Retry with bypassEvacuate.
await confirm({
body: _('forceStopHostMessage'),
title: _('forceStopHost'),
})
return _call('host.stop', { id: resolveId(host), bypassEvacuate: true })
}
throw error
}
}
export const stopHosts = hosts => { export const stopHosts = hosts => {
const nHosts = size(hosts) const nHosts = size(hosts)