Repository navigation
Attach the terminal to its tmux session again when its exec ends - #114
Merged
Merged
Conversation
When the exec that carried the pty ended, the orchestrator closed the WebSocket, and the user had to press Reconnect. On a runtime where a long-lived stream can end at any time, for example through an idle timeout of the container runtime, this broke an open terminal without a reason that the user could see. The orchestrator now waits one second after the exec ended and opens a new exec that attaches to the same tmux client session by its name. The WebSocket stays open, and tmux keeps the screen. Text typed in the gap is kept and sent after the attach. A reattach never starts a stopped box: when the box has stopped, the socket closes with "box stopped". When tmux reports no such session, the user ended the shell, and the socket closes with "shell ended" as before. A reattach that fails for another reason is tried once more after five seconds, and then the socket closes with the error. Part of splitbrain#109
4 of 9 tasks
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Part of #109 (step 3).
Changes
new exec that attaches to the same tmux client session by its name (
openTerminalExecwith thereattachargument in
docker.ts). The WebSocket stays open, and tmux keeps the screen. Before, the socket closed with"shell ended" on every ended exec, and the user had to press Reconnect.
NO_TERMINAL_SESSION). The user endedthe shell, and the socket closes with "shell ended" as before. This now comes about one second later than before.
the error.
doc/terminal.mddescribes the reattach.Change in behavior: a tmux detach (prefix, then
d) now reattaches after one second. Before, it closed theterminal. The client session still exists after a detach, so the orchestrator cannot tell it from a cut stream.
Tests
tsc --noEmitis clean, 886 tests passed, 1 skipped (as before).terminal.test.tshas six newtests: reattach to the same session with text typed in the gap, "shell ended" on exit code 3, "box stopped"
without a box start, one failed try followed by one that works, two failed tries, and a browser that closes in
the gap. The test fake now opens a new pty for each exec and reports a container state.
connects to it, and a missing session gives exit code 3.
Not tested against a real Docker daemon.
Notes for the next steps
Runtimeinterface. The reattach is a secondspawnof the terminal with a different command,and a
containerStateread between them. Both go through the interface without a change. The namesREATTACH_DELAY_MSandREATTACH_RETRY_MSinterminal.tsare the one second and the five seconds of section12 of the concept.
by session name shows the same screen, and that the exit code of the attach is 3 when the session is gone.
this is the
stateof the box, where a pod inPendingcounts asrunning. In that case the attach fails,and the second try after five seconds applies.