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
feat(providers): expand PutBlob API to allow for idempotent puts #1654
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1654 +/- ##
==========================================
- Coverage 70.72% 70.69% -0.04%
==========================================
Files 386 386
Lines 30760 30775 +15
==========================================
Hits 21755 21755
- Misses 7336 7351 +15
Partials 1669 1669
Continue to review full report at Codecov.
|
Is this only going to work for GCS? What about S3-like providers? |
Currently only GCS, yes. If/When S3 has support for write-once then we can extend. |
9ab4138
to
ac8ce66
Compare
ac8ce66
to
54ee2ce
Compare
When `DoNotRecreate` is set as true, the blob put operation should only succeed if no blob with the given blob ID already exists. Othwerwise, `ErrBlobAlreadyExists` is returned.
By default, storage providers should not support idempotent creates. This commit adds error handling to exit early if `DoNotRecreate` is set to true. The commit also verifies this behavior in the provider validation test.
When PutBlob options were introduced, error handling logic for them was implemented for the Sharded storage interface. However, the behavior of different providers that implement Sharded can be different, so it's better to push the options down to be processed in the provider implementations.
54ee2ce
to
48aaf2d
Compare
To unify error handling code and make it more maintainable, introduce a new error type `blob.ErrUnsupportedPutBlobOption`, which is to be returned whenever a storage provider implementation is given put options it does not support.
48aaf2d
to
4fd99d9
Compare
LGTM, although I'm still unsure how broadly useful this will be, if GCS is the only provider that can support it. |
Thank you @jkowalski, I will also investigate other storage providers and add support in future PRs as is possible. |
There was a small regression in kopia#1654 - only in negative tests. Also removed unnecessary retries on ErrUnsupportedPutBlobOption + switched provider test to run once per day, instead of 12 times/day.
There was a small regression in #1654 - only in negative tests. Also removed unnecessary retries on ErrUnsupportedPutBlobOption + switched provider test to run once per day, instead of 12 times/day.
Today, executing a PutBlob operation will always overwrite a blob if it exists. It would be helpful for some customer workflows to be able to write blobs only if they don't exist (i.e. don't overwrite/recreate blobs). This PR expands the PutBlob API with an additional option
DoNotRecreate
, which toggles this feature. Note that not all backends support idempotent creates, so this PR also implements error logic to rejects such PutBlobs if they can't be executed.