-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Track BackupEngine and BackupStorageHandle errors together. #6350
Conversation
(Yes, I need to document, and also fix the interface implementation for all the other implementations of BackupHandle) Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
The `s3iface` type is an interface listing all the methods that the `s3` struct implements, with the added benefit of being able to swap in mock implementations in tests. Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work! +100 for writing a unit test.
It will be nice to reword the long comment so that it works as a standalone explanation without reference to the diff.
Co-authored-by: Deepthi Sigireddi <deepthi.sigireddi@gmail.com> Signed-off-by: Andrew Mason <amason@slack-corp.com>
Signed-off-by: Andrew Mason <amason@slack-corp.com>
f8952ef
to
3c3822c
Compare
|
||
wc, err := bh.AddFile(aws.BackgroundContext(), "somefile", 100000) | ||
require.NoErrorf(t, err, "AddFile() expected no error, got %s", err) | ||
assert.NotEqual(t, nil, wc, "AddFile() expected non-nil WriteCloser") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's also an assert.NotNil, but I'll accept this.
Signed-off-by: Andrew Mason <amason@slack-corp.com>
Track BackupEngine and BackupStorageHandle errors together.
Track BackupEngine and BackupStorageHandle errors together.
This addresses #6349.
This change requires
BackupHandle
to implement theconcurrency.ErrorRecorder
interface in order to guarantee that errors that happen either in the backup engine code or in the backup storage handle code end up in the same place. This provides a single place for builtinbackupengine to check for errors before proceeding with writing the manifest.This also required adding
ErrorRecorder
to certain BackupStorage implementations that didn't previously need them (filebackupstorage
,gcsbackupstorage
), and allowed me to turn simplify some calls (i.e.bh.errors.HasErrors()
becomesbh.HasErrors()
) in other implemtations (s3backupstorage
,azblobbackupstorage
,cephbackupstorage
).Finally, I added a test for the builtinbackupengine+s3backupstorage error case, which required me to change the typing of
S3BackupHandle.client
from*s3.S3
to the recommendeds3iface.S3API
which is just the interface that*s3.S3
implements.