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

Size tracking component #423

Open
wants to merge 28 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a88d7c5
Initial commit for size tracking
jfantinhardesty Jan 17, 2025
748732c
Fix some unit tests
jfantinhardesty Jan 21, 2025
be6dd67
Merge remote-tracking branch 'origin/main' into size-tracking-component
jfantinhardesty Jan 21, 2025
080b9f9
Pass all unit tests
jfantinhardesty Jan 22, 2025
d180145
Cleanup
jfantinhardesty Jan 22, 2025
c590963
Finalize unit tests and fix issue with symlink
jfantinhardesty Jan 23, 2025
d6c332c
Fix spelling
jfantinhardesty Jan 23, 2025
98710e2
Fix size test to run only for S3, cleanup tests for Windows
jfantinhardesty Jan 23, 2025
f513d7f
Fix test failurs on Windows in loopback
jfantinhardesty Jan 23, 2025
2306396
Fix journaling on Windows
jfantinhardesty Jan 23, 2025
4f443b6
Fix linting and don't run size_tracker test on blob storage
jfantinhardesty Jan 23, 2025
fa4eba6
Fix code coverage tests for Linux, add them for Windows
jfantinhardesty Jan 23, 2025
3111f43
Merge remote-tracking branch 'origin/main' into size-tracking-component
jfantinhardesty Jan 23, 2025
c7fe19a
Debug failur
jfantinhardesty Jan 23, 2025
a63c8bc
Create default working directory if it does not exist when journaling
jfantinhardesty Jan 23, 2025
ce925ed
Fix code coverage tests
jfantinhardesty Jan 23, 2025
5d158c2
Fix windows code coverage error
jfantinhardesty Jan 23, 2025
0af0481
Fix issue with bash shell
jfantinhardesty Jan 24, 2025
2ef55a2
Fix dir tests for Windows
jfantinhardesty Jan 24, 2025
27beee1
Merge remote-tracking branch 'origin/main' into size-tracking-component
jfantinhardesty Jan 24, 2025
b28e7dd
Fix flaky tests on Windows
jfantinhardesty Jan 24, 2025
912a35b
Fix missing aws region
jfantinhardesty Jan 24, 2025
12e1ac4
Fix journaling issue on Windows
jfantinhardesty Jan 24, 2025
641b31e
Fix windows size tracker test errors
jfantinhardesty Jan 24, 2025
2359475
Update component/size_tracker/size_tracker.go
jfantinhardesty Jan 27, 2025
b137e2a
Merge branch 'main' into size-tracking-component
jfantinhardesty Jan 27, 2025
80dbc22
Avoid second GetAttr call in size tracker write file
jfantinhardesty Jan 27, 2025
038f79c
Merge branch 'size-tracking-component' of github.com:Seagate/cloudfus…
jfantinhardesty Jan 27, 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
73 changes: 73 additions & 0 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,37 @@ jobs:
sudo fusermount -u ${{ env.MOUNT_DIR }}
sleep 5

- name: Cleanup S3 Storage before size tracker test
run: go test -timeout 120m -v test/s3cleanup/s3cleanup_test.go
env:
AWS_ACCESS_KEY_ID: "${{ secrets.S3TEST_ACCESS_KEY }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets.S3TEST_SECRET_KEY }}"
AWS_REGION: "${{ secrets.S3TEST_REGION }}"
S3_BUCKET_NAME: "${{ secrets.S3TEST_BUCKET_NAME }}"
S3_ENDPOINT: "${{ secrets.S3TEST_ENDPOINT }}"

- name: Create Config File - S3 with Size Tracker
env:
S3_BUCKET_NAME: "${{ secrets.S3TEST_BUCKET_NAME }}"
S3_ENDPOINT: "${{ secrets.S3TEST_ENDPOINT }}"
S3_KEY_ID: "${{ secrets.S3TEST_ACCESS_KEY }}"
S3_REGION: "${{ secrets.S3TEST_REGION }}"
S3_SECRET_KEY: "${{ secrets.S3TEST_SECRET_KEY }}"
run: "./cloudfuse.test gen-test-config --config-file=s3_key_size_tracker.yaml --temp-path=${{ env.TEMP_DIR }} --output-file=${{ env.cloudfuse_CFG }}"

