Skip to content

Commit

Permalink
fix(backups): handles task end in CR without health check (#6866)
Browse files Browse the repository at this point in the history
  • Loading branch information
fbeauchamp committed May 30, 2023
1 parent 8b7b162 commit 3f316fc
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 11 deletions.
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
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

0 comments on commit 3f316fc

Please sign in to comment.