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

fix(backups): handles task end in CR without health check #6866

Merged
merged 7 commits into from
May 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 10 additions & 2 deletions @xen-orchestra/backups/_runners/_vmRunners/_Abstract.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,17 @@ exports.Abstract = class AbstractVmBackupRunner {
const intersect = settings.healthCheckVmsWithTags.some(t => tags.includes(t))

if (settings.healthCheckVmsWithTags.length !== 0 && !intersect) {
return
// create a task to have an info in the logs and reports
return Task.run(
{
name: 'health check',
},
() => {
Task.info(`This VM doesn't match the health check's tags for this schedule`)
}
)
}

await this._callWriters(writer => writer.healthCheck(this._healthCheckSr), 'writer.healthCheck()')
await this._callWriters(writer => writer.healthCheck(), 'writer.healthCheck()')
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ exports.AbstractRemote = class AbstractRemoteVmBackupRunner extends Abstract {
...settings,
...allSettings[remoteId],
}
writers.add(new RemoteWriter({ adapter, config, job, vmUuid, remoteId, settings: targetSettings }))
writers.add(new RemoteWriter({ adapter, config, healthCheckSr, job, vmUuid, remoteId, settings: targetSettings }))
})
}

Expand Down
4 changes: 2 additions & 2 deletions @xen-orchestra/backups/_runners/_vmRunners/_AbstractXapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class AbstractXapiVmBackupRunner extends Abstract {
...allSettings[remoteId],
}
if (targetSettings.exportRetention !== 0) {
writers.add(new BackupWriter({ adapter, config, job, vmUuid: vm.uuid, remoteId, settings: targetSettings }))
writers.add(new BackupWriter({ adapter, config, healthCheckSr, job, vmUuid: vm.uuid, remoteId, settings: targetSettings }))
}
})
srs.forEach(sr => {
Expand All @@ -89,7 +89,7 @@ class AbstractXapiVmBackupRunner extends Abstract {
...allSettings[sr.uuid],
}
if (targetSettings.copyRetention !== 0) {
writers.add(new ReplicationWriter({ config, job, vmUuid: vm.uuid, sr, settings: targetSettings }))
writers.add(new ReplicationWriter({ config, healthCheckSr, job, vmUuid: vm.uuid, sr, settings: targetSettings}))
}
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,10 @@ exports.IncrementalXapiWriter = class IncrementalXapiWriter extends MixinXapiWri
type: 'SR',
},
})
const hasHealthCheckSr = this._healthCheckSr !== undefined
this.transfer = task.wrapFn(this.transfer)
this.cleanup = task.wrapFn(this.cleanup)
this.healthCheck = task.wrapFn(this.healthCheck, true)
this.cleanup = task.wrapFn(this.cleanup, !hasHealthCheckSr)
this.healthCheck = task.wrapFn(this.healthCheck, hasHealthCheckSr)

return task.run(() => this._prepare())
}
Expand Down
3 changes: 2 additions & 1 deletion @xen-orchestra/backups/_runners/_writers/_AbstractWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ const { formatFilenameDate } = require('../../_filenameDate')
const { getVmBackupDir } = require('../../_getVmBackupDir')

exports.AbstractWriter = class AbstractWriter {
constructor({ config, job, vmUuid, scheduleId, settings }) {
constructor({ config, healthCheckSr, job, vmUuid, scheduleId, settings }) {
this._config = config
this._healthCheckSr = healthCheckSr
julien-f marked this conversation as resolved.
Show resolved Hide resolved
this._job = job
this._scheduleId = scheduleId
this._settings = settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ exports.MixinRemoteWriter = (BaseClass = Object) =>
}
}

healthCheck(sr) {
healthCheck() {
const sr = this._healthCheckSr
assert.notStrictEqual(sr, undefined, 'SR should be defined before making a health check')
assert.notStrictEqual(
this._metadataFileName,
undefined,
Expand Down
4 changes: 3 additions & 1 deletion @xen-orchestra/backups/_runners/_writers/_MixinXapiWriter.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ exports.MixinXapiWriter = (BaseClass = Object) =>
this._sr = sr
}

healthCheck(sr) {
healthCheck() {
const sr = this._healthCheckSr
assert.notStrictEqual(sr, undefined, 'SR should be defined before making a health check')
assert.notEqual(this._targetVmRef, undefined, 'A vm should have been transfered to be health checked')
// copy VM
return Task.run(
Expand Down
2 changes: 1 addition & 1 deletion @xen-orchestra/backups/docs/VM backups/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ Settings are described in [`@xen-orchestra/backups/Backup.js](https://github.com
- `prepare({ isFull })`
- `transfer({ timestamp, deltaExport, sizeContainers })`
- `cleanup()`
- `healthCheck(sr)`
- `healthCheck()` // is not executed if no health check sr or tag doesn't match
- **Full**
- `run({ timestamp, sizeContainer, stream })`
- `afterBackup()`
2 changes: 2 additions & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

> Users must be able to say: “I had this issue, happy to know it's fixed”

- [Incremental Replication] Fix task showing as *interrupted* when running without health check [Forum#62669](https://xcp-ng.org/forum/post/62669) (PR [#6866](https://github.com/vatesfr/xen-orchestra/pull/6866))

### Packages to release

> When modifying a package, add it here with its release type.
Expand Down