add corso error event

This commit is contained in:
neha-Gupta1 2023-10-05 20:56:10 +05:30
parent 02db885c1e
commit 46a4cc0d53
7 changed files with 58 additions and 0 deletions

View File

@ -33,6 +33,7 @@ const (
RepoConnect = "Repo Connect"
BackupStart = "Backup Start"
BackupEnd = "Backup End"
CorsoError = "Corso Error"
RestoreStart = "Restore Start"
RestoreEnd = "Restore End"
ExportStart = "Export Start"
@ -50,11 +51,13 @@ const (
ItemsRead = "items_read"
ItemsWritten = "items_written"
Resources = "resources"
ResourcesName = "resources_name"
RestoreID = "restore_id"
ExportID = "export_id"
Service = "service"
StartTime = "start_time"
Status = "status"
Command = "command"
// default values for keys
RepoIDNotFound = "not_found"

View File

@ -257,6 +257,21 @@ func (op *BackupOperation) Run(ctx context.Context) (err error) {
})
defer func() {
if op.Errors.Failure() != nil {
op.bus.Event(
ctx,
events.CorsoError,
map[string]any{
events.Resources: op.ResourceOwner.ID(),
events.ResourcesName: op.ResourceOwner.Name(),
events.Service: op.Selectors.PathService().String(),
events.StartTime: dttm.Format(op.Results.StartedAt),
events.Status: op.Status.String(),
events.BackupID: op.Results.BackupID,
events.Command: "Backup",
})
}
op.bus.Event(
ctx,
events.BackupEnd,

View File

@ -141,6 +141,19 @@ func (op *ExportOperation) Run(ctx context.Context) (
"service", op.Selectors.Service)
defer func() {
if op.Errors.Failure() != nil {
op.bus.Event(
ctx,
events.CorsoError,
map[string]any{
events.Service: op.Selectors.PathService().String(),
events.StartTime: dttm.Format(op.Results.StartedAt),
events.Status: op.Status.String(),
events.BackupID: op.BackupID,
events.Command: "Export",
})
}
op.bus.Event(
ctx,
events.ExportEnd,

View File

@ -65,6 +65,18 @@ func (op *MaintenanceOperation) Run(ctx context.Context) (err error) {
})
defer func() {
if op.Errors.Failure() != nil {
op.bus.Event(
ctx,
events.CorsoError,
map[string]any{
events.Resources: op.mOpts.Type.String(),
events.StartTime: dttm.Format(op.Results.StartedAt),
events.Status: op.Status.String(),
events.Command: "Maintenance",
})
}
op.bus.Event(
ctx,
events.MaintenanceEnd,

View File

@ -146,6 +146,19 @@ func (op *RestoreOperation) Run(ctx context.Context) (restoreDetails *details.De
"destination_container", clues.Hide(op.RestoreCfg.Location))
defer func() {
if op.Errors.Failure() != nil {
op.bus.Event(
ctx,
events.CorsoError,
map[string]any{
events.Service: op.Selectors.PathService().String(),
events.StartTime: dttm.Format(op.Results.StartedAt),
events.Status: op.Status.String(),
events.BackupID: op.BackupID,
events.Command: "Restore",
})
}
op.bus.Event(
ctx,
events.RestoreEnd,

View File

@ -368,5 +368,6 @@ func (suite *RestoreOpIntegrationSuite) TestRestore_Run_errorNoBackup() {
assert.Zero(t, ro.Results.BytesRead, "bytes read")
// no restore start, because we'd need to find the backup first.
assert.Equal(t, 0, mb.TimesCalled[events.RestoreStart], "restore-start events")
assert.Equal(t, 1, mb.TimesCalled[events.CorsoError], "corso-error events")
assert.Equal(t, 1, mb.TimesCalled[events.RestoreEnd], "restore-end events")
}

View File

@ -227,6 +227,7 @@ func (suite *ExchangeBackupIntgSuite) TestBackup_Run_exchange() {
assert.NoError(t, incBO.Errors.Failure(), "incremental non-recoverable error", clues.ToCore(bo.Errors.Failure()))
assert.Empty(t, incBO.Errors.Recovered(), "count incremental recoverable/iteration errors")
assert.Equal(t, 1, incMB.TimesCalled[events.BackupStart], "incremental backup-start events")
assert.Equal(t, 0, incMB.TimesCalled[events.CorsoError], "corso error events")
assert.Equal(t, 1, incMB.TimesCalled[events.BackupEnd], "incremental backup-end events")
assert.Equal(t,
incMB.CalledWith[events.BackupStart][0][events.BackupID],