Skip to content
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

feat: first attempt of terminal #285

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

feat: first attempt of terminal #285

wants to merge 1 commit into from

Conversation

janlauber
Copy link
Owner

@janlauber janlauber added the feature New feature or request label Jun 22, 2024
@janlauber janlauber self-assigned this Jun 22, 2024
@janlauber janlauber linked an issue Jun 22, 2024 that may be closed by this pull request
@janlauber
Copy link
Owner Author

@okaufmann

Current problem:

Issue Description

We are encountering a problem with our WebSocket-based CLI shell streaming from the backend to a Kubernetes pod. The current implementation requires sending the same command multiple times before receiving the output. This issue significantly impacts the real-time interactivity expected from a remote shell session. Also the frontend implementation is not done yet (doesn't work).

Observations

  1. Multiple Attempts Required: Commands such as ls and pwd need to be sent several times before the output is received.
  2. Buffered Output: The output from the commands is delayed, indicating possible issues with how data is being read and flushed between the WebSocket and the Kubernetes exec command.

Logs and Analysis

Here are the relevant logs illustrating the problem:

  1. WebSocket connection is established and receives initial messages.
  2. Commands (ls, pwd, etc.) are sent multiple times before receiving the expected output.

Backend Logs:

2024/06/22 13:44:47 Server started at http://0.0.0.0:8090
2024/06/22 13:44:56 Received initial message: {"projectId": "mkid5cu6294qv64","podName": "igncvwo3lt1zici-6f849f6454-9gq9h"}
2024/06/22 13:44:56 Parsed request: projectId=mkid5cu6294qv64, podName=igncvwo3lt1zici-6f849f6454-9gq9h
2024/06/22 13:44:56 WatchK8sTerminalAndSendUpdates called with projectId=mkid5cu6294qv64, podName=igncvwo3lt1zici-6f849f6454-9gq9h
2024/06/22 13:44:57 Sent output: # 
2024/06/22 13:44:59 WebSocket received message: ls
2024/06/22 13:45:01 WebSocket received message: ls
2024/06/22 13:45:03 Read 3 bytes from WebSocket: ls
2024/06/22 13:45:03 Sent output: ls
2024/06/22 13:45:03 Sent output: bin docker-entrypoint.d home media proc sbin tmp
boot docker-entrypoint.sh lib mnt root srv usr
dev etc lib64 opt run sys var
2024/06/22 13:45:03 Sent output: #
2024/06/22 13:45:08 WebSocket received message: pwd
2024/06/22 13:45:10 Read 4 bytes from WebSocket: pwd
2024/06/22 13:45:10 Sent output: pwd
2024/06/22 13:45:10 Sent output: /
#

Proposed Solution

To address this issue, the following steps are proposed:

  1. Custom LogStreamer: Implement a LogStreamer that captures stdout and streams it back in real-time.
  2. Immediate Flushing: Ensure commands are immediately flushed and processed.
  3. Use os.Stdin: Utilize os.Stdin for stdin in the StreamOptions to maintain real-time command input.

Signed-off-by: Jan Lauber <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request size/XL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shell Support
1 participant