- name: S3 Coverage with Size Tracker
run: |-
rm -rf ${{ env.MOUNT_DIR }}/*
rm -rf ${{ env.TEMP_DIR }}/*
./cloudfuse.test -test.v -test.coverprofile=${{ env.WORK_DIR }}/cloudfuse_s3.cov mount ${{ env.MOUNT_DIR }} --config-file=${{ env.cloudfuse_CFG }} --foreground=true &
sleep 10
ps -aux | grep cloudfuse
cd test/e2e_tests
go test -v -timeout=7200s ./... -args -mnt-path=${{ env.MOUNT_DIR }} -tmp-path=${{ env.TEMP_DIR }} -size-tracker=true
cd -
sudo fusermount -u ${{ env.MOUNT_DIR }}
sleep 5

- name: Create Config File - Stream
env:
NIGHTLY_STO_ACC_NAME: "${{ secrets.NIGHTLY_STO_BLOB_ACC_NAME }}"
Expand Down Expand Up @@ -782,6 +813,39 @@ jobs:
kill $pid
sleep 5

- name: Cleanup S3 Storage before size tracker test
run: go test -timeout 120m -v test/s3cleanup/s3cleanup_test.go
env:
AWS_ACCESS_KEY_ID: "${{ secrets.S3TEST_ACCESS_KEY }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets.S3TEST_SECRET_KEY }}"
AWS_REGION: "${{ secrets.S3TEST_REGION }}"
S3_BUCKET_NAME: "${{ secrets.S3TEST_BUCKET_NAME }}"
S3_ENDPOINT: "${{ secrets.S3TEST_ENDPOINT }}"

- name: Create Config File - S3 with Size Tracker
shell: bash
env:
S3_BUCKET_NAME: "${{ secrets.S3TEST_BUCKET_NAME }}"
S3_ENDPOINT: "${{ secrets.S3TEST_ENDPOINT }}"
S3_KEY_ID: "${{ secrets.S3TEST_ACCESS_KEY }}"
S3_REGION: "${{ secrets.S3TEST_REGION }}"
S3_SECRET_KEY: "${{ secrets.S3TEST_SECRET_KEY }}"
run: "./cloudfuse.test gen-test-config --config-file=s3_key_size_tracker.yaml --temp-path=${{ env.TEMP_DIR }} --output-file=${{ env.cloudfuse_CFG }}"

- name: S3 Coverage with Size Tracker
shell: bash
run: |-
rm -rf ${{ env.MOUNT_DIR }}/*
rm -rf ${{ env.TEMP_DIR }}/*
./cloudfuse.test -test.v -test.coverprofile=${{ env.WORK_DIR }}/cloudfuse_s3.cov mount ${{ env.MOUNT_DIR }} --config-file=${{ env.cloudfuse_CFG }} --foreground=true &
sleep 10
pid=`ps -a | grep cloudfuse | tr -s ' ' | cut -d ' ' -f2`
cd test/e2e_tests
go test -v -timeout=7200s ./... -args -mnt-path=${{ env.MOUNT_DIR }} -tmp-path=${{ env.TEMP_DIR }} -quick-test=true -stream-direct-test=true -size-tracker=true
cd -
kill $pid
sleep 5

- name: Create Config File - Stream
shell: bash
env:
Expand Down Expand Up @@ -1050,3 +1114,12 @@ jobs:
env:
STORAGE_ACCOUNT_NAME: "${{ secrets.AZTEST_ADLS_ACC_NAME }}"
STORAGE_ACCOUNT_Key: "${{ secrets.AZTEST_ADLS_KEY }}"

- name: Cleanup S3 Storage
run: go test -timeout 120m -v test/s3cleanup/s3cleanup_test.go
env:
AWS_ACCESS_KEY_ID: "${{ secrets.S3TEST_ACCESS_KEY }}"
AWS_SECRET_ACCESS_KEY: "${{ secrets.S3TEST_SECRET_KEY }}"
AWS_REGION: "${{ secrets.S3TEST_REGION }}"
S3_BUCKET_NAME: "${{ secrets.S3TEST_BUCKET_NAME }}"
S3_ENDPOINT: "${{ secrets.S3TEST_ENDPOINT }}"
1 change: 1 addition & 0 deletions cmd/import_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@ import (
_ "github.com/Seagate/cloudfuse/component/libfuse"
_ "github.com/Seagate/cloudfuse/component/loopback"
_ "github.com/Seagate/cloudfuse/component/s3storage"
_ "github.com/Seagate/cloudfuse/component/size_tracker"
_ "github.com/Seagate/cloudfuse/component/stream"
)
1 change: 1 addition & 0 deletions cmd/imports_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,6 @@ import (
_ "github.com/Seagate/cloudfuse/component/libfuse"
_ "github.com/Seagate/cloudfuse/component/loopback"
_ "github.com/Seagate/cloudfuse/component/s3storage"
_ "github.com/Seagate/cloudfuse/component/size_tracker"
_ "github.com/Seagate/cloudfuse/component/stream"
)
13 changes: 3 additions & 10 deletions cmd/mount.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,16 +158,9 @@ func (opt *mountOptions) validate(skipNonEmptyMount bool) error {
common.DefaultLogFilePath = common.JoinUnixFilepath(common.DefaultWorkDir, "cloudfuse.log")
}

f, err := os.Stat(common.ExpandPath(common.DefaultWorkDir))
if err == nil && !f.IsDir() {
return fmt.Errorf("default work dir '%s' is not a directory", common.DefaultWorkDir)
}

if err != nil && os.IsNotExist(err) {
// create the default work dir
if err = os.MkdirAll(common.ExpandPath(common.DefaultWorkDir), 0755); err != nil {
return fmt.Errorf("failed to create default work dir [%s]", err.Error())
}
err := common.CreateDefaultDirectory()
if err != nil {
return fmt.Errorf("Failed to create default work dir [%s]", err.Error())
}

opt.Logging.LogFilePath = common.ExpandPath(opt.Logging.LogFilePath)
Expand Down
15 changes: 15 additions & 0 deletions common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -369,3 +369,18 @@ func IsDriveLetter(path string) bool {
match, _ := regexp.MatchString(pattern, path)
return match
}

func CreateDefaultDirectory() error {
dir, err := os.Stat(ExpandPath(DefaultWorkDir))
if err == nil && !dir.IsDir() {
return err
}

if err != nil && os.IsNotExist(err) {
// create the default work dir
if err = os.MkdirAll(ExpandPath(DefaultWorkDir), 0755); err != nil {
return err
}
}
return nil
}
17 changes: 12 additions & 5 deletions component/loopback/loopback_fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ func (lfs *LoopbackFS) CreateFile(options internal.CreateFileOptions) (*handlema
}
handle := handlemap.NewHandle(options.Name)
handle.SetFileObject(f)
handlemap.Add(handle)

return handle, nil
}
Expand Down Expand Up @@ -212,6 +213,7 @@ func (lfs *LoopbackFS) OpenFile(options internal.OpenFileOptions) (*handlemap.Ha
}
handle := handlemap.NewHandle(options.Name)
handle.SetFileObject(f)
handlemap.Add(handle)
return handle, nil
}

Expand All @@ -224,14 +226,23 @@ func (lfs *LoopbackFS) CloseFile(options internal.CloseFileOptions) error {
return syscall.EBADF
}

handlemap.Delete(options.Handle.ID)
return f.Close()
}

func (lfs *LoopbackFS) RenameFile(options internal.RenameFileOptions) error {
log.Trace("LoopbackFS::RenameFile : %s -> %s", options.Src, options.Dst)
oldPath := filepath.Join(lfs.path, options.Src)
newPath := filepath.Join(lfs.path, options.Dst)
return os.Rename(oldPath, newPath)
err := os.Rename(oldPath, newPath)
handlemap.GetHandles().Range(func(key, value any) bool {
handle := value.(*handlemap.Handle)
if handle.Path == options.Src {
handle.Path = options.Dst
}
return true
})
return err
}

func (lfs *LoopbackFS) ReadLink(options internal.ReadLinkOptions) (string, error) {
Expand Down Expand Up @@ -266,10 +277,6 @@ func (lfs *LoopbackFS) ReadInBuffer(options internal.ReadInBufferOptions) (int,
options.Handle.RLock()
defer options.Handle.RUnlock()

if f == nil {
log.Err("LoopbackFS::ReadInBuffer : error [invalid file object]")
return 0, os.ErrInvalid
}
return f.ReadAt(options.Data, options.Offset)
}

Expand Down
Loading
Loading