简体   繁体   中英

When Kubernetes client-go Remotecommand Stream finishes?

I am using this Remotecommand here https://github.com/kubernetes/client-go/blob/master/tools/remotecommand/remotecommand.go#L108 to execute a command on a pod and stream the result to an io.Writer . As stated in the command above the function in the link the Stream does finish only when client or server disconnect. As the Stream config has only one command attached, why doesn't it close when the command has exited? How can I know when the command has finished?

Particularly I am transferring the result of tar -cf - ... to the client and want to know when its finished.

I noticed that the Stream Function does run synchronously and blocks until the remote command has finished. Adding a one second timeout after calling writer.Close() prevented that the program exited before I could handle the received tar archive.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM