Skip to content
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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

ashmeenkaur
Copy link
Collaborator

@ashmeenkaur ashmeenkaur commented Oct 15, 2024

Description

This PR includes changes to bucket.go interface and all it's associated implementations to include the following methods:

Link to the issue in case of a bug fix.

NA

Testing details

  1. Manual - NA
  2. Unit tests - Added
  3. Integration tests - NA

@ashmeenkaur ashmeenkaur changed the title [Do not review yet] bucket interface changes to storage.Writer for resumable uploads [Do not review yet] bucket interface changes to create storage.Writer for resumable uploads Oct 15, 2024
Copy link

codecov bot commented Oct 18, 2024

Codecov Report

Attention: Patch coverage is 54.72973% with 67 lines in your changes missing coverage. Please review.

Project coverage is 78.28%. Comparing base (0dab668) to head (f111264).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
internal/ratelimit/throttled_bucket.go 0.00% 15 Missing ⚠️
internal/storage/debug_bucket.go 0.00% 12 Missing ⚠️
internal/monitor/bucket.go 0.00% 10 Missing ⚠️
internal/storage/testify_mock_bucket.go 0.00% 9 Missing ⚠️
internal/gcsx/prefix_bucket.go 0.00% 6 Missing ⚠️
internal/storage/fake/bucket.go 0.00% 6 Missing ⚠️
internal/storage/mock_bucket.go 90.47% 2 Missing and 2 partials ⚠️
internal/storage/storageutil/object_attrs.go 0.00% 2 Missing and 1 partial ⚠️
internal/storage/bucket_handle.go 92.59% 2 Missing ⚠️
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     
Flag Coverage Δ
unittests 78.28% <54.72%> (-0.21%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@ashmeenkaur ashmeenkaur marked this pull request as ready for review October 18, 2024 05:18
@ashmeenkaur ashmeenkaur requested a review from a team as a code owner October 18, 2024 05:18
@ashmeenkaur ashmeenkaur changed the title [Do not review yet] bucket interface changes to create storage.Writer for resumable uploads [Buffered Writes] bucket interface changes for buffered writes Oct 18, 2024
@kislaykishore kislaykishore requested a review from a team October 18, 2024 05:18
@ashmeenkaur ashmeenkaur requested review from vadlakondaswetha and removed request for a team October 18, 2024 05:18
@kislaykishore kislaykishore requested review from a team and removed request for vadlakondaswetha October 18, 2024 05:18
@ashmeenkaur ashmeenkaur requested review from vadlakondaswetha and removed request for a team October 18, 2024 05:20
@ashmeenkaur ashmeenkaur added the execute-integration-tests Run only integration tests label Oct 18, 2024
@kislaykishore kislaykishore requested a review from a team October 18, 2024 05:20
@ashmeenkaur ashmeenkaur added minimal-file-buffering and removed execute-integration-tests Run only integration tests labels Oct 18, 2024
@ashmeenkaur ashmeenkaur changed the title [Buffered Writes] bucket interface changes for buffered writes [Buffered Writes] bucket interface changes for buffered writes part 1 Oct 18, 2024

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)
Copy link
Collaborator

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?

Copy link
Collaborator Author

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 {
Copy link
Collaborator

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.

Copy link
Collaborator Author

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 {
Copy link
Collaborator

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

Copy link
Collaborator Author

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.

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{}
Copy link
Collaborator

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

Copy link
Collaborator Author

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.

internal/storage/bucket_handle_test.go Show resolved Hide resolved
}

func (testSuite *BucketHandleTest) createObject(objName string) {
testSuite.T().Helper()
Copy link
Collaborator

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?

Copy link
Collaborator Author

@ashmeenkaur ashmeenkaur Oct 22, 2024

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.

internal/storage/caching/fast_stat_bucket_test.go Outdated Show resolved Hide resolved

func init() { RegisterTestSuite(&CreateObjectChunkWriterTest{}) }

func (t *CreateObjectChunkWriterTest) CallsWrapped() {
Copy link
Collaborator

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

Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants