Skip to content

blob: introduce conditional write option for storage #3533

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

Merged
merged 1 commit into from
Apr 8, 2025

Conversation

ocampeau
Copy link
Contributor

@ocampeau ocampeau commented Mar 31, 2025

This commit introduces support for conditional writes for major cloud providers: aws, gcp, azure.

It does so by adding a new write options: IfNotExist.

When set to true, conditions are set for each cloud storage driver to enable the desired behavior.

Addresses #3518

Copy link

google-cla bot commented Mar 31, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@ocampeau ocampeau force-pushed the add-if-not-exists branch from cae6693 to 49d8bce Compare March 31, 2025 19:57
Copy link
Contributor

@vangent vangent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a drivertest that exercises this new feature?

It'll be tricky for you to verify on GCP/Azure/AWS, but you should be able to get it working with memblob and fileblob. Once you've done that, you can comment it out, we can get this merged, and then I can generate the goldens for the GCP/Azure/AWS packages.

@ocampeau ocampeau force-pushed the add-if-not-exists branch 3 times, most recently from d2fdaeb to 4114b43 Compare April 1, 2025 22:59
@ocampeau ocampeau changed the title blob: introduce conditional write option for gcp, s3, azure blob: introduce conditional write option for storage Apr 1, 2025
@ocampeau ocampeau force-pushed the add-if-not-exists branch 2 times, most recently from 8e5a572 to 69616e7 Compare April 1, 2025 23:13
@ocampeau
Copy link
Contributor Author

ocampeau commented Apr 1, 2025

Thanks @vangent for the quick feedback. I have provided the implementation for the fileblob and memblob driver. I also added a test in the drivertest package.

Following your suggestion, I ran the tests for the memblob and fileblob package, and they all passed. I haven't been able to test for the cloud providers though. I have commented out the test so you can run them in your CI as mentioned.

Let me know if there is anything else that needs to be fixed.

@ocampeau ocampeau requested a review from vangent April 2, 2025 12:21
Copy link

codecov bot commented Apr 2, 2025

Codecov Report

Attention: Patch coverage is 26.47059% with 25 lines in your changes missing coverage. Please review.

Project coverage is 70.47%. Comparing base (7caced7) to head (2b8057c).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
blob/fileblob/fileblob.go 36.84% 10 Missing and 2 partials ⚠️
blob/azureblob/azureblob.go 0.00% 6 Missing ⚠️
blob/memblob/memblob.go 25.00% 2 Missing and 1 partial ⚠️
blob/gcsblob/gcsblob.go 0.00% 1 Missing and 1 partial ⚠️
blob/s3blob/s3blob.go 0.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3533      +/-   ##
==========================================
- Coverage   70.55%   70.47%   -0.09%     
==========================================
  Files         113      113              
  Lines       14347    14382      +35     
==========================================
+ Hits        10123    10135      +12     
- Misses       3497     3515      +18     
- Partials      727      732       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ocampeau ocampeau force-pushed the add-if-not-exists branch from 69616e7 to 6d9598f Compare April 7, 2025 14:44
This commit introduces support for conditional writes.

It does so my adding a new write options: IfNotExist. When
set to true, conditions are set for each driver
to enable the desired behavior.
@ocampeau ocampeau force-pushed the add-if-not-exists branch from 6d9598f to 2b8057c Compare April 8, 2025 13:13
@ocampeau ocampeau requested a review from vangent April 8, 2025 13:15
@vangent
Copy link
Contributor

vangent commented Apr 8, 2025

For future reference, please don't rebase/force-push. It makes it so I have to review the whole PR again every time rather than just the commits/changes since my last review.

@vangent
Copy link
Contributor

vangent commented Apr 8, 2025

Thanks for the contribution!

@vangent vangent merged commit ee2a669 into google:master Apr 8, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants