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

Terminal size calculation is wrong when upgrade http to spdy stream protocol #68648

Open
wjiangjay opened this Issue Sep 14, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@wjiangjay
Contributor

wjiangjay commented Sep 14, 2018

/kind bug

What happened:
When invoke pod/exec api with stdin=true&stdout=true&tty=true, the terminal resize will run to handle the terminal resize event, but according to the output log with loglevel=8, terminal size calculation is wrong(at least width).

I0913 22:18:39.213492    2664 round_trippers.go:383] POST https://apiserver/api/v1/namespaces/default/pods/docker-registry-3-bcxbs/exec?command=%2Fbin%2Fsh&container=registry&container=registry&stdin=true&stdout=true&tty=true
                                       I0913 22:18:39.213544    2664 round_trippers.go:390] Request Headers:
                                                                                                            I0913 22:18:39.213554    2664 round_trippers.go:393]     X-Stream-Protocol-Version: v4.channel.k8s.io
                                                                                                                                                                                                                 I0913 22:18:39.213562    2664 round_trippers.go:393]     X-Stream-Protocol-Version: v3.channel.k8s.io
                                                                                                   I0913 22:18:39.213568    2664 round_trippers.go:393]     X-Stream-Protocol-Version: v2.channel.k8s.io
                                                                                                                                                                                                        I0913 22:18:39.213580    2664 round_trippers.go:393]     X-Stream-Protocol-Version: channel.k8s.io
                                                                                       I0913 22:18:39.213587    2664 round_trippers.go:393]     User-Agent: kubectl/v1.11.0+d4cacc0 (linux/amd64) kubernetes/d4cacc0
 I0913 22:18:39.265686    2664 round_trippers.go:408] Response Status: 101 Switching Protocols in 52 milliseconds
                                                                                                                 I0913 22:18:39.265732    2664 round_trippers.go:411] Response Headers:
                                                                                                                                                                                       I0913 22:18:39.265741    2664 round_trippers.go:414]     Connection: Upgrade
                                                I0913 22:18:39.265748    2664 round_trippers.go:414]     Upgrade: SPDY/3.1
                                                                                                                          I0913 22:18:39.265754    2664 round_trippers.go:414]     X-Stream-Protocol-Version: v4.channel.k8s.io
            I0913 22:18:39.265761    2664 round_trippers.go:414]     Date: Fri, 14 Sep 2018 02:18:40 GMT
                                                                                                        sh-4.2$

What you expected to happen:
terminal size should be correct

I0913 22:18:39.213492    2664 round_trippers.go:383] POST https://apiserver/api/v1/namespaces/default/pods/docker-registry-3-bcxbs/exec?command=%2Fbin%2Fsh&container=registry&container=registry&stdin=true&stdout=true&tty=true
I0913 22:18:39.213544    2664 round_trippers.go:390] Request Headers:
I0913 22:18:39.213554    2664 round_trippers.go:393]     X-Stream-Protocol-Version: v4.channel.k8s.io
I0913 22:18:39.213562    2664 round_trippers.go:393]     X-Stream-Protocol-Version: v3.channel.k8s.io
I0913 22:18:39.213568    2664 round_trippers.go:393]     X-Stream-Protocol-Version: v2.channel.k8s.io
I0913 22:18:39.213580    2664 round_trippers.go:393]     X-Stream-Protocol-Version: channel.k8s.io
I0913 22:18:39.213587    2664 round_trippers.go:393]     User-Agent: kubectl/v1.11.0+d4cacc0 (linux/amd64) kubernetes/d4cacc0
I0913 22:18:39.265686    2664 round_trippers.go:408] Response Status: 101 Switching Protocols in 52 milliseconds
I0913 22:18:39.265732    2664 round_trippers.go:411] Response Headers:
I0913 22:18:39.265741    2664 round_trippers.go:414]     Connection: Upgrade
I0913 22:18:39.265748    2664 round_trippers.go:414]     Upgrade: SPDY/3.1
I0913 22:18:39.265754    2664 round_trippers.go:414]     X-Stream-Protocol-Version: v4.channel.k8s.io
I0913 22:18:39.265761    2664 round_trippers.go:414]     Date: Fri, 14 Sep 2018 02:18:40 GMT
sh-4.2$

How to reproduce it (as minimally and precisely as possible):
kubectl exec -it --loglevel=8 podname /bin/sh

Anything else we need to know?:

Environment:

  • Kubernetes version (use kubectl version):
    Client Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.0+d4cacc0", GitCommit:"d4cacc0", GitTreeState:"clean", BuildDate:"2018-09-07T12:30:06Z", GoVersion:"go1.10.2", Compiler:"gc", Platform:"linux/amd64"}
    Server Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.0+d4cacc0", GitCommit:"d4cacc0", GitTreeState:"clean", BuildDate:"2018-09-07T12:30:06Z", GoVersion:"go1.10.2", Compiler:"gc", Platform:"linux/amd64"}
  • Cloud provider or hardware configuration:
  • OS (e.g. from /etc/os-release): kubectl os: fedora 28, gnome-terminal 3.28.2
  • Kernel (e.g. uname -a):
  • Install tools:
  • Others:
@wjiangjay

This comment has been minimized.

Show comment
Hide comment
@wjiangjay

wjiangjay Sep 14, 2018

Contributor

/sig cli

Contributor

wjiangjay commented Sep 14, 2018

/sig cli

@k8s-ci-robot k8s-ci-robot added sig/cli and removed needs-sig labels Sep 14, 2018

@yue9944882

This comment has been minimized.

Show comment
Hide comment
@yue9944882

yue9944882 Sep 14, 2018

Contributor

/cc @adohe

Contributor

yue9944882 commented Sep 14, 2018

/cc @adohe

@wjiangjay

This comment has been minimized.

Show comment
Hide comment
@wjiangjay

wjiangjay Sep 18, 2018

Contributor

After deep dig and might be terminal raw mode got something wrong with this scenario.
Still digging and trying to make a patch for this

Contributor

wjiangjay commented Sep 18, 2018

After deep dig and might be terminal raw mode got something wrong with this scenario.
Still digging and trying to make a patch for this

@wjiangjay

This comment has been minimized.

Show comment
Hide comment
@wjiangjay

wjiangjay Sep 25, 2018

Contributor

After dig, and found the root reason,
we switch the terminal mode for exec, from cooked -> raw -> cooked,
but switch back to cooked from raw will got this issue.

Contributor

wjiangjay commented Sep 25, 2018

After dig, and found the root reason,
we switch the terminal mode for exec, from cooked -> raw -> cooked,
but switch back to cooked from raw will got this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment