Hook into error callback in kopia (#2555)

## Description

Using this over extracting errors from the snapshot allows us to see all errors. The errors that each directory tracks are truncated when the directory is serialized for persistence if there're too many.

With the current `fault.Errors` behavior this cases the backup to fail if there's any errors
kopia ignored. This is consistent with behavior in the backup op that checks for any errors.

Unclear what the CLI output and log messages will be for these errors as they are grouped
into all other errors reported through the fault package

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

- [ ]  Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [x]  No 

## Type of change

- [ ] 🌻 Feature
- [x] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Test
- [ ] 💻 CI/Deployment
- [ ] 🧹 Tech Debt/Cleanup

## Issue(s)

* #2548

## Test Plan

- [ ] 💪 Manual
- [x]  Unit test
- [ ] 💚 E2E
This commit is contained in:
ashmrtn 2023-02-16 20:32:44 -08:00 committed by GitHub
parent 7b9ba935e8
commit 0ff218ab3e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -257,6 +257,16 @@ func (cp *corsoProgress) CachedFile(fname string, size int64) {
d.cached = true d.cached = true
} }
// Kopia interface function used as a callback when kopia encounters an error
// during the upload process. This could be from reading a file or something
// else.
func (cp *corsoProgress) Error(relpath string, err error, isIgnored bool) {
defer cp.UploadProgress.Error(relpath, err, isIgnored)
cp.errs.Add(clues.Wrap(err, "kopia reported error").
WithAll("is_ignored", isIgnored, "relative_path", relpath))
}
func (cp *corsoProgress) put(k string, v *itemDetails) { func (cp *corsoProgress) put(k string, v *itemDetails) {
cp.mu.Lock() cp.mu.Lock()
defer cp.mu.Unlock() defer cp.mu.Unlock()

View File

@ -483,7 +483,7 @@ func (suite *KopiaIntegrationSuite) TestBackupCollections_ReaderError() {
tags, tags,
true, true,
fault.New(true)) fault.New(true))
require.NoError(t, err) require.Error(t, err)
assert.Equal(t, 0, stats.ErrorCount) assert.Equal(t, 0, stats.ErrorCount)
assert.Equal(t, 5, stats.TotalFileCount) assert.Equal(t, 5, stats.TotalFileCount)