Notifications for interactive web terminal session
Problem to solve
In gitlab-ce#25990 we need to show a banner with information about the terminal session.
-
If the terminal session times out, or is otherwise disconnected, this will be displayed to the user clearly on the page.
-
If there are to many tty's the following error is shown:
-
Terminal window countdown progress is shown at top of page:
-
It should be possible for the backend to send messages/events to be displayed by the frontend through the WebSocket connection. This will be used to indicate on the web terminal page when the automated tasks in the job are complete.
Further details
gitlab-ce#25990
Proposal
If the terminal session times out, or is otherwise disconnected, this will be displayed to the user clearly on the page. The
onclose
method from the websocket method can be used.
Use the same WebSocket connection for the terminal and the notification channel. To do so we have to create a new sub-protocol that extends terminal.gitlab.com
. The name of the protocol is yet to be decided but can be for example v2.terminal.gitlab.com
.
Sub protocol specification
- The data will be all binary
- Works the same as
terminal.gitlab.com
- A new prefix (FD) will be added with the value
255
which will be a JSON string used for the notifications.- If there are to many tty's the following error is show
{ "type": "error", "code": "max_connections", "max_connections": 5, "timeout": 1800 }
- Job status update
-
{ "type": "info", "code": "job_running", "max_connections": 5, "timeout": 1800 }
<- Used to display to the user the job is still running banner -
{ "type": "info", "code": "job_finished", "max_connections": 5, "timeout": 1800 }
<- Used to display browser notification and start countdown
-
- If there are to many tty's the following error is show
Getting to the new protocol
Below is a list of things that need to do for the new protocol to work:
- Migrate workhorse to use https://gitlab.com/gitlab-org/gitlab-terminal which there is already some work done in gitlab-workhorse!243 (closed)
- Add new protocol support in https://gitlab.com/gitlab-org/gitlab-terminal/blob/master/terminal.go#L16
- Add support in https://gitlab.com/gitlab-org/gitlab-terminal to so we can send notifications to the websocket from the runner.
- Frontend starts using the new protocol
What does success look like, and how can we measure that?
gitlab-ce#25990