-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v16] Improve handling of various lifecycle erorrs in VNet (#42220)
* Split vnet.Run into vnet.Setup and vnet.Run lib/teleterm cannot reuse this function due to different semantics of contexts within an RPC vs a CLI command. It needs one function that has request-response semantics and another that blocks that can be run from a separate goroutine. * tsh vnet: Select on ctx.Done too when awaiting TUN device Without this extra select on ctx.Done, interrupting tsh vnet at that moment would return an error about using a closed socket. That's because when the context gets canceled, another goroutine closes the socket. Instead, we should wait for either the cancelation of the context or socket.AcceptUnix returning a value. To test this, run `tsh vnet`. When the osascript prompt is shown, go back to the terminal and Ctrl+C the command. The previous version would show an error about using closed connection whereas this exits cleanly. * Do not show context canceled errors to user The previous version would show "context canceled" after sending SIGINT to tsh vnet after the user entered the password in the prompt and the TUN device was set up. * Fix handling of admin subcommand exiting prematurely with no err If the socket file was removed, the admin subcommand stops. The previous version of VNet would continue running. This version correctly propagates the fact that the admin subcommand has quit prematurely with no error and shuts down vnet.Manager as well. * Correctly report admin subcommand quitting prematurely Because of the changes from a couple of commits ago related to ignoring context.Canceled errors, if the admin subcommand was killed or has crashed, VNet would stop with no error message. This commit fixes that and propagates the error from osascript. * Avoid race condition when ctx gets canceled on awaiting TUN device * Refactor detecting premature exit with no error * Simplify shared VNet setup code Squashed from #41653 (only lib/vnet and tool/tsh). * Rename taskErr to expectedErr * Remove special treatment of context.Canceled in tsh vnet * Turn socket closer into critical task
- Loading branch information
Showing
8 changed files
with
350 additions
and
221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.