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

help: resize method can not work in my project #3425

Closed
gy09535 opened this issue Aug 25, 2021 · 1 comment
Closed

help: resize method can not work in my project #3425

gy09535 opened this issue Aug 25, 2021 · 1 comment

Comments

@gy09535
Copy link

gy09535 commented Aug 25, 2021

Base issue #1374 .I use the resize method to change my channel size ,but it dose not work.
As I check the kubenetes code on #1533 , I find the link of kubenetes code is missing(https://github.com/kubernetes/kubernetes/blob/master/pkg/kubelet/server/remotecommand/websocket.go).
I confused is the feature abandoned or my code problem. Flowing is my code:

    @Override
    public void afterConnectionEstablished(WebSocketSession session) throws Exception {
        WsQuery query = getWsQuery(session.getAttributes());
        KubeWsOutputStream outputStream = new KubeWsOutputStream(session);
        ExecWatch execWatch;
        KubeWsBashInputStream inputStream = new KubeWsBashInputStream(session);
        if (StringUtils.isNotEmpty(query.getContainer())) {
            execWatch = KubeProxyContainer.get(query.getEnv()).pods().inNamespace(query.getNamespace()).withName(query.getName())
                    .inContainer(query.getContainer())
                    .readingInput(inputStream)
                    .writingOutput(outputStream)
                    .writingError(outputStream).withTTY().exec("/bin/bash");
        } else {
            execWatch = KubeProxyContainer.get(query.getEnv()).pods().inNamespace(query.getNamespace()).withName(query.getName())
                    .readingInput(inputStream)
                    .writingOutput(outputStream)
                    .writingError(outputStream).withTTY().exec("/bin/bash");
        }

        inputStream.setExecWatch(execWatch);
        this.execWatch = execWatch;
        KubeInputStreamManager.addInputStream(session.getId(), inputStream);
    }

    @Override
    public void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception {
        if (message.getPayload().startsWith("{")) {
            log.info("[handleTextMessage] receive resize data:{}", message.getPayload());
            try {
                ResizeRequest resizeRequest = objectMapper.readValue(message.getPayload(), ResizeRequest.class);
                execWatch.resize(resizeRequest.cols, resizeRequest.rows);
            } catch (Exception e) {
                log.warn("[handleTextMessage] resize request fail, request: {}, error: {}", message.getPayload(), e.getMessage());
            } finally {
                return;
            }
        }

        KubeInputStreamManager.enQueueBytes(session.getId(), message.getPayload().getBytes(StandardCharsets.UTF_8));
    }

@stale
Copy link

stale bot commented Nov 23, 2021

This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions!

@stale stale bot added the status/stale label Nov 23, 2021
@stale stale bot closed this as completed Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant