Skip to content

Commit e2f948e

Browse files
authored
Ensure to close FUSE file descriptor after Mountpoint is terminated (awslabs#484)
This should fix the flaky unit test https://github.com/awslabs/mountpoint-s3-csi-driver/actions/runs/15275854246/job/42961924795?pr=483#step:8:122. Verified by running `go test ./cmd/aws-s3-csi-mounter/... -count 10000`. Previously, it was failing multiple times even with 1000 runs. --- By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. Signed-off-by: Burak Varlı <burakvar@amazon.co.uk>
1 parent e8f1e0f commit e2f948e

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

cmd/aws-s3-csi-mounter/csimounter/csimounter_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,12 @@ func TestRunningMountpoint(t *testing.T) {
118118
})
119119

120120
t.Run("Fails if file descriptor is invalid", func(t *testing.T) {
121+
basepath := t.TempDir()
122+
mountErrPath := filepath.Join(basepath, "mount.err")
123+
121124
_, err := csimounter.Run(csimounter.Options{
122125
MountpointPath: mountpointPath,
126+
MountErrPath: mountErrPath,
123127
MountOptions: mountoptions.Options{
124128
Fd: -1,
125129
BucketName: "test-bucket",

pkg/mountpoint/runner/foreground.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ func RunInForeground(opts ForegroundOptions) (ExitCode, []byte, error) {
5252
if fuseDev == nil {
5353
return 0, nil, fmt.Errorf("runner: passed file descriptor %d is not a valid FUSE file descriptor", opts.Fd)
5454
}
55+
defer fuseDev.Close()
5556

5657
mountpointArgs := opts.Args
5758

0 commit comments

Comments
 (0)