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

fix: ignore go-fuse ctx in Lookup #2268

Merged
merged 2 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions internal/proxy/fuse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,27 @@ func TestFUSEReadDir(t *testing.T) {
}
}

func TestLookupIgnoresContext(t *testing.T) {
if testing.Short() {
t.Skip("skipping fuse tests in short mode.")
}
// create context and cancel it immediately
ctx, cancel := context.WithCancel(context.Background())
cancel()
d := &fakeDialer{}
c, _, _ := newTestClient(t, d, randTmpDir(t), randTmpDir(t))

// invoke Lookup with cancelled context, should ignore context and succeed
_, err := c.Lookup(ctx, "proj:reg:mysql", nil)
if err != fs.OK {
t.Fatalf("proxy.Client.Lookup(): %v", err)
}
// Close the client to close all open sockets.
if err := c.Close(); err != nil {
t.Fatalf("c.Close(): %v", err)
}
}

func TestFUSEErrors(t *testing.T) {
if testing.Short() {
t.Skip("skipping fuse tests in short mode.")
Expand Down
3 changes: 2 additions & 1 deletion internal/proxy/proxy_other.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ func (c *Client) Readdir(_ context.Context) (fs.DirStream, syscall.Errno) {
// socket is connected to the requested Cloud SQL instance. Lookup returns a
// symlink (instead of the socket itself) so that multiple callers all use the
// same Unix socket.
func (c *Client) Lookup(ctx context.Context, instance string, _ *fuse.EntryOut) (*fs.Inode, syscall.Errno) {
func (c *Client) Lookup(_ context.Context, instance string, _ *fuse.EntryOut) (*fs.Inode, syscall.Errno) {
ctx := context.Background()
if instance == "README" {
return c.NewInode(ctx, &readme{}, fs.StableAttr{}), fs.OK
}
Expand Down
Loading