Skip to content

Kubernetes.StreamConnectAsync does not pass the CancellationToken to WebSocketBuilder.BuildAndConnectAsync #1503

Closed
@nathanwoctopusdeploy

Description

@nathanwoctopusdeploy

Describe the bug
A clear and concise description of what the bug is.

k8s.Kubernetes.StreamConnectAsync does not pass the CancellationToken to WebSocketBuilder.BuildAndConnectAsync so there is no way to cancel an in-progress connection attempt

webSocket = await webSocketBuilder.BuildAndConnectAsync(uri, CancellationToken.None)

Kubernetes C# SDK Client Version
master

Server Kubernetes Version
n/a

Dotnet Runtime Version
net6.0

To Reproduce
Steps to reproduce the behavior:

  • Use a method such as Kubernetes.WebSocketNamespacedPodExecAsync that calls Kubernetes.StreamConnectAsync with a CancellationToken
  • When await webSocketBuilder.BuildAndConnectAsync is executing cancel the CancellationToken
  • The connection attempt is not cancelled but continues to execute

Expected behavior
A clear and concise description of what you expected to happen.

  • When the CancellationToken is cancelled, the connection attempt should also be cancelled

KubeConfig
n/a

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

Additional context
If the call to WebSocketBuilder.BuildAndConnectAsync hangs while trying to establish the connection, there is currently no way to gracefully cancel this using the passed in CancellationToken and it can hang indefinitely

Metadata

Metadata

Assignees

No one assigned

    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