Compare commits
7 Commits
main
...
addErrorEv
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
492c02e758 | ||
|
|
78347af93e | ||
|
|
50d8e1af6b | ||
|
|
ec9c72be10 | ||
|
|
7bca07e8a5 | ||
|
|
3c30f56dfe | ||
|
|
46a4cc0d53 |
@ -45,11 +45,14 @@ const (
|
|||||||
ItemsRead = "items_read"
|
ItemsRead = "items_read"
|
||||||
ItemsWritten = "items_written"
|
ItemsWritten = "items_written"
|
||||||
Resources = "resources"
|
Resources = "resources"
|
||||||
|
ResourcesName = "resources_name"
|
||||||
RestoreID = "restore_id"
|
RestoreID = "restore_id"
|
||||||
ExportID = "export_id"
|
ExportID = "export_id"
|
||||||
Service = "service"
|
Service = "service"
|
||||||
StartTime = "start_time"
|
StartTime = "start_time"
|
||||||
Status = "status"
|
Status = "status"
|
||||||
|
Command = "command"
|
||||||
|
ErrorMessage = "error"
|
||||||
|
|
||||||
// default values for keys
|
// default values for keys
|
||||||
RepoIDNotFound = "not_found"
|
RepoIDNotFound = "not_found"
|
||||||
|
|||||||
@ -248,10 +248,7 @@ func (op *BackupOperation) Run(ctx context.Context) (err error) {
|
|||||||
"disable_assist_backup", op.disableAssistBackup)
|
"disable_assist_backup", op.disableAssistBackup)
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
op.bus.Event(
|
data := map[string]any{
|
||||||
ctx,
|
|
||||||
events.BackupEnd,
|
|
||||||
map[string]any{
|
|
||||||
events.BackupID: op.Results.BackupID,
|
events.BackupID: op.Results.BackupID,
|
||||||
events.DataStored: op.Results.BytesUploaded,
|
events.DataStored: op.Results.BytesUploaded,
|
||||||
events.Duration: op.Results.CompletedAt.Sub(op.Results.StartedAt),
|
events.Duration: op.Results.CompletedAt.Sub(op.Results.StartedAt),
|
||||||
@ -260,7 +257,16 @@ func (op *BackupOperation) Run(ctx context.Context) (err error) {
|
|||||||
events.Service: op.Selectors.PathService().String(),
|
events.Service: op.Selectors.PathService().String(),
|
||||||
events.StartTime: dttm.Format(op.Results.StartedAt),
|
events.StartTime: dttm.Format(op.Results.StartedAt),
|
||||||
events.Status: op.Status.String(),
|
events.Status: op.Status.String(),
|
||||||
})
|
}
|
||||||
|
|
||||||
|
if op.Errors.Failure() != nil {
|
||||||
|
data[events.ErrorMessage] = op.Errors.Errors().Failure.Msg
|
||||||
|
}
|
||||||
|
|
||||||
|
op.bus.Event(
|
||||||
|
ctx,
|
||||||
|
events.BackupEnd,
|
||||||
|
data)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
|
|||||||
@ -144,10 +144,7 @@ func (op *ExportOperation) Run(ctx context.Context) (
|
|||||||
"service", op.Selectors.Service)
|
"service", op.Selectors.Service)
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
op.bus.Event(
|
data := map[string]any{
|
||||||
ctx,
|
|
||||||
events.ExportEnd,
|
|
||||||
map[string]any{
|
|
||||||
events.BackupID: op.BackupID,
|
events.BackupID: op.BackupID,
|
||||||
events.DataRetrieved: op.Results.BytesRead,
|
events.DataRetrieved: op.Results.BytesRead,
|
||||||
events.Duration: op.Results.CompletedAt.Sub(op.Results.StartedAt),
|
events.Duration: op.Results.CompletedAt.Sub(op.Results.StartedAt),
|
||||||
@ -159,7 +156,16 @@ func (op *ExportOperation) Run(ctx context.Context) (
|
|||||||
events.Service: op.Selectors.Service.String(),
|
events.Service: op.Selectors.Service.String(),
|
||||||
events.StartTime: dttm.Format(op.Results.StartedAt),
|
events.StartTime: dttm.Format(op.Results.StartedAt),
|
||||||
events.Status: op.Status.String(),
|
events.Status: op.Status.String(),
|
||||||
})
|
}
|
||||||
|
|
||||||
|
if op.Errors.Failure() != nil {
|
||||||
|
data[events.ErrorMessage] = op.Errors.Errors()
|
||||||
|
}
|
||||||
|
|
||||||
|
op.bus.Event(
|
||||||
|
ctx,
|
||||||
|
events.ExportEnd,
|
||||||
|
data)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
|
|||||||
@ -58,16 +58,22 @@ func (op *MaintenanceOperation) Run(ctx context.Context) (err error) {
|
|||||||
op.Results.StartedAt = time.Now()
|
op.Results.StartedAt = time.Now()
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
op.bus.Event(
|
data := map[string]any{
|
||||||
ctx,
|
|
||||||
events.MaintenanceEnd,
|
|
||||||
map[string]any{
|
|
||||||
events.StartTime: op.Results.StartedAt,
|
events.StartTime: op.Results.StartedAt,
|
||||||
events.Duration: op.Results.CompletedAt.Sub(op.Results.StartedAt),
|
events.Duration: op.Results.CompletedAt.Sub(op.Results.StartedAt),
|
||||||
events.EndTime: dttm.Format(op.Results.CompletedAt),
|
events.EndTime: dttm.Format(op.Results.CompletedAt),
|
||||||
events.Status: op.Status.String(),
|
events.Status: op.Status.String(),
|
||||||
events.Resources: op.mOpts.Type.String(),
|
events.Resources: op.mOpts.Type.String(),
|
||||||
})
|
}
|
||||||
|
|
||||||
|
if op.Errors.Failure() != nil {
|
||||||
|
data[events.ErrorMessage] = op.Errors.Errors()
|
||||||
|
}
|
||||||
|
|
||||||
|
op.bus.Event(
|
||||||
|
ctx,
|
||||||
|
events.MaintenanceEnd,
|
||||||
|
data)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return op.do(ctx)
|
return op.do(ctx)
|
||||||
|
|||||||
@ -146,10 +146,7 @@ func (op *RestoreOperation) Run(ctx context.Context) (restoreDetails *details.De
|
|||||||
"destination_container", clues.Hide(op.RestoreCfg.Location))
|
"destination_container", clues.Hide(op.RestoreCfg.Location))
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
op.bus.Event(
|
data := map[string]any{
|
||||||
ctx,
|
|
||||||
events.RestoreEnd,
|
|
||||||
map[string]any{
|
|
||||||
events.BackupID: op.BackupID,
|
events.BackupID: op.BackupID,
|
||||||
events.DataRetrieved: op.Results.BytesRead,
|
events.DataRetrieved: op.Results.BytesRead,
|
||||||
events.Duration: op.Results.CompletedAt.Sub(op.Results.StartedAt),
|
events.Duration: op.Results.CompletedAt.Sub(op.Results.StartedAt),
|
||||||
@ -161,7 +158,16 @@ func (op *RestoreOperation) Run(ctx context.Context) (restoreDetails *details.De
|
|||||||
events.Service: op.Selectors.Service.String(),
|
events.Service: op.Selectors.Service.String(),
|
||||||
events.StartTime: dttm.Format(op.Results.StartedAt),
|
events.StartTime: dttm.Format(op.Results.StartedAt),
|
||||||
events.Status: op.Status.String(),
|
events.Status: op.Status.String(),
|
||||||
})
|
}
|
||||||
|
|
||||||
|
if op.Errors.Failure() != nil {
|
||||||
|
data[events.ErrorMessage] = op.Errors.Errors()
|
||||||
|
}
|
||||||
|
|
||||||
|
op.bus.Event(
|
||||||
|
ctx,
|
||||||
|
events.RestoreEnd,
|
||||||
|
data)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// -----
|
// -----
|
||||||
|
|||||||
@ -366,6 +366,5 @@ func (suite *RestoreOpIntegrationSuite) TestRestore_Run_errorNoBackup() {
|
|||||||
require.Nil(t, ds, "restoreOp.Run() should not produce details")
|
require.Nil(t, ds, "restoreOp.Run() should not produce details")
|
||||||
assert.Zero(t, ro.Results.ResourceOwners, "resource owners")
|
assert.Zero(t, ro.Results.ResourceOwners, "resource owners")
|
||||||
assert.Zero(t, ro.Results.BytesRead, "bytes read")
|
assert.Zero(t, ro.Results.BytesRead, "bytes read")
|
||||||
// no restore start, because we'd need to find the backup first.
|
|
||||||
assert.Equal(t, 1, mb.TimesCalled[events.RestoreEnd], "restore-end events")
|
assert.Equal(t, 1, mb.TimesCalled[events.RestoreEnd], "restore-end events")
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user