diff --git a/src/internal/events/events.go b/src/internal/events/events.go index 99c1651ac..63eaf6cb3 100644 --- a/src/internal/events/events.go +++ b/src/internal/events/events.go @@ -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" diff --git a/src/internal/operations/backup.go b/src/internal/operations/backup.go index 80b74277e..2992ecaec 100644 --- a/src/internal/operations/backup.go +++ b/src/internal/operations/backup.go @@ -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, diff --git a/src/internal/operations/export.go b/src/internal/operations/export.go index 6f09b8c5d..2eba8076e 100644 --- a/src/internal/operations/export.go +++ b/src/internal/operations/export.go @@ -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, diff --git a/src/internal/operations/maintenance.go b/src/internal/operations/maintenance.go index 4c4003733..85bf7f233 100644 --- a/src/internal/operations/maintenance.go +++ b/src/internal/operations/maintenance.go @@ -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, diff --git a/src/internal/operations/restore.go b/src/internal/operations/restore.go index dc05836e3..95d63dc36 100644 --- a/src/internal/operations/restore.go +++ b/src/internal/operations/restore.go @@ -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, diff --git a/src/internal/operations/restore_test.go b/src/internal/operations/restore_test.go index d8d1767e5..6c3a9ab4b 100644 --- a/src/internal/operations/restore_test.go +++ b/src/internal/operations/restore_test.go @@ -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") } diff --git a/src/internal/operations/test/exchange_test.go b/src/internal/operations/test/exchange_test.go index a2ff84fd8..38f875f3a 100644 --- a/src/internal/operations/test/exchange_test.go +++ b/src/internal/operations/test/exchange_test.go @@ -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],