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

Merge changes from gcsfuse-prelaunch #2906

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
47bb885
Merge changes from gcsfuse-prelaunch
gargnitingoogle Jan 17, 2025
7f9f9a4
intermediate
gargnitingoogle Jan 17, 2025
db1f3f9
intermediate
gargnitingoogle Jan 17, 2025
e23defb
address some self-review comments
gargnitingoogle Jan 17, 2025
4d7934b
address ashmeen review comment
gargnitingoogle Jan 17, 2025
096e7fe
restore files added in gcsfuse-prelaunch but not deleted in gcsfuse-m…
gargnitingoogle Jan 17, 2025
5764f08
removing unwanted file
gargnitingoogle Jan 17, 2025
a990e9d
switch back to the latest of indirect dependencies
gargnitingoogle Jan 17, 2025
2e675de
fixing bucket_handle.go and storage_handle.go
vadlakondaswetha Jan 17, 2025
83aa3ce
fixing compose
vadlakondaswetha Jan 17, 2025
6d007da
address a minor review comment
gargnitingoogle Jan 17, 2025
97c17f7
restore files added in gcsfuse-prelaunch but not deleted in gcsfuse-m…
gargnitingoogle Jan 17, 2025
c7be825
removing unwanted file
gargnitingoogle Jan 17, 2025
c441053
fix build errors
gargnitingoogle Jan 17, 2025
06f390c
fix build errors
gargnitingoogle Jan 17, 2025
2a85aa5
address a review comment
gargnitingoogle Jan 17, 2025
f0c05f4
remove old unused code
gargnitingoogle Jan 17, 2025
e7b9ca6
fix build of some UTs
gargnitingoogle Jan 17, 2025
08d736e
fix some linter errors
gargnitingoogle Jan 17, 2025
52168b3
remove commented code
gargnitingoogle Jan 17, 2025
6b73aa1
add/update file headers
gargnitingoogle Jan 17, 2025
17ed8fe
fix some UT build errors
gargnitingoogle Jan 17, 2025
6f46c3c
address more UT build errors
gargnitingoogle Jan 17, 2025
5515941
fix more lint/UT-build errors
gargnitingoogle Jan 17, 2025
22c7864
fix more lint/UT-build errors
gargnitingoogle Jan 17, 2025
a2ff724
fix more lint/UT-build errors
gargnitingoogle Jan 17, 2025
e4bd52d
fixing random_read_test.go
vadlakondaswetha Jan 17, 2025
4f3dea4
fixing random_reader_stretchr_test.go
vadlakondaswetha Jan 17, 2025
7f97e1e
fixing lint
vadlakondaswetha Jan 17, 2025
eb087fd
empty commit to force e2e test run
gargnitingoogle Jan 17, 2025
a5338b5
fixing uts
vadlakondaswetha Jan 17, 2025
f460c02
re-enabled an old commented test in prelanch-repo
gargnitingoogle Jan 17, 2025
b5345ea
remove unwanted comment
gargnitingoogle Jan 17, 2025
263674a
setting hierarchial=true
vadlakondaswetha Jan 17, 2025
7bfcb2a
fixing the test
vadlakondaswetha Jan 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
matrix:
go: [ 1.23.x ]
runs-on: ubuntu-latest
timeout-minutes: 15
timeout-minutes: 30
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 we need to increase the timeout?

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 kept it from what we had in prelaunch repo. if it passes under 15 minutes, I'll put it back to 15 min.


steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion go.mod
gargnitingoogle marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please attach a snapshot of perf comparison.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
cloud.google.com/go/compute/metadata v0.6.0
cloud.google.com/go/iam v1.3.1
cloud.google.com/go/secretmanager v1.14.3
cloud.google.com/go/storage v1.49.0
cloud.google.com/go/storage v1.50.0
contrib.go.opencensus.io/exporter/ocagent v0.7.0
contrib.go.opencensus.io/exporter/prometheus v0.4.2
contrib.go.opencensus.io/exporter/stackdriver v0.13.14
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0Zeo
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
cloud.google.com/go/storage v1.49.0 h1:zenOPBOWHCnojRd9aJZAyQXBYqkJkdQS42dxL55CIMw=
cloud.google.com/go/storage v1.49.0/go.mod h1:k1eHhhpLvrPjVGfo0mOUPEJ4Y2+a/Hv5PiwehZI9qGU=
cloud.google.com/go/storage v1.50.0 h1:3TbVkzTooBvnZsk7WaAQfOsNrdoM8QHusXA1cpk6QJs=
cloud.google.com/go/storage v1.50.0/go.mod h1:l7XeiD//vx5lfqE3RavfmU9yvk5Pp0Zhcv482poyafY=
cloud.google.com/go/trace v1.11.3 h1:c+I4YFjxRQjvAhRmSsmjpASUKq88chOX854ied0K/pE=
Expand Down Expand Up @@ -133,8 +131,6 @@ github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/
github.com/fsnotify/fsnotify v1.8.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
github.com/fsouza/fake-gcs-server v1.52.0 h1:ps23VAKR0pKu+QsdMUo25mtDXp6KpKxksIRkbHNBPug=
github.com/fsouza/fake-gcs-server v1.52.0/go.mod h1:tmfEOHhUOdkk243WkWUPC1MuHEaGdpJrslDijp5nZRs=
github.com/fsouza/fake-gcs-server v1.52.1 h1:Hx3G2ZpyBzHGmW7cHURWWoTm6jM3M5fcWMIAHBYlJyc=
github.com/fsouza/fake-gcs-server v1.52.1/go.mod h1:Paxf25VmSNMN52L+2/cVulF5fkLUA0YJIYjTGJiwf3c=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
Expand Down
11 changes: 9 additions & 2 deletions internal/cache/file/cache_handle_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"strings"
"testing"

"cloud.google.com/go/storage/control/apiv2/controlpb"
"github.com/googlecloudplatform/gcsfuse/v2/cfg"
"github.com/googlecloudplatform/gcsfuse/v2/common"
"github.com/googlecloudplatform/gcsfuse/v2/internal/cache/data"
Expand All @@ -40,6 +41,7 @@ import (
"github.com/googlecloudplatform/gcsfuse/v2/internal/storage/storageutil"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/operations"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/suite"
"golang.org/x/sync/semaphore"
)
Expand Down Expand Up @@ -110,9 +112,14 @@ func (cht *cacheHandleTest) SetupTest() {
ctx := context.Background()

// Create bucket in fake storage.
cht.fakeStorage = storage.NewFakeStorage()
var err error
mockClient := new(storage.MockStorageControlClient)
cht.fakeStorage = storage.NewFakeStorageWithMockClient(mockClient, cfg.HTTP2)
storageHandle := cht.fakeStorage.CreateStorageHandle()
cht.bucket = storageHandle.BucketHandle(ctx, storage.TestBucketName, "")
mockClient.On("GetStorageLayout", mock.Anything, mock.Anything, mock.Anything).
Return(&controlpb.StorageLayout{}, nil)
cht.bucket, err = storageHandle.BucketHandle(ctx, storage.TestBucketName, "")
assert.Nil(cht.T(), err)

// Create test object in the bucket.
testObjectContent := make([]byte, TestObjectSize)
Expand Down
12 changes: 9 additions & 3 deletions internal/cache/file/cache_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"testing"
"time"

"cloud.google.com/go/storage/control/apiv2/controlpb"
"github.com/googlecloudplatform/gcsfuse/v2/cfg"
"github.com/googlecloudplatform/gcsfuse/v2/common"
"github.com/googlecloudplatform/gcsfuse/v2/internal/cache/data"
Expand All @@ -36,6 +37,7 @@ import (
"github.com/googlecloudplatform/gcsfuse/v2/internal/storage/storageutil"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/operations"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
)

Expand All @@ -59,17 +61,21 @@ func initializeCacheHandlerTestArgs(t *testing.T, fileCacheConfig *cfg.FileCache
locker.EnableInvariantsCheck()

// Create bucket in fake storage.
fakeStorage := storage.NewFakeStorage()
mockClient := new(storage.MockStorageControlClient)
fakeStorage := storage.NewFakeStorageWithMockClient(mockClient, cfg.HTTP2)
t.Cleanup(func() {
fakeStorage.ShutDown()
})
storageHandle := fakeStorage.CreateStorageHandle()
mockClient.On("GetStorageLayout", mock.Anything, mock.Anything, mock.Anything).
Return(&controlpb.StorageLayout{}, nil)
ctx := context.Background()
bucket := storageHandle.BucketHandle(ctx, storage.TestBucketName, "")
bucket, err := storageHandle.BucketHandle(ctx, storage.TestBucketName, "")
require.NoError(t, err)

// Create test object in the bucket.
testObjectContent := make([]byte, TestObjectSize)
_, err := rand.Read(testObjectContent)
_, err = rand.Read(testObjectContent)
require.NoError(t, err)
object := createObject(t, bucket, TestObjectName, testObjectContent)

Expand Down
11 changes: 9 additions & 2 deletions internal/cache/file/downloader/downloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"testing"
"time"

"cloud.google.com/go/storage/control/apiv2/controlpb"
"github.com/googlecloudplatform/gcsfuse/v2/cfg"
"github.com/googlecloudplatform/gcsfuse/v2/common"
"github.com/googlecloudplatform/gcsfuse/v2/internal/cache/data"
Expand All @@ -33,6 +34,7 @@ import (
testutil "github.com/googlecloudplatform/gcsfuse/v2/internal/util"
"github.com/googlecloudplatform/gcsfuse/v2/tools/integration_tests/util/operations"
. "github.com/jacobsa/ogletest"
"github.com/stretchr/testify/mock"
)

var cacheDir = path.Join(os.Getenv("HOME"), "cache/dir")
Expand All @@ -57,10 +59,15 @@ func (dt *downloaderTest) setupHelper() {
operations.RemoveDir(cacheDir)

// Create bucket in fake storage.
dt.fakeStorage = storage.NewFakeStorage()
var err error
mockClient := new(storage.MockStorageControlClient)
dt.fakeStorage = storage.NewFakeStorageWithMockClient(mockClient, cfg.HTTP2)
storageHandle := dt.fakeStorage.CreateStorageHandle()
mockClient.On("GetStorageLayout", mock.Anything, mock.Anything, mock.Anything).
Return(&controlpb.StorageLayout{}, nil)
ctx := context.Background()
dt.bucket = storageHandle.BucketHandle(ctx, storage.TestBucketName, "")
dt.bucket, err = storageHandle.BucketHandle(ctx, storage.TestBucketName, "")
ExpectEq(nil, err)

dt.initJobTest(DefaultObjectName, []byte("taco"), DefaultSequentialReadSizeMb, CacheMaxSize, func() {})
dt.jm = NewJobManager(dt.cache, util.DefaultFilePerm, util.DefaultDirPerm, cacheDir, DefaultSequentialReadSizeMb, dt.defaultFileCacheConfig, common.NewNoopMetrics())
Expand Down
15 changes: 11 additions & 4 deletions internal/cache/file/downloader/jm_parallel_downloads_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"testing"
"time"

"cloud.google.com/go/storage/control/apiv2/controlpb"
"github.com/googlecloudplatform/gcsfuse/v2/cfg"
"github.com/googlecloudplatform/gcsfuse/v2/common"
"github.com/googlecloudplatform/gcsfuse/v2/internal/cache/data"
Expand All @@ -31,6 +32,7 @@ import (
"github.com/googlecloudplatform/gcsfuse/v2/internal/storage/gcs"
"github.com/googlecloudplatform/gcsfuse/v2/internal/storage/storageutil"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
)

Expand All @@ -50,8 +52,11 @@ func createObjectInBucket(t *testing.T, objPath string, objSize int64, bucket gc

func configureFakeStorage(t *testing.T) storage.StorageHandle {
t.Helper()
fakeStorage := storage.NewFakeStorage()
mockClient := new(storage.MockStorageControlClient)
fakeStorage := storage.NewFakeStorageWithMockClient(mockClient, cfg.HTTP2)
t.Cleanup(func() { fakeStorage.ShutDown() })
mockClient.On("GetStorageLayout", mock.Anything, mock.Anything, mock.Anything).
Return(&controlpb.StorageLayout{}, nil)
return fakeStorage.CreateStorageHandle()
}

Expand Down Expand Up @@ -140,7 +145,8 @@ func TestParallelDownloads(t *testing.T) {
cache, cacheDir := configureCache(t, 2*tc.objectSize)
storageHandle := configureFakeStorage(t)
ctx := context.Background()
bucket := storageHandle.BucketHandle(ctx, storage.TestBucketName, "")
bucket, err := storageHandle.BucketHandle(ctx, storage.TestBucketName, "")
assert.Nil(t, err)
minObj, content := createObjectInStoreAndInitCache(t, cache, bucket, "path/in/gcs/foo.txt", tc.objectSize)
fileCacheConfig := &cfg.FileCacheConfig{
EnableParallelDownloads: true,
Expand All @@ -154,7 +160,7 @@ func TestParallelDownloads(t *testing.T) {
job := jm.CreateJobIfNotExists(&minObj, bucket)
subscriberC := job.subscribe(tc.subscribedOffset)

_, err := job.Download(context.Background(), 10, false)
_, err = job.Download(context.Background(), 10, false)

timeout := time.After(1 * time.Second)
for {
Expand All @@ -181,7 +187,8 @@ func TestMultipleConcurrentDownloads(t *testing.T) {
storageHandle := configureFakeStorage(t)
cache, cacheDir := configureCache(t, 30*util.MiB)
ctx := context.Background()
bucket := storageHandle.BucketHandle(ctx, storage.TestBucketName, "")
bucket, err := storageHandle.BucketHandle(ctx, storage.TestBucketName, "")
assert.Nil(t, err)
minObj1, content1 := createObjectInStoreAndInitCache(t, cache, bucket, "path/in/gcs/foo.txt", 10*util.MiB)
minObj2, content2 := createObjectInStoreAndInitCache(t, cache, bucket, "path/in/gcs/bar.txt", 5*util.MiB)
fileCacheConfig := &cfg.FileCacheConfig{
Expand Down
10 changes: 8 additions & 2 deletions internal/cache/file/downloader/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ func (job *Job) updateStatusOffset(downloadedOffset int64) (err error) {
// file and updates the file info cache. It uses gcs.Bucket's NewReader method
// to download the object.
func (job *Job) downloadObjectToFile(cacheFile *os.File) (err error) {
var newReader io.ReadCloser
var newReader gcs.StorageReader
var readHandle []byte
var start, end, sequentialReadSize, newReaderLimit int64
end = int64(job.object.Size)
sequentialReadSize = int64(job.sequentialReadSizeMb) * cacheutil.MiB
Expand All @@ -308,7 +309,7 @@ func (job *Job) downloadObjectToFile(cacheFile *os.File) (err error) {
for start < end {
if newReader == nil {
newReaderLimit = min(start+sequentialReadSize, end)
newReader, err = job.bucket.NewReader(
newReader, err = job.bucket.NewReaderWithReadHandle(
job.cancelCtx,
&gcs.ReadObjectRequest{
Name: job.object.Name,
Expand All @@ -318,11 +319,16 @@ func (job *Job) downloadObjectToFile(cacheFile *os.File) (err error) {
Limit: uint64(newReaderLimit),
},
ReadCompressed: job.object.HasContentEncodingGzip(),
ReadHandle: readHandle,
})
if err != nil {
err = fmt.Errorf("downloadObjectToFile: error in creating NewReader with start %d and limit %d: %w", start, newReaderLimit, err)
return err
}
if newReader != nil {
// The following is a dead code which has no net output.
gargnitingoogle marked this conversation as resolved.
Show resolved Hide resolved
readHandle = newReader.ReadHandle()
}
common.CaptureGCSReadMetrics(job.cancelCtx, job.metricsHandle, util.Sequential, newReaderLimit-start)
}

Expand Down
37 changes: 20 additions & 17 deletions internal/cache/file/downloader/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ import (
"golang.org/x/sync/semaphore"
)

// NOTE: Please add new tests in job_testify_test.go file. This file
// is deprecated and these tests will be moved to the job_testify_test.go.

////////////////////////////////////////////////////////////////////////
// Boilerplate
////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -951,23 +954,23 @@ func (dt *downloaderTest) Test_validateCRC_ForTamperedFileWhenEnableCRCIsFalse()
}

func (dt *downloaderTest) Test_validateCRC_WheContextIsCancelled() {
objectName := "path/in/gcs/file2.txt"
objectSize := 10 * util.MiB
objectContent := testutil.GenerateRandomBytes(objectSize)
dt.initJobTest(objectName, objectContent, DefaultSequentialReadSizeMb, uint64(2*objectSize), func() {})
// Start download
offset := int64(10 * util.MiB)
_, err := dt.job.Download(context.Background(), offset, true)
AssertEq(nil, err)
AssertTrue((dt.job.status.Name == Downloading) || (dt.job.status.Name == Completed), fmt.Sprintf("got job status: %v", dt.job.status.Name))
AssertEq(nil, dt.job.status.Err)
AssertGe(dt.job.status.Offset, offset)

dt.job.cancelFunc()
dt.waitForCrcCheckToBeCompleted()

AssertEq(Invalid, dt.job.status.Name)
dt.verifyInvalidError(dt.job.status.Err)
// objectName := "path/in/gcs/file2.txt"
gargnitingoogle marked this conversation as resolved.
Show resolved Hide resolved
gargnitingoogle marked this conversation as resolved.
Show resolved Hide resolved
// objectSize := 10 * util.MiB
// objectContent := testutil.GenerateRandomBytes(objectSize)
// dt.initJobTest(objectName, objectContent, DefaultSequentialReadSizeMb, uint64(2*objectSize), func() {})
// // Start download
// offset := int64(10 * util.MiB)
// _, err := dt.job.Download(context.Background(), offset, true)
// AssertEq(nil, err)
// AssertTrue((dt.job.status.Name == Downloading) || (dt.job.status.Name == Completed), fmt.Sprintf("got job status: %v", dt.job.status.Name))
// AssertEq(nil, dt.job.status.Err)
// AssertGe(dt.job.status.Offset, offset)

// dt.job.cancelFunc()
// dt.waitForCrcCheckToBeCompleted()

// AssertEq(Invalid, dt.job.status.Name)
// dt.verifyInvalidError(dt.job.status.Err)
}

func (dt *downloaderTest) Test_handleError_SetStatusAsInvalidWhenContextIsCancelled() {
Expand Down
Loading
Loading