-
Notifications
You must be signed in to change notification settings - Fork 297
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
fix: minio error while creating bucket if already exists #3109
Conversation
02cdef7
to
5aac17b
Compare
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## release/1.7.x #3109 +/- ##
==============================================
Coverage 53.69% 53.70%
==============================================
Files 350 351 +1
Lines 54456 54459 +3
==============================================
+ Hits 29240 29247 +7
+ Misses 23563 23551 -12
- Partials 1653 1661 +8
... and 11 files with indirect coverage changes Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
5aac17b
to
6c3a5f2
Compare
services/filemanager/miniomanager.go
Outdated
@@ -36,8 +36,8 @@ func (manager *MinioManager) Upload(ctx context.Context, file *os.File, prefixes | |||
defer cancel() | |||
|
|||
if err = minioClient.MakeBucket(ctx, manager.Config.Bucket, minio.MakeBucketOptions{Region: "us-east-1"}); err != nil { | |||
exists, errBucketExists := minioClient.BucketExists(ctx, manager.Config.Bucket) | |||
if !(errBucketExists == nil && exists) { | |||
err = suppressMinorErrors(err) |
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.
[minor] not sure if wrapping error handling in a separate method is really necessary. The errors that we are ignoring here are specific to bucket creation, not sure if the function should be reused elsewhere
9402515
to
6534453
Compare
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.
Instead of directly trying to create a bucket and then handling the error, why don't we 1st check if the bucket exist or not. And only create if it doesn't exist?
We can do it by calling BucketExists()
func in minio and ContainerExists()
in azure.
Yeah, But it will still require 1 API call anyways. Why not just use the Create APi and suppress it in case of already exists? |
Well, I believe preventing error in first place is better then handling it. |
Make sense. |
What if we don't create a bucket at all? Ideally, it should be the customer's responsibility to create the bucket. |
Both approaches sound good to me, I personally prefer the ask for forgiveness than permission. Being optimistic that something would work, and handle the unexpected outcome. Having a single call is better safeguard against race conditions (trying to create the bucket at the same time). Checking if bucket exists from an implicit call makes our service more robust against error code changes. |
…/rudder-server into fix.minio-create-bucket-error
well, I am not sure if we have clearly mentioned it somewhere that they themself need to create a bucket. But, if that is the case then your point make sense. But, still I believe at the end of the it will escalate to some issue when upload would fail and then we will be notified and CS team will get in touch with them to create it. So, I personally think creating on our own if it doesn't exist would be best for us. 😄 |
I have reverted the Azure changes since it requires additional logic to check if the container exists or not using storage.GetContainerReferenceFromSASURI(sasUri).Exists() which requires a SASUri instead of an existing containerUri. |
5f71946
to
d65a1e5
Compare
Also, it was not in the scope of the PR. |
d65a1e5
to
f5f34c7
Compare
Description
minioClient.BucketExists
but this is returning apermission error
.Notion Ticket
https://www.notion.so/rudderstacks/Minio-data-retention-object-storage-validations-is-failing-b1c961c67337476a82566a43eaed243e?pvs=4
Security