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

Add support for resizeChannel in ExecWebSocketListener #1374

Closed
juju812 opened this issue Feb 27, 2019 · 23 comments · Fixed by #1533
Closed

Add support for resizeChannel in ExecWebSocketListener #1374

juju812 opened this issue Feb 27, 2019 · 23 comments · Fixed by #1533
Labels

Comments

@juju812
Copy link
Contributor

juju812 commented Feb 27, 2019

After walk through the ExecWebSocketListener I found that currently resizeChannel is not supported.
Is there any plan to support it? Or any other work around here to resize tty while bash execution?

Thx.

@juju812
Copy link
Contributor Author

juju812 commented Feb 28, 2019

seems like we can construct command with env to initialize terminal size like this:

exec("env", "TERM%3Dxterm", "COLUMNS%3D" + columns, "LINES%3D" + lines, "bash")

but without resizeChannel support we can't adjust the size online

@rohanKanojia
Copy link
Member

@juju812 : Hmm, Could you please create a PR for this?

@juju812
Copy link
Contributor Author

juju812 commented Mar 4, 2019

@rohanKanojia the workaround is just used for execute bash with tty. If a PR is need, in my view it can be added as an exec example.

Or I need to implement the resizeChannel in ExecWebSocketListener?

@rohanKanojia
Copy link
Member

@juju812 : if you have time to create PR with full implementation, then please do. Otherwise, we can add workaround as an example too to resolve confusion if someone else faces the same issue.

@juju812
Copy link
Contributor Author

juju812 commented Mar 5, 2019

@rohanKanojia A quick PR is created for the workaround.

And about the resizeChannel implementation, unfortunately I don't have time now, but I'll inform you if I start handling this.

@rohanKanojia
Copy link
Member

@juju812 : Much appreciated, Thanks 👍

@4qing
Copy link

4qing commented May 15, 2019

Hello, I now need this function to implement a web terminal that can dynamically change the size. I want to know if k8s supports this function. Which api is specific, I don’t seem to find this api on the k8s offical document.Thanks! @juju812

@rohanKanojia
Copy link
Member

@4qing : Maybe you can pick it up where @juju812 left.... We still need to implement resizeChannel in ExecWebSocketListener.

@4qing
Copy link

4qing commented May 16, 2019

Excuse me, I am bothered again, I looked at the python client implementation,kubernetes-client/python#515,it send message by this way :

self.k8s_stream.write_channel(4,
                                      json.dumps({"Height": rows,
                                                  "Width": cols}))

In our project, it seems that the message is sent in the following way:

private void send(byte[] bytes) throws IOException {
        if (bytes.length > 0) {
            WebSocket ws = webSocketRef.get();
            if (ws != null) {
                byte[] toSend = new byte[bytes.length + 1];
                toSend[0] = 0;
                System.arraycopy(bytes, 0, toSend, 1, bytes.length);
                ws.send(ByteString.of(toSend));
            }
        }
    }

Is this function changed the first bit of the array to 4 and then sends the message?
@rohanKanojia

@candyleer
Copy link
Contributor

hope for this feature...need resize channel too.

@candyleer
Copy link
Contributor

@4qing hi, do you have any idea how to implement this feature?

@candyleer
Copy link
Contributor

@juju812 can you provide the idea of how to implement or some document about this feature,we can help to implement this

@4qing
Copy link

4qing commented May 16, 2019

Yes, I have some ideas, but it is limited by my low level, it may be ugly, and I have not participated in the open source project before. If you are willing to wait, I can try to contribute this weekend. @candyleer

@candyleer
Copy link
Contributor

@4qing the resize channel,the streamId is 4?

@4qing
Copy link

4qing commented May 16, 2019

@4qing the resize channel,the streamId is 4?

yes

@candyleer
Copy link
Contributor

@4qing amazing! does anywhere have the specification for this protocol?, eg, 1 for message 2 for err,3 for errorChannel ,4 for resizeChannel

@4qing
Copy link

4qing commented May 16, 2019

@4qing amazing! does anywhere have the specification for this protocol?, eg, 1 for message 2 for err,3 for errorChannel ,4 for resizeChannel

I don't know ,I see the python code and try it,and this repo send common data is 0

@candyleer
Copy link
Contributor

@4qing thanks,recently I need the resize channel too,so I will learn and may make a PR to support this.

@candyleer
Copy link
Contributor

@4qing do you know how to send resize command to the outputstream? that mean how to tell kubenetes we should send a resize command insteam normal commands?

@candyleer
Copy link
Contributor

I know in io.fabric8.kubernetes.client.dsl.internal.ExecWebSocketListener#send

@candyleer
Copy link
Contributor

I read the kubenetes code and I know how to do in java client,I will make a PR today

@4qing
Copy link

4qing commented May 16, 2019

高山仰止,景行行止,虽不能至,心向往之,阿里就算了,向apache 的commiter致敬!

@fengyinqiao
Copy link

@4qing 我能看看你的webTerminal是怎么实现的吗?如何给前端暴露接口。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants