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: exit when FUSE errors on accept #2257

Merged
merged 1 commit into from
Jul 9, 2024
Merged

fix: exit when FUSE errors on accept #2257

merged 1 commit into from
Jul 9, 2024

Conversation

hessjcg
Copy link
Collaborator

@hessjcg hessjcg commented Jun 26, 2024

This change makes FUSE-configured connections behave the same way as normal connections:
the proxy process should exit when there is an error accepting a connection while listening on
the local server socket.

Fixes #2256

@hessjcg hessjcg requested a review from a team as a code owner June 26, 2024 20:28
@hessjcg hessjcg marked this pull request as draft June 26, 2024 20:29
@hessjcg hessjcg force-pushed the gh-2256-fuse-exit branch 3 times, most recently from 73a065c to c44e59d Compare June 26, 2024 21:23
@hessjcg hessjcg requested a review from enocom June 26, 2024 21:25
@hessjcg hessjcg marked this pull request as ready for review June 26, 2024 21:25
@enocom enocom changed the title fix: Proxy process should exit when it gets an error accepting a connection fix: exit when FUSE errors on accept Jun 26, 2024
<-ctx.Done()
return ctx.Err()
select {
case cErr := <-c.fuseExitCh:
Copy link
Member

Choose a reason for hiding this comment

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

nit: since there are no other errors in scope here, err would be fine here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated to reuse err.

conn := tryDialUnix(t, socketPath)
defer conn.Close()

var got []string
Copy link
Member

Choose a reason for hiding this comment

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

Is this block of assertions necessary? tryDialUnix should wait until a connection has been established and we have tests elsewhere that ensure the wiring is correct (see above for example).

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 removed the d.dialedInstances() assertion.

servErrCh := make(chan error)
go func() {
servErr := c.Serve(context.Background(), func() { close(ready) })
servErrCh <- servErr
Copy link
Member

Choose a reason for hiding this comment

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

This will leak goroutines if servErrCh is full.

How about:

select {
  case servErrCh <- servErr:
  default:
    // exit background thread
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

internal/proxy/fuse_test.go Show resolved Hide resolved
@hessjcg hessjcg force-pushed the gh-2256-fuse-exit branch 2 times, most recently from 5ef7f29 to a46c983 Compare July 8, 2024 18:12
go c.Serve(context.Background(), func() { close(ready) })
servErrCh := make(chan error)
go func() {
servErr := c.Serve(context.Background(), func() { close(ready) })
Copy link
Member

Choose a reason for hiding this comment

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

My suggestion seems to have broken your test. Maybe it's better to block on the error channel or a context that you can cancel at the end of the test run.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There must be some subtle timing difference in the ubuntu implementation of channels. I put the test back to how it was and now it passes. I think its OK for this goroutine to block until servErrCh can accept an error.

Copy link
Member

@enocom enocom Jul 8, 2024

Choose a reason for hiding this comment

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

ctx, cancel := context.WithCancel(context.Background())
defer cancel()

go func() {
  servErr := c.Server(ctx, func() { close(ready) })
  select {
    case servErrCh <- serrErr:
    case <-ctx.Done():
  }
}()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed.

@hessjcg hessjcg requested review from enocom July 8, 2024 18:29
@hessjcg hessjcg force-pushed the gh-2256-fuse-exit branch 8 times, most recently from 3b2b3b5 to 1584076 Compare July 9, 2024 16:29

ctx, cancel := context.WithCancel(context.Background())
go func() {

Copy link
Member

Choose a reason for hiding this comment

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

nit: whitespace

@hessjcg hessjcg merged commit bb2a0ae into main Jul 9, 2024
12 checks passed
@hessjcg hessjcg deleted the gh-2256-fuse-exit branch July 9, 2024 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proxy process should exit when a FUSE instance gets an error when accepting a connection
3 participants