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-web/host): ask for confirmation to reboot the updated slave host if the master is not #7293

Merged
merged 5 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -8,6 +8,7 @@
> Users must be able to say: “Nice enhancement, I'm eager to test it”

- [Settings/Logs] Use GitHub issue form with pre-filled fields when reporting a bug [#7142](https://github.com/vatesfr/xen-orchestra/issues/7142) (PR [#7274](https://github.com/vatesfr/xen-orchestra/pull/7274))
- [Host/Reboot] Confirmation modal to reboot an updated slave host if the master is not [#7059](https://github.com/vatesfr/xen-orchestra/issues/7059) (PR [#7293](https://github.com/vatesfr/xen-orchestra/pull/7293))

### Bug fixes

Expand Down
22 changes: 22 additions & 0 deletions packages/xo-server/src/api/host.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,25 @@ export async function restart({

bypassBlockedSuspend = force,
bypassCurrentVmCheck = force,
bypassVersionCheck = force,
}) {

if (bypassVersionCheck) {
log.warn('host.restart with argument "bypassVersionCheck" set to true', { hostId: host.id })
} else {
const pool = this.getObject(host.$poolId, 'pool')
const master = this.getObject(pool.master, 'host')
const hostRebootRequired = host.rebootRequired
if (hostRebootRequired && host.id !== master.id && host.version === master.version) {
throw incorrectState({
actual: hostRebootRequired,
expected: false,
object: host.id,
MathieuRA marked this conversation as resolved.
Show resolved Hide resolved
property: 'rebootRequired',
})
}
}

if (bypassBackupCheck) {
log.warn('host.restart with argument "bypassBackupCheck" set to true', { hostId: host.id })
} else {
Expand Down Expand Up @@ -165,6 +183,10 @@ restart.params = {
type: 'boolean',
default: false,
},
bypassVersionCheck: {
type: 'boolean',
optional: true,
},
}

restart.resolve = {
Expand Down
3 changes: 3 additions & 0 deletions packages/xo-web/src/common/intl/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,8 @@ const messages = {
// ----- Host actions ------
disableMaintenanceMode: 'Disable maintenance mode',
enableMaintenanceMode: 'Enable maintenance mode',
slaveHostMoreUpToDateThanMasterAfterReboot:
'It appears that your slave host will be more up-to-date than the master after the reboot. This will result in the slave being unable to contact the pool master. Please update and reboot your master node first.',
pdonias marked this conversation as resolved.
Show resolved Hide resolved
startHostLabel: 'Start',
stopHostLabel: 'Stop',
enableHostLabel: 'Enable',
Expand All @@ -978,6 +980,7 @@ const messages = {
forceRebootHostLabel: 'Force reboot',
forceSmartRebootHost:
'Smart Reboot failed because {nVms, number} VM{nVms, plural, one {} other {s}} ha{nVms, plural, one {s} other {ve}} {nVms, plural, one {its} other {their}} Suspend operation blocked. Would you like to force?',
rebootAnyway: 'Reboot anyway',
rebootHostLabel: 'Reboot',
noHostsAvailableErrorTitle: 'Error while restarting host',
noHostsAvailableErrorMessage:
Expand Down
21 changes: 21 additions & 0 deletions packages/xo-web/src/common/xo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,21 @@ const _restartHost = async ({ host, ...opts }) => {
return _restartHost({ ...opts, host, bypassBackupCheck: true })
}

if (masterNeedUpdate(error)) {
await chooseAction({
body: (
<p>
<Icon icon='alarm' /> {_('slaveHostMoreUpToDateThanMasterAfterReboot')}
</p>
),
buttons: [{ label: _('rebootAnyway'), btnStyle: 'warning' }],
pdonias marked this conversation as resolved.
Show resolved Hide resolved
icon: 'alarm',
title: _('restartHostModalTitle'),
})

return _restartHost({ ...opts, host, bypassVersionCheck: true })
}

if (noHostsAvailableErrCheck(error)) {
alert(_('noHostsAvailableErrorTitle'), _('noHostsAvailableErrorMessage'))
}
Expand All @@ -926,6 +941,12 @@ const backupIsRunning = (err, poolId) =>
forbiddenOperation.is(err, {
reason: `A backup is running on the pool: ${poolId}`,
}))
const masterNeedUpdate = err =>
pdonias marked this conversation as resolved.
Show resolved Hide resolved
err !== undefined &&
incorrectState.is(err, {
property: 'rebootRequired',
})

const noHostsAvailableErrCheck = err => err !== undefined && noHostsAvailable.is(err)

export const restartHosts = (hosts, force = false) => {
Expand Down
Loading