Skip to content

MuxedStreamNamespacedPodExecAsync doesn't open a V5 WebSocket #1946

Closed

Description

@AWehrhahn

Describe the bug
When requesting a StreamDemuxer using MuxedStreamNamespacedPodExecAsync with webSocketSubProtocol: WebSocketProtocol.V5BinaryWebsocketProtocol, it opens a v4 websocket instead

Kubernetes C# SDK Client Version
21.0.8

Server Kubernetes Version
1.36.1

Dotnet Runtime Version
net8

To Reproduce
Steps to reproduce the behavior:

  • create a Kubernetes client
  • create a helper pod with CoreV1.CreateNamespacedPodAsync
  • request a MuxedStreamNamespacedPodExecAsync with webSocketSubProtocol = WebSocketProtocol.V5BinaryWebsocketProtocol

Expected behavior
Expect a websocket with protocol V5

KubeConfig
If applicable, add a KubeConfig file with secrets redacted.

Where do you run your app with Kubernetes SDK (please complete the following information):

  • OS: Windows, with Kubernetes in Docker Desktop

Additional context
I am using ubuntu as the helper pod

I can get a V5 websocket using WebSocketNamespacedPodExecAsync and then create a StreamDemuxer like so:

    public async Task<IStreamDemuxer> MuxedStreamNamespacedPodExecAsync(
    string podName,
    string namespaceName,
    string containerName,
    IEnumerable<string> command,
    CancellationToken cancellationToken = default)
    {
        // Make our own StreamDemuxer from a websocket
        // since client.MuxedStreamNamespacedPodExecAsync does not properly open a V5 websocket
        var ws = await client.WebSocketNamespacedPodExecAsync(podName, namespaceName, command, containerName, tty: false, webSocketSubProtocol: WebSocketProtocol.V5BinaryWebsocketProtocol, cancellationToken: cancellationToken);

        if (ws.SubProtocol != WebSocketProtocol.V5BinaryWebsocketProtocol)
            throw new InvalidOperationException($"Expected Websocket protocol V5, but got {ws.SubProtocol}");

        return new StreamDemuxer(ws, StreamType.RemoteCommand, ownsSocket: true, supportsClose: true);
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions