Open iholder101 opened 1 month ago
/label good-first-issue
The issue you're experiencing with long terminal commands not wrapping correctly when SSHing into a KubeVirtCI node could be related to terminal settings or configurations. Here are a few things you can check or try:
Terminal Settings: Ensure that your local terminal emulator settings are configured to handle line wrapping correctly. This can usually be found in the preferences or settings menu of your terminal application.
Terminal Type: Verify that the terminal type (TERM
environment variable) is set correctly. You can check this by running echo $TERM
in your SSH session. Common values are xterm
, xterm-256color
, etc. You can try setting it explicitly before running your commands:
export TERM=xterm-256color
SSH Configuration: The virtctl ssh
command and the underlying SSH configuration might influence terminal behavior. Ensure that the SSH session requests a pseudo-terminal (PTY) and handles window size changes correctly. The KubeVirt repository has code comments related to these configurations:
// requestPty requests a pseudo-terminal for the SSH session and sets up window size change handling.
func requestPty(session *ssh.Session) error {
w, h, err := term.GetSize(int(os.Stdin.Fd()))
if err != nil {
return err
}
if err := session.RequestPty(
os.Getenv("TERM"),
h, w,
ssh.TerminalModes{},
); err != nil {
return err
}
go resizeSessionOnWindowChange(session, os.Stdin.Fd())
return nil
}
This ensures that the terminal size is correctly set and adjusted during the SSH session [1].
Shell Configuration: Check if there are any custom shell configurations or profiles on the KubeVirtCI nodes that might affect terminal behavior. This includes .bashrc
, .bash_profile
, or other shell initialization files.
Known Issues: There have been previous discussions and fixes related to SSH session display problems in the KubeVirt repository. For example, PRs kubevirt/kubevirt#7421, kubevirt/kubevirt#6854, kubevirt/kubevirt#6891, and kubevirt/kubevirt#6902 address various SSH and terminal issues [2].
By checking these configurations and settings, you may be able to resolve the issue with command wrapping in your SSH sessions.
To continue talking to Dosu, mention @dosu.
Seems like a PTY issue along with SIGWINCH
not being handled properly.
Execing into the node's container and then running ssh.sh
seems to work fine.
Also verified this by doing the following:
$ podman exec -it <kubevirtci container> sh
$ trap 'echo test' WINCH
Resizing the terminal doesn't do anything.
TBH this may be a general RFE for virtctl console (virtctl ssh seems to be aware according to dosu)
Back to the subject, for the kubevirtci ssh script, I don't think we're aware of SIGWINCH or try to do any resizing at all.
As a quick W/A one could run stty size
on the host machine and apply the same values on the kvci node
@iholder101 - does this belong more to kubevirt/kubevirtci? I can transfer the issue if you want?
@iholder101 - does this belong more to kubevirt/kubevirtci? I can transfer the issue if you want?
Yes, feel free to do so if you think that's more appropriate! Thanks!
TBH this may be a general RFE for virtctl console (virtctl ssh seems to be aware according to dosu)
FYI @akalenyu (this interested me). The only feasible way I can think of achieving this in the current setup where the serial console is accessed through a virt-handler unix socket connection is to execute stty size
directly upon receiving a SIGWINCH
event. This is due to the connection being to a character device, which makes it impossible to perform more complex operations like sending an ioctl TIOCGWINSZ
to the tty. While the VNC protocol supports terminal resizing, serial consoles simply don't.
Another way (hypothetically speaking) is to change the way by which virt-handler communicates with the device, making it a device on its side instead of a unix socket and then sending ioctl to that device.
What happened: When SSHing into a KubevirtCI node, if the command is long enough, it is not warpped by instead being messy overriding the beginning of the command:
This is how it looks like:
What you expected to happen: The command to be wrapped into a new line in a human-readable way.
How to reproduce it (as minimally and precisely as possible): As explained above. 100% reproducible.
Environment:
virtctl version
): v1.3 (main)