Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Wait for copy to complete before propagating exit-status. #1647

Merged
merged 1 commit into from
Jan 31, 2018

Conversation

russjones
Copy link
Contributor

Purpose

Occasionally Teleport session recordings don't contain the end of a session. This happens because of a race condition between when everything has been copied from the PTY and when exit-status has been received by the server. To fix this problem, the PTY is not closed until everything has been copied from the PTY.

Implementation

  • New sessions create two goroutines, one that performs a io.Copy from the PTY to the writer (which is the session recorder and a direct connection to the remote client) and another goroutine that waits until either exit-status has been received (for the forwarding node) or exec.Cmd is complete (regular Teleport).
  • Use a doneCh to notify the goroutine that is waiting for the execution of the shell to complete to also wait for the io.Copy to finish before broadcasting the exit-status to the client. This has to be done because broadcasting of the exit-status causes the PTY to be closed.
  • Timeout after 5 seconds if everything has not been copied and log an error that end of the session may be missing.

Related Issues

Fixes #1646

@klizhentas klizhentas merged commit cce1e08 into master Jan 31, 2018
@klizhentas klizhentas deleted the rjones/fix-exit branch January 31, 2018 20:20
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Teleport occasionally missing end of session recordings
2 participants