kubectl icon indicating copy to clipboard operation
kubectl copied to clipboard

interrupting kubectl watch with Ctrl-C breaks readline

Open freedge opened this issue 1 year ago • 5 comments

What happened: running kubectl get pod -w, then interrupting with Ctrl-C, will leave "^C" written on the terminal without a new line after. The terminal prompt is drawn right after the ^C

Here is why it's an issue: this causes weird issues with the terminal, if you for example, try to reexecute the previous statement with pressing the up arrow then go to the beg of the line with Ctrl-A, and travel through the line with Alt-F and edit that statement, you realize that readline does not really know where the line starts, and you're going to mess up the terminal input.

Practically, this means the user has to run "Ctrl-C" a second time to end up on a new line:

$ oc get pod -w
^C$ ^C
$

compare to :

$ sleep 10
^C
$

What you expected to happen: The ^C should be followed by a new line.

How to reproduce it (as minimally and precisely as possible): kubectl get pod -w then type Ctrl-C to interrupt it.

Anything else we need to know?: for the readline behavior https://askubuntu.com/a/861621

Environment:

  • Kubernetes client and server versions (use kubectl version): v1.29.0
  • Cloud provider or hardware configuration: any
  • OS (e.g: cat /etc/os-release): centos stream9/ubuntu

bash 5.1-6ubuntu1 / bash-5.1.8-6.el9.x86_64

freedge avatar Jan 12 '24 10:01 freedge

/assign @ardaguclu

mpuckett159 avatar Jan 31 '24 17:01 mpuckett159

/triage accepted

mpuckett159 avatar Jan 31 '24 18:01 mpuckett159

Hello @mpuckett159, @ardaguclu I have investigate on this issue and there is common issue between multiple resources not just get, currently i've tested debug. But events, rollout_status, run should have the same issue.

I have fixed this issue on my local, can i assign myself? or should i provide @ardaguclu with my findings?

ah8ad3 avatar Feb 03 '24 06:02 ah8ad3

@ah8ad3 thanks for diving into it. Feel free to open a PR (and assign this issue to yourself) and we can continue discussions on it.

ardaguclu avatar Feb 03 '24 07:02 ardaguclu

/assign

ah8ad3 avatar Feb 03 '24 07:02 ah8ad3