Skip to content

Commit

Permalink
fix(xo-server/Rolling Pool Update/_xcpUpdate): handle undefined hosts (
Browse files Browse the repository at this point in the history
…#6186)

Fixes #6170
Introduced by e7f9111
  • Loading branch information
pdonias authored Apr 13, 2022
1 parent ef819f4 commit 3f1c41a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
- [Plugins] Automatically configure plugins when a configuration file is imported (PR [#6171](https://github.com/vatesfr/xen-orchestra/pull/6171))
- [VMDK Export] Fix `VBOX_E_FILE_ERROR (0x80BB0004)` when importing in VirtualBox (PR [#6163](https://github.com/vatesfr/xen-orchestra/pull/6163))
- [Backup] Fix "Cannot read properties of undefined" error when restoring from a proxied remote (PR [#6179](https://github.com/vatesfr/xen-orchestra/pull/6179))
- [Rolling Pool Update] Fix "cannot read properties of undefined" error [#6170](https://github.com/vatesfr/xen-orchestra/issues/6170) (PR [#6186](https://github.com/vatesfr/xen-orchestra/pull/6186))

### Packages to release

Expand Down
4 changes: 1 addition & 3 deletions packages/xo-server/src/api/pool.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,13 @@ listMissingPatches.resolve = {
// -------------------------------------------------------------------

export async function installPatches({ pool, patches, hosts }) {
const opts = { patches }
let xapi
if (pool !== undefined) {
pool = this.getXapiObject(pool, 'pool')
xapi = pool.$xapi
hosts = Object.values(xapi.objects.indexes.type.host)
} else {
hosts = hosts.map(_ => this.getXapiObject(_))
opts.hosts = hosts
xapi = hosts[0].$xapi
pool = xapi.pool
}
Expand All @@ -138,7 +136,7 @@ export async function installPatches({ pool, patches, hosts }) {
})
}

await xapi.installPatches(opts)
await xapi.installPatches({ hosts, patches })

const masterRef = pool.master
if (moveFirst(hosts, _ => _.$ref === masterRef)) {
Expand Down
4 changes: 4 additions & 0 deletions packages/xo-server/src/xapi/mixins/patching.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,10 @@ export default {
// INSTALL -------------------------------------------------------------------

async _xcpUpdate(hosts) {
if (hosts === undefined) {
hosts = Object.values(this.objects.indexes.type.host)
}

// XCP-ng hosts need to be updated one at a time starting with the pool master
// https://github.com/vatesfr/xen-orchestra/issues/4468
hosts = hosts.sort(({ $ref }) => ($ref === this.pool.master ? -1 : 1))
Expand Down

0 comments on commit 3f1c41a

Please sign in to comment.