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

Pod.exec stdin never closes #212

Open
jacobtomlinson opened this issue Nov 21, 2023 · 2 comments
Open

Pod.exec stdin never closes #212

jacobtomlinson opened this issue Nov 21, 2023 · 2 comments
Labels
bug Something isn't working good second issue Clearly described and reproducible, but solution less clear than "good first issue" help wanted Extra attention is needed

Comments

@jacobtomlinson
Copy link
Member

jacobtomlinson commented Nov 21, 2023

Which project are you reporting a bug for?

kr8s

What happened?

When writing to stdin with Pod.exec(..., stdin=...) the stream is never closed. This means if the process being executed is waiting for the stdin file to be closed it will hang forever.

import kr8s, sys
pod = kr8s.objects.Pod.get("my-pod")
pod.exec(["cat"], stdin="hello", stdout=sys.stdout.buffer)
# I would expect `hello` to be printed to stdout but it just hangs forever

This seems to be a limitation of the websocket API in Kubernetes and is being tracked in kubernetes/kubernetes#89899. There is a KEP which should handle fixing this in a future release of Kubernetes kubernetes/enhancements#4016.

@jacobtomlinson jacobtomlinson added the bug Something isn't working label Nov 21, 2023
@jacobtomlinson
Copy link
Member Author

jacobtomlinson commented Nov 28, 2023

It looks like this has been resolved upstream via the V5 RemoteCommand protocol added in kubernetes/kubernetes#119157. This will be included in Kubernetes v1.29.

Once this release is out we need to retest this and make any appropriate changes. We may also need to add a check so that if the user tries to pass stdin on a cluster that is <1.29 they get a warning or error.

To close stdin we will need to send the channel ID (0) to the close channel 255.

@jacobtomlinson
Copy link
Member Author

Support for 1.29 just landed in #257 so we are no longer blocked in updating to the V5 RemoteCommand protocol.

We will need to decide what happens when folks are on older Kubernetes versions, maybe a warning or exception if they try and use stdin?

@jacobtomlinson jacobtomlinson added good second issue Clearly described and reproducible, but solution less clear than "good first issue" help wanted Extra attention is needed labels Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good second issue Clearly described and reproducible, but solution less clear than "good first issue" help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant