-
Notifications
You must be signed in to change notification settings - Fork 426
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
[Buffered Writes] bucket interface changes for buffered writes part 1 #2597
base: master
Are you sure you want to change the base?
Conversation
ebaa65a
to
22aebfd
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2597 +/- ##
==========================================
- Coverage 78.48% 78.28% -0.21%
==========================================
Files 108 109 +1
Lines 15905 16056 +151
==========================================
+ Hits 12483 12569 +86
- Misses 2914 2976 +62
- Partials 508 511 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
38812e9
to
fd305af
Compare
fd305af
to
82acee7
Compare
|
||
func (b *throttledBucket) FinalizeUpload(ctx context.Context, w gcs.Writer) (*gcs.Object, error) { | ||
// Wait for permission to call through. | ||
err := b.opThrottle.Wait(ctx, 1) |
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.
I think we shouldn't throttle this operation given that this fails, entire upload fails. Thoughts?
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.
Yes, I think it is okay to just throttle for create writer operation as they will anyway share the context. We are in a way double counting here too. Thanks for catching this!
@@ -43,6 +44,12 @@ const ( | |||
ReqIdField string = "GcsReqId" | |||
) | |||
|
|||
type Writer interface { |
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.
Can you add a comment here why is this interface required and why can't use storage.writer directly. Atleast i didnt understand the usecase.
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.
We need different implementations of writer for testing - particularly for fake bucket that we use for composite tests. That is why I added this interface. Fake bucket writer implementation is in the subsequent PR.
@@ -62,6 +62,9 @@ func convertACLRuleToObjectAccessControl(element storage.ACLRule) *storagev1.Obj | |||
} | |||
|
|||
func ObjectAttrsToBucketObject(attrs *storage.ObjectAttrs) *gcs.Object { | |||
if attrs == nil { |
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.
Did it happen in any scenario without receiving an error from GCS. Just curious
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.
No not a real scenario, this is added just to make unit tests simpler.
internal/storage/bucket_handle.go
Outdated
func (bh *bucketHandle) CreateObjectChunkWriter(ctx context.Context, req *gcs.CreateObjectRequest, chunkSize int, callBack func(bytesUploadedSoFar int64)) (gcs.Writer, error) { | ||
// For phase 1 of buffered writes, we are doing chunk uploads only for new | ||
// file uploads. | ||
preconditions := storage.Conditions{} |
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.
why do you want to restrict for not exist scenario. why can't we just use the generation from the request
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.
I was restricting to phase 1 of the project but makes sense to do this in one go as well. I'll update this.
} | ||
|
||
func (testSuite *BucketHandleTest) createObject(objName string) { | ||
testSuite.T().Helper() |
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.
I see this as definition for helper:
Helper marks the calling function as a test helper function.
// When printing file and line information, that function will be skipped.
// Helper may be called simultaneously from multiple goroutines.
Don't we want to print file and line info when something goes wrong?
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.
This will still print the error but not with the file name and line number of test helper but with the file and line number of calling Test function so it is easier to debug from where the error is coming from.
Eg: With Test Helper:
=== RUN TestBucketHandleTestSuite/TestFinalizeUploadWithGenerationAsZeroWhenObjectAlreadyExists
bucket_handle_test.go:554:
Error Trace: /usr/local/google/home/ashmeen/gcsfuse/internal/storage/bucket_handle_test.go:543
/usr/local/google/home/ashmeen/gcsfuse/internal/storage/bucket_handle_test.go:554
Error: An error is expected but got nil.
Test: TestBucketHandleTestSuite/TestFinalizeUploadWithGenerationAsZeroWhenObjectAlreadyExists
bucket_handle_test.go:554:
is the line number of test function where helper is called
Without test helper:
=== RUN TestBucketHandleTestSuite/TestFinalizeUploadWithGenerationAsZeroWhenObjectAlreadyExists
bucket_handle_test.go:543:
Error Trace: /usr/local/google/home/ashmeen/gcsfuse/internal/storage/bucket_handle_test.go:543
/usr/local/google/home/ashmeen/gcsfuse/internal/storage/bucket_handle_test.go:554
Error: An error is expected but got nil.
Test: TestBucketHandleTestSuite/TestFinalizeUploadWithGenerationAsZeroWhenObjectAlreadyExists
--- FAIL: TestBucketHandleTestSuite (0.01s)
bucket_handle_test.go:543:
is the line number of helper function where test is called.
|
||
func init() { RegisterTestSuite(&CreateObjectChunkWriterTest{}) } | ||
|
||
func (t *CreateObjectChunkWriterTest) CallsWrapped() { |
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.
are you verifying the request parameters here. can you name the method accordingly
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.
This test is validating that the wrapped bucket is called with the expected parameters. Let me know if you still think we should rename the test.
Description
This PR includes changes to bucket.go interface and all it's associated implementations to include the following methods:
fake bucket, prefix bucket and and content type bucket implementations are added in a subsequent PR [Buffered Writes] bucket interface changes for buffered writes part 2 #2606
Link to the issue in case of a bug fix.
NA
Testing details