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(backups): expose NBD settings per backup #6995

Merged
merged 5 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions @xen-orchestra/backups/_incrementalVm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export async function exportIncrementalVm(
fullVdisRequired = new Set(),

disableBaseTags = false,
preferNbd,
} = {}
) {
// refs of VM's VDIs → base's VDIs.
Expand Down Expand Up @@ -88,6 +89,7 @@ export async function exportIncrementalVm(
baseRef: baseVdi?.$ref,
cancelToken,
format: 'vhd',
preferNbd,
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const IncrementalXapi = class IncrementalXapiVmBackupRunner extends Abstr

const deltaExport = await exportIncrementalVm(exportedVm, baseVm, {
fullVdisRequired,
preferNbd: this._settings.preferNbd,
})
// since NBD is network based, if one disk use nbd , all the disk use them
// except the suspended VDI
Expand Down
4 changes: 2 additions & 2 deletions @xen-orchestra/xapi/vdi.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class Vdi {
}
}

async exportContent(ref, { baseRef, cancelToken = CancelToken.none, format }) {
async exportContent(ref, { baseRef, cancelToken = CancelToken.none, format, preferNbd = this._preferNbd }) {
const query = {
format,
vdi: ref,
Expand All @@ -96,7 +96,7 @@ class Vdi {
}
let nbdClient, stream
try {
if (this._preferNbd) {
if (preferNbd) {
nbdClient = await this._getNbdClient(ref)
}
// the raw nbd export does not need to peek ath the vhd source
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

> Users must be able to say: “Nice enhancement, I'm eager to test it”

- [Backups] Ability to set the NBD mode per backup job in the UI instead of globally in the config file (PR [#6995](https://github.com/vatesfr/xen-orchestra/pull/6995))

### Bug fixes

> Users must be able to say: “I had this issue, happy to know it's fixed”
Expand All @@ -29,6 +31,9 @@

<!--packages-start-->

- @xen-orchestra/backups minor
- @xen-orchestra/xapi minor
- xo-server patch
- xo-web minor

<!--packages-end-->
2 changes: 2 additions & 0 deletions packages/xo-web/src/common/intl/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,8 @@ const messages = {
'Delete old backups before backing up the VMs. If the new backup fails, you will lose your old backups.',
customTag: 'Custom tag',
editJobNotFound: "The job you're trying to edit wasn't found",
preferNbd: 'Use NBD protocol to transfer disk if available',
preferNbdInformation: 'A network accessible by XO or the proxy must have NBD enabled',

// ------ New Remote -----
newRemote: 'New file system remote',
Expand Down
41 changes: 34 additions & 7 deletions packages/xo-web/src/xo-app/backup/new/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { generateId, linkState } from 'reaclette-utils'
import { injectIntl } from 'react-intl'
import { injectState, provideState } from 'reaclette'
import { Map } from 'immutable'
import { Number } from 'form'
import { Number, Toggle } from 'form'
import { renderXoItemFromId, Remote } from 'render-xo-item'
import { SelectRemote, SelectSr, SelectVm } from 'select-objects'
import {
Expand Down Expand Up @@ -148,6 +148,7 @@ const normalizeSettings = ({ copyMode, exportMode, offlineBackupActive, settings
copyRetention: copyMode ? setting.copyRetention : undefined,
exportRetention: exportMode ? setting.exportRetention : undefined,
snapshotRetention: snapshotMode && !offlineBackupActive ? setting.snapshotRetention : undefined,
preferNbd: undefined,
}
: setting
)
Expand Down Expand Up @@ -187,6 +188,7 @@ const getInitialState = ({ preSelectedVmIds, setHomeVmIdsSelection, suggestedExc
deltaMode: false,
drMode: false,
name: '',
preferNbd: false,
remotes: [],
schedules: {},
settings: undefined,
Expand All @@ -213,12 +215,11 @@ export const DeleteOldBackupsFirst = ({ handler, handlerParam, value }) => (
)

const New = decorate([
New => props =>
(
<Upgrade place='newBackup' required={2}>
<New {...props} />
</Upgrade>
),
New => props => (
<Upgrade place='newBackup' required={2}>
<New {...props} />
</Upgrade>
),
connectStore(() => ({
hostsById: createGetObjectsOfType('host'),
poolsById: createGetObjectsOfType('pool'),
Expand Down Expand Up @@ -621,13 +622,21 @@ const New = decorate([
offlineBackup,
})
},
setPreferNbd:
({ setGlobalSettings }, preferNbd) =>
() => {
setGlobalSettings({
preferNbd,
})
},
},
computed: {
compressionId: generateId,
formId: generateId,
inputConcurrencyId: generateId,
inputFullIntervalId: generateId,
inputMaxExportRate: generateId,
inputPreferNbd: generateId,
inputTimeoutId: generateId,

// In order to keep the user preference, the offline backup is kept in the DB
Expand Down Expand Up @@ -741,6 +750,7 @@ const New = decorate([
maxExportRate,
offlineBackup,
offlineSnapshot,
preferNbd,
reportRecipients,
reportWhen = 'failure',
timeout,
Expand Down Expand Up @@ -1013,6 +1023,23 @@ const New = decorate([
/>
</FormGroup>
)}
{state.isDelta && (
<FormGroup>
<label htmlFor={state.inputPreferNbd}>
<strong>{_('preferNbd')}</strong>{' '}
<Tooltip content={_('preferNbdInformation')}>
<Icon icon='info' />
</Tooltip>
</label>
<Toggle
className='pull-right'
id={state.inputPreferNbd}
name='preferNbd'
value={preferNbd}
onChange={effects.setPreferNbd}
/>
MathieuRA marked this conversation as resolved.
Show resolved Hide resolved
</FormGroup>
)}
<FormGroup>
<label htmlFor={state.inputMaxExportRate}>
<strong>{_('speedLimit')}</strong>
Expand Down