handle error from bu.backupCollections (#2386)

## Does this PR need a docs update or release note?

- [x]  No 

## Type of change

- [x] 🐛 Bugfix

## Test Plan

- [x] 💚 E2E
This commit is contained in:
Keepers 2023-02-02 23:18:41 -07:00 committed by GitHub
parent 76c2ac628b
commit 0be38909dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 16 deletions

View File

@ -167,6 +167,12 @@ func (op *BackupOperation) do(ctx context.Context) (err error) {
// persist operation results to the model store on exit
defer func() {
// panic recovery here prevents additional errors in op.persistResults()
if r := recover(); r != nil {
err = clues.Wrap(r.(error), "panic recovery").WithClues(ctx).With("stacktrace", debug.Stack())
return
}
err = op.persistResults(startTime, &opStats)
if err != nil {
op.Errors.Fail(errors.Wrap(err, "persisting backup results"))
@ -445,24 +451,22 @@ func consumeBackupDataCollections(
cs,
nil,
tags,
isIncremental,
)
isIncremental)
if err != nil {
if kopiaStats == nil {
return nil, nil, nil, err
}
return nil, nil, nil, errors.Wrapf(
err,
"kopia snapshot failed with %v catastrophic errors and %v ignored errors",
kopiaStats.ErrorCount, kopiaStats.IgnoredErrorCount)
}
if kopiaStats.ErrorCount > 0 || kopiaStats.IgnoredErrorCount > 0 {
if err != nil {
err = errors.Wrapf(
err,
"kopia snapshot failed with %v catastrophic errors and %v ignored errors",
kopiaStats.ErrorCount,
kopiaStats.IgnoredErrorCount,
)
} else {
err = errors.Errorf(
"kopia snapshot failed with %v catastrophic errors and %v ignored errors",
kopiaStats.ErrorCount,
kopiaStats.IgnoredErrorCount,
)
}
err = errors.Errorf(
"kopia snapshot failed with %v catastrophic errors and %v ignored errors",
kopiaStats.ErrorCount, kopiaStats.IgnoredErrorCount)
}
return kopiaStats, deets, itemsSourcedFromBase, err

View File

@ -151,6 +151,12 @@ func (op *RestoreOperation) do(ctx context.Context) (restoreDetails *details.Det
)
defer func() {
// panic recovery here prevents additional errors in op.persistResults()
if r := recover(); r != nil {
err = clues.Wrap(r.(error), "panic recovery").WithClues(ctx).With("stacktrace", debug.Stack())
return
}
err = op.persistResults(ctx, startTime, &opStats)
if err != nil {
return