When Kubernetes client-go Remotecommand Stream finishes?

823 views Asked by At

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.

1

There are 1 answers

0
Techradar On BEST ANSWER

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.