-
Notifications
You must be signed in to change notification settings - Fork 978
feat(cli/ssh): simplify log file flags #7863
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
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
4b3b2bd
feat(cli/ssh): simplify log file flags
ammario 82ce7a2
Fix race
ammario ad2c946
Fix race the right way
ammario 1ca5930
Restore directory flag
ammario d7b26ad
Update tests
ammario 48cb9b2
make
ammario 3c43cfc
Merge remote-tracking branch 'origin/main' into log-race
ammario a1b68e5
mess around
ammario 23a6833
Fix another race
ammario f17e7ce
fixup! Fix another race
ammario 5a311b3
Update cli/ssh.go
ammario 65cdbcc
Move CloseStdin into clibase
ammario d1cb325
Merge remote-tracking branch 'origin/main' into log-race
ammario 8471555
Revert "Move CloseStdin into clibase"
ammario 6593dfe
Merge remote-tracking branch 'origin/main' into log-race
ammario c5a1968
Spike-ify
ammario File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix another race
- Loading branch information
commit 23a6833c775c5f5e57d45c071132fd30f9c6f4c4
There are no files selected for viewing
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This smells funny in that it shouldn't be the job of the cli command to close stdin.
Also, in the case where rawSSH goes down unexpectedly, but the workspace stays up, I think that we could still be blocked on reading from stdin, creating a deadlock with the waitgroup.
It should be the job of the clibase invoker to close stdin when the command is done -- but here that can create a deadlock with the waitgroup, since the main command won't return until the waitgroup is done.
Instead of considering the waitgroup to be all the command goroutines except the main one, why don't we make the waitgroup all the command goroutines including the main one? Then we can have a separate goroutine that just waits for the group, and closes the log file.
e.g.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree my solution is janky. The challenge with closing the logfile in a separate goroutine is it creates a leak — which was the main thing I was trying to fix when opening this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closing in a separate goroutine is not a leak (unless the waitgroup fails to complete). It just waits for the other things to finish, closes the file, then exits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And, it's not just a question of jankiness. As written, it's still bugged in the case where the
rawSSH
closes for some external reason not related to the workspace being stopped. The command will deadlock.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe leak isn't the best word. It can show up in our leak detector and cause test flakiness, even though in production there is no leak.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this. If
rawSSH
closes for some external reason, and io.Copy is blocked on write, the write call would immediately fail?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm worried about
io.Copy
blocking onRead()
- the same thing you're trying to prevent here, but with rawSSH just closing for a different reason.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you tried it and seen
goleak
firing? If there are goroutines still running,goleak
will sleep and retry up to some maximum timeout, exactly so that things like what I'm proposing have time to resolve themselves beforegoleak
complains about them.I can't imagine this would be the case for waiting for a waitgroup and closing a file, but if for some reason the goroutine takes longer to resolve than
goleak
's default timeout, we can adjust the timeout.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't know about the retry. I'll implement your proposal.