feat(xo-server/patching): check date consistency before patching (#3292)

Fixes #3056
This commit is contained in:
Pierre Donias 2018-08-09 16:10:13 +02:00 committed by Julien Fontanet
parent 06d38808be
commit 8fbf2786fd
3 changed files with 19 additions and 1 deletions

View File

@ -14,6 +14,7 @@
- [Backup NG form] Move "Use compression" checkbox in the advanced settings [#2711](https://github.com/vatesfr/xen-orchestra/issues/2711) (PR [#3281](https://github.com/vatesfr/xen-orchestra/pull/3281))
- [Backup NG form] Ability to remove previous backups first before backup the VMs [#3212](https://github.com/vatesfr/xen-orchestra/issues/3212) (PR [#3260](https://github.com/vatesfr/xen-orchestra/pull/3260))
- [Backup reports] Send report for the interrupted backup jobs on the server startup [#2998](https://github.com/vatesfr/xen-orchestra/issues/#2998) (PR [3164](https://github.com/vatesfr/xen-orchestra/pull/3164) [3154](https://github.com/vatesfr/xen-orchestra/pull/3154))
- [Patching] Check date consistency before patching to avoid error on install [#3056](https://github.com/vatesfr/xen-orchestra/issues/3056)
### Bug fixes

View File

@ -64,6 +64,7 @@ import {
isVmRunning,
NULL_REF,
optional,
parseDateTime,
prepareXapiParam,
} from './utils'
@ -2339,5 +2340,17 @@ export default class Xapi extends XapiBase {
)
}
// =================================================================
async _assertConsistentHostServerTime (hostRef) {
if (
Math.abs(
parseDateTime(
await this.call('host.get_servertime', hostRef)
).getTime() - Date.now()
) > 2e3
) {
throw new Error(
'host server time and XOA date are not consistent with each other'
)
}
}
}

View File

@ -320,6 +320,8 @@ export default {
patchUuid,
host
) {
await this._assertConsistentHostServerTime(host.$ref)
const [vdi] = await Promise.all([
this._getUpdateVdi($defer, patchUuid, host.$id),
this._ejectToolsIsos(host.$ref),
@ -361,6 +363,8 @@ export default {
// platform_version >= 2.1.1
_installPatchUpdateOnAllHosts: deferrable(async function ($defer, patchUuid) {
await this._assertConsistentHostServerTime(this.pool.master)
let [vdi] = await Promise.all([
this._getUpdateVdi($defer, patchUuid),
this._ejectToolsIsos(),