From 2d6b827fd282a5f02b1b97b72264378e9e2c354c Mon Sep 17 00:00:00 2001 From: Florent BEAUCHAMP Date: Mon, 26 Sep 2022 14:50:30 +0200 Subject: [PATCH] fix(xo-server): ignore disabled remotes when running VM backup (#6430) --- CHANGELOG.unreleased.md | 1 + .../src/xo-mixins/backups-ng/index.mjs | 21 ++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index a22267ec4..ca3f257a9 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -22,6 +22,7 @@ - [Tasks] Fix the pool filter that did not display tasks even if they existed (PR [#6424](https://github.com/vatesfr/xen-orchestra/pull/6424)) - [Tasks] Fix tasks being displayed for all users (PR [#6422](https://github.com/vatesfr/xen-orchestra/pull/6422)) - [Storage/advanced] Fix the display of VDI to coalesce [#6334](https://xcp-ng.org/forum/topic/6334/coalesce-not-showing-anymore) (PR [#6429](https://github.com/vatesfr/xen-orchestra/pull/6429)) +- [Backup] Ignore disabled remotes instead of failing the execution [#6347](https://github.com/vatesfr/xen-orchestra/issues/6374) (PR [#6430](https://github.com/vatesfr/xen-orchestra/pull/6430)) ### Packages to release diff --git a/packages/xo-server/src/xo-mixins/backups-ng/index.mjs b/packages/xo-server/src/xo-mixins/backups-ng/index.mjs index 05e23e667..06733673c 100644 --- a/packages/xo-server/src/xo-mixins/backups-ng/index.mjs +++ b/packages/xo-server/src/xo-mixins/backups-ng/index.mjs @@ -193,9 +193,17 @@ export default class BackupNg { const remotes = {} const xapis = {} + const remoteErrors = {} await waitAll([ asyncMapSettled(remoteIds, async id => { - const remote = await app.getRemoteWithCredentials(id) + let remote + try { + remote = await app.getRemoteWithCredentials(id) + } catch (error) { + log.warn('Error while instantiating remote', { error, remoteId: id }) + remoteErrors[id] = error + return + } if (remote.proxy !== proxyId) { throw new Error( proxyId === undefined @@ -221,6 +229,17 @@ export default class BackupNg { } }), ]) + if (Object.keys(remotes).length === 0) { + const error = new Error(`couldn't instantiate any remote`) + error.errors = remoteErrors + throw error + } + // update remotes list with only the enabled remotes + job.remotes = { + id: { + __or: Object.keys(remotes), + }, + } const params = { job